From 932f6aee50abb4f4c71b172a99afd9440e7896ab Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 29 Sep 2021 17:33:10 -0700 Subject: 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 --- libs/gui/BLASTBufferQueue.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') 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; } -- cgit v1.2.3-59-g8ed1b