diff options
| -rw-r--r-- | services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp | 15 | ||||
| -rw-r--r-- | services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index fba3261388..c8cd442e11 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -73,6 +73,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, mOutputUsage(GRALLOC_USAGE_HW_COMPOSER), mProducerSlotSource(0), mProducerBuffers(), + mProducerSlotNeedReallocation(0), mQueueBufferOutput(), mSinkBufferWidth(0), mSinkBufferHeight(0), @@ -335,10 +336,14 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source, dbgSourceStr(source), *sslot, pslot, result); uint64_t sourceBit = static_cast<uint64_t>(source) << pslot; + // reset producer slot reallocation flag + mProducerSlotNeedReallocation &= ~(1ULL << pslot); + if ((mProducerSlotSource & (1ULL << pslot)) != sourceBit) { // This slot was previously dequeued from the other source; must // re-request the buffer. - result |= BUFFER_NEEDS_REALLOCATION; + mProducerSlotNeedReallocation |= 1ULL << pslot; + mProducerSlotSource &= ~(1ULL << pslot); mProducerSlotSource |= sourceBit; } @@ -360,6 +365,9 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source, dbgSourceStr(source), pslot, mProducerBuffers[pslot].get(), mProducerBuffers[pslot]->getPixelFormat(), mProducerBuffers[pslot]->getUsage()); + + // propagate reallocation to VDS consumer + mProducerSlotNeedReallocation |= 1ULL << pslot; } return result; @@ -434,6 +442,11 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, uint if (outBufferAge) { *outBufferAge = 0; } + + if ((mProducerSlotNeedReallocation & (1ULL << *pslot)) != 0) { + result |= BUFFER_NEEDS_REALLOCATION; + } + return result; } diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h index 3cbad8f8ae..22b552857a 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h @@ -180,6 +180,10 @@ private: uint64_t mProducerSlotSource; sp<GraphicBuffer> mProducerBuffers[BufferQueueDefs::NUM_BUFFER_SLOTS]; + // Need to propagate reallocation to VDS consumer. + // Each bit corresponds to a producer slot. + uint64_t mProducerSlotNeedReallocation; + // The QueueBufferOutput with the latest info from the sink, and with the // transform hint cleared. Since we defer queueBuffer from the GPU driver // to the sink, we have to return the previous version. |