Loading libs/gui/BufferQueueProducer.cpp +20 −26 Original line number Original line Diff line number Diff line Loading @@ -1501,7 +1501,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, const bool useDefaultSize = !width && !height; const bool useDefaultSize = !width && !height; while (true) { while (true) { size_t newBufferCount = 0; uint32_t allocWidth = 0; uint32_t allocWidth = 0; uint32_t allocHeight = 0; uint32_t allocHeight = 0; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN; Loading @@ -1523,8 +1522,9 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, // Only allocate one buffer at a time to reduce risks of overlapping an allocation from // Only allocate one buffer at a time to reduce risks of overlapping an allocation from // both allocateBuffers and dequeueBuffer. // both allocateBuffers and dequeueBuffer. newBufferCount = mCore->mFreeSlots.empty() ? 0 : 1; if (mCore->mFreeSlots.empty()) { if (newBufferCount == 0) { BQ_LOGV("allocateBuffers: a slot was occupied while " "allocating. Dropping allocated buffer."); return; return; } } Loading Loading @@ -1566,8 +1566,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, }; }; #endif #endif Vector<sp<GraphicBuffer>> buffers; for (size_t i = 0; i < newBufferCount; ++i) { #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest); sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest); #else #else Loading @@ -1586,8 +1584,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, mCore->mIsAllocatingCondition.notify_all(); mCore->mIsAllocatingCondition.notify_all(); return; return; } } buffers.push_back(graphicBuffer); } { // Autolock scope { // Autolock scope std::unique_lock<std::mutex> lock(mCore->mMutex); std::unique_lock<std::mutex> lock(mCore->mMutex); Loading @@ -1614,15 +1610,13 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, continue; continue; } } for (size_t i = 0; i < newBufferCount; ++i) { if (mCore->mFreeSlots.empty()) { if (mCore->mFreeSlots.empty()) { BQ_LOGV("allocateBuffers: a slot was occupied while " BQ_LOGV("allocateBuffers: a slot was occupied while " "allocating. Dropping allocated buffer."); "allocating. Dropping allocated buffer."); continue; } else { } auto slot = mCore->mFreeSlots.begin(); auto slot = mCore->mFreeSlots.begin(); mCore->clearBufferSlotLocked(*slot); // Clean up the slot first mCore->clearBufferSlotLocked(*slot); // Clean up the slot first mSlots[*slot].mGraphicBuffer = buffers[i]; mSlots[*slot].mGraphicBuffer = graphicBuffer; mSlots[*slot].mFence = Fence::NO_FENCE; mSlots[*slot].mFence = Fence::NO_FENCE; #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) mSlots[*slot].mAdditionalOptionsGenerationId = allocOptionsGenId; mSlots[*slot].mAdditionalOptionsGenerationId = allocOptionsGenId; Loading Loading
libs/gui/BufferQueueProducer.cpp +20 −26 Original line number Original line Diff line number Diff line Loading @@ -1501,7 +1501,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, const bool useDefaultSize = !width && !height; const bool useDefaultSize = !width && !height; while (true) { while (true) { size_t newBufferCount = 0; uint32_t allocWidth = 0; uint32_t allocWidth = 0; uint32_t allocHeight = 0; uint32_t allocHeight = 0; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN; Loading @@ -1523,8 +1522,9 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, // Only allocate one buffer at a time to reduce risks of overlapping an allocation from // Only allocate one buffer at a time to reduce risks of overlapping an allocation from // both allocateBuffers and dequeueBuffer. // both allocateBuffers and dequeueBuffer. newBufferCount = mCore->mFreeSlots.empty() ? 0 : 1; if (mCore->mFreeSlots.empty()) { if (newBufferCount == 0) { BQ_LOGV("allocateBuffers: a slot was occupied while " "allocating. Dropping allocated buffer."); return; return; } } Loading Loading @@ -1566,8 +1566,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, }; }; #endif #endif Vector<sp<GraphicBuffer>> buffers; for (size_t i = 0; i < newBufferCount; ++i) { #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest); sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest); #else #else Loading @@ -1586,8 +1584,6 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, mCore->mIsAllocatingCondition.notify_all(); mCore->mIsAllocatingCondition.notify_all(); return; return; } } buffers.push_back(graphicBuffer); } { // Autolock scope { // Autolock scope std::unique_lock<std::mutex> lock(mCore->mMutex); std::unique_lock<std::mutex> lock(mCore->mMutex); Loading @@ -1614,15 +1610,13 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, continue; continue; } } for (size_t i = 0; i < newBufferCount; ++i) { if (mCore->mFreeSlots.empty()) { if (mCore->mFreeSlots.empty()) { BQ_LOGV("allocateBuffers: a slot was occupied while " BQ_LOGV("allocateBuffers: a slot was occupied while " "allocating. Dropping allocated buffer."); "allocating. Dropping allocated buffer."); continue; } else { } auto slot = mCore->mFreeSlots.begin(); auto slot = mCore->mFreeSlots.begin(); mCore->clearBufferSlotLocked(*slot); // Clean up the slot first mCore->clearBufferSlotLocked(*slot); // Clean up the slot first mSlots[*slot].mGraphicBuffer = buffers[i]; mSlots[*slot].mGraphicBuffer = graphicBuffer; mSlots[*slot].mFence = Fence::NO_FENCE; mSlots[*slot].mFence = Fence::NO_FENCE; #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE) mSlots[*slot].mAdditionalOptionsGenerationId = allocOptionsGenId; mSlots[*slot].mAdditionalOptionsGenerationId = allocOptionsGenId; Loading