summaryrefslogtreecommitdiff
path: root/libs/gui/BLASTBufferQueue.cpp
diff options
context:
space:
mode:
author Chavi Weingarten <chaviw@google.com> 2023-02-22 17:36:40 +0000
committer Chavi Weingarten <chaviw@google.com> 2023-02-22 17:36:40 +0000
commit70670e63cec845ae61fe34059475c1919a2f078a (patch)
treedf9ecccba93afc52b6ab8980b9406301047a3aa6 /libs/gui/BLASTBufferQueue.cpp
parent5fc135bf77a1d4379aca32d2b400cd3ff864d6fc (diff)
[BBQ] Only update destination frame when buffer matches requested
The current code in BBQ won't reject the buffer if the buffer size and last size match, even if requested size doesn't match. This is fine as long as we don't also update the destination frame to the new requested size. We can apply the old buffer, so we don't drop additional buffers, but keep the last destination frame as the last requested size. When we get a new buffer that matches the new requested size, we can update the destination frame. Without this fix, the buffer could be stretched in FREEZE mode since the buffer size will end up not matching the destination frame set in SF. Test: SurfaceSyncGroupContinuousTest Fixes: 267284591 Change-Id: Id8bc8b6e04fa1cc56f7b9eb609cadb208b27b3ea
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
-rw-r--r--libs/gui/BLASTBufferQueue.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index 9d82c143f5..cf8b13ffa4 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -486,6 +486,17 @@ void BLASTBufferQueue::releaseBuffer(const ReleaseCallbackId& callbackId,
mSyncedFrameNumbers.erase(callbackId.framenumber);
}
+static ui::Size getBufferSize(const BufferItem& item) {
+ uint32_t bufWidth = item.mGraphicBuffer->getWidth();
+ uint32_t bufHeight = item.mGraphicBuffer->getHeight();
+
+ // Take the buffer's orientation into account
+ if (item.mTransform & ui::Transform::ROT_90) {
+ std::swap(bufWidth, bufHeight);
+ }
+ return ui::Size(bufWidth, bufHeight);
+}
+
status_t BLASTBufferQueue::acquireNextBufferLocked(
const std::optional<SurfaceComposerClient::Transaction*> transaction) {
// Check if we have frames available and we have not acquired the maximum number of buffers.
@@ -563,7 +574,12 @@ status_t BLASTBufferQueue::acquireNextBufferLocked(
// Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback.
incStrong((void*)transactionCallbackThunk);
- mSize = mRequestedSize;
+ // Only update mSize for destination bounds if the incoming buffer matches the requested size.
+ // Otherwise, it could cause stretching since the destination bounds will update before the
+ // buffer with the new size is acquired.
+ if (mRequestedSize == getBufferSize(bufferItem)) {
+ mSize = mRequestedSize;
+ }
Rect crop = computeCrop(bufferItem);
mLastBufferInfo.update(true /* hasBuffer */, bufferItem.mGraphicBuffer->getWidth(),
bufferItem.mGraphicBuffer->getHeight(), bufferItem.mTransform,
@@ -834,14 +850,7 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) {
return false;
}
- uint32_t bufWidth = item.mGraphicBuffer->getWidth();
- uint32_t bufHeight = item.mGraphicBuffer->getHeight();
-
- // Take the buffer's orientation into account
- if (item.mTransform & ui::Transform::ROT_90) {
- std::swap(bufWidth, bufHeight);
- }
- ui::Size bufferSize(bufWidth, bufHeight);
+ ui::Size bufferSize = getBufferSize(item);
if (mRequestedSize != mSize && mRequestedSize == bufferSize) {
return false;
}