diff options
| author | 2021-09-29 17:33:10 -0700 | |
|---|---|---|
| committer | 2021-09-30 20:43:07 +0000 | |
| commit | 932f6aee50abb4f4c71b172a99afd9440e7896ab (patch) | |
| tree | 9b9bba0c5557253efe266e9a1a68eab959893ca7 /libs/gui/BLASTBufferQueue.cpp | |
| parent | fb4e33acfe0c432d19c1716d7d3405238ecd039e (diff) | |
BlastBufferQueue: Fix scaling when buffer scaling mode changes
The current logic updates the target size of the buffer when a buffer
arrives with FREEZE scaling mode (target size == buffer size) or when
the target size is set and the previous buffer has a scaling mode
!FREEZE. This is because if the previous scaling mode is freeze, we
do not want to change the target size otherwise we will break the
contract with the client and scale the currently presented buffer.
In the case of YoutubeMusic on TV, the client sets a target size,
then submits a buffer with scaling mode FREEZE, then changes
the target size but submits a buffer with scaling mode
SCALE_TO_WINDOW. The new target size never gets sent to
SurfaceFlinger. To fix this we check if the target size has been
updated when acquiring a buffer and update the target size.
Test: atest BLASTBufferQueueTest SurfaceViewSyncTest
Bug: 196339769
Change-Id: I6db3411b64552e5a4416d60420c92e698beda311
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 8 | 
1 files changed, 3 insertions, 5 deletions
| diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index d1f57b03bc..9f52487857 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -456,10 +456,10 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {      // Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback.      incStrong((void*)transactionCallbackThunk); +    const bool sizeHasChanged = mRequestedSize != mSize; +    mSize = mRequestedSize; +    const bool updateDestinationFrame = sizeHasChanged || !mLastBufferInfo.hasBuffer;      Rect crop = computeCrop(bufferItem); -    const bool updateDestinationFrame = -            bufferItem.mScalingMode == NATIVE_WINDOW_SCALING_MODE_FREEZE || -            !mLastBufferInfo.hasBuffer;      mLastBufferInfo.update(true /* hasBuffer */, bufferItem.mGraphicBuffer->getWidth(),                             bufferItem.mGraphicBuffer->getHeight(), bufferItem.mTransform,                             bufferItem.mScalingMode, crop); @@ -586,7 +586,6 @@ void BLASTBufferQueue::setNextTransaction(SurfaceComposerClient::Transaction* t)  bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) {      if (item.mScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) { -        mSize = mRequestedSize;          // Only reject buffers if scaling mode is freeze.          return false;      } @@ -600,7 +599,6 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) {      }      ui::Size bufferSize(bufWidth, bufHeight);      if (mRequestedSize != mSize && mRequestedSize == bufferSize) { -        mSize = mRequestedSize;          return false;      } |