diff options
author | 2021-03-11 16:44:42 -0600 | |
---|---|---|
committer | 2021-03-30 15:53:01 -0500 | |
commit | 9a93ea66bb7116b8821877a69991ae94557b1303 (patch) | |
tree | 40a457bee0e057406fb8b35ad418383c909812e0 /libs/gui/BLASTBufferQueue.cpp | |
parent | 9fc9513410b4b3e6889f5b201e5235ec062bddcd (diff) |
Remove setFrame from BufferStateLayer
Replace setFrame with setCrop, setMatrix, and setPosition
Test: SurfaceFlinger_tests
Test: ASurfaceControlTest
Bug: 170765639
Change-Id: I32ee0e3e48e5171d99a5f5af0b7583165d4dd9f9
Diffstat (limited to 'libs/gui/BLASTBufferQueue.cpp')
-rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 1976b493b2..1d7ed2f97b 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -204,13 +204,16 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, if (mRequestedSize != newSize) { mRequestedSize.set(newSize); mBufferItemConsumer->setDefaultBufferSize(mRequestedSize.width, mRequestedSize.height); - if (mLastBufferScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) { + if (mLastBufferInfo.scalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) { // If the buffer supports scaling, update the frame immediately since the client may // want to scale the existing buffer to the new size. mSize = mRequestedSize; - t.setFrame(mSurfaceControl, - {0, 0, static_cast<int32_t>(mSize.width), - static_cast<int32_t>(mSize.height)}); + // We only need to update the scale if we've received at least one buffer. The reason + // for this is the scale is calculated based on the requested size and buffer size. + // If there's no buffer, the scale will always be 1. + if (mLastBufferInfo.hasBuffer) { + setMatrix(&t, mLastBufferInfo); + } applyTransaction = true; } } @@ -374,8 +377,10 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { // Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback. incStrong((void*)transactionCallbackThunk); - mLastBufferScalingMode = bufferItem.mScalingMode; mLastAcquiredFrameNumber = bufferItem.mFrameNumber; + mLastBufferInfo.update(true /* hasBuffer */, bufferItem.mGraphicBuffer->getWidth(), + bufferItem.mGraphicBuffer->getHeight(), bufferItem.mTransform, + bufferItem.mScalingMode); auto releaseBufferCallback = std::bind(releaseBufferCallbackThunk, wp<BLASTBufferQueue>(this) /* callbackContext */, @@ -388,8 +393,7 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE); t->addTransactionCompletedCallback(transactionCallbackThunk, static_cast<void*>(this)); - t->setFrame(mSurfaceControl, - {0, 0, static_cast<int32_t>(mSize.width), static_cast<int32_t>(mSize.height)}); + setMatrix(t, mLastBufferInfo); t->setCrop(mSurfaceControl, computeCrop(bufferItem)); t->setTransform(mSurfaceControl, bufferItem.mTransform); t->setTransformToDisplayInverse(mSurfaceControl, bufferItem.mTransformToDisplayInverse); @@ -515,6 +519,17 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) { return mSize != bufferSize; } +void BLASTBufferQueue::setMatrix(SurfaceComposerClient::Transaction* t, + const BufferInfo& bufferInfo) { + uint32_t bufWidth = bufferInfo.width; + uint32_t bufHeight = bufferInfo.height; + + float dsdx = mSize.width / static_cast<float>(bufWidth); + float dsdy = mSize.height / static_cast<float>(bufHeight); + + t->setMatrix(mSurfaceControl, dsdx, 0, 0, dsdy); +} + void BLASTBufferQueue::setTransactionCompleteCallback( uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback) { std::lock_guard _lock{mMutex}; |