Loading libs/gui/BLASTBufferQueue.cpp +7 −22 Original line number Diff line number Diff line Loading @@ -204,16 +204,13 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, if (mRequestedSize != newSize) { mRequestedSize.set(newSize); mBufferItemConsumer->setDefaultBufferSize(mRequestedSize.width, mRequestedSize.height); if (mLastBufferInfo.scalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) { if (mLastBufferScalingMode != 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; // 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); } t.setFrame(mSurfaceControl, {0, 0, static_cast<int32_t>(mSize.width), static_cast<int32_t>(mSize.height)}); applyTransaction = true; } } Loading Loading @@ -377,10 +374,8 @@ 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 */, Loading @@ -393,7 +388,8 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE); t->addTransactionCompletedCallback(transactionCallbackThunk, static_cast<void*>(this)); setMatrix(t, mLastBufferInfo); t->setFrame(mSurfaceControl, {0, 0, static_cast<int32_t>(mSize.width), static_cast<int32_t>(mSize.height)}); t->setCrop(mSurfaceControl, computeCrop(bufferItem)); t->setTransform(mSurfaceControl, bufferItem.mTransform); t->setTransformToDisplayInverse(mSurfaceControl, bufferItem.mTransformToDisplayInverse); Loading Loading @@ -519,17 +515,6 @@ 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}; Loading libs/gui/LayerState.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,10 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eCropChanged; crop = other.crop; } if (other.what & eFrameChanged) { what |= eFrameChanged; orientedDisplaySpaceRect = other.orientedDisplaySpaceRect; } if (other.what & eBufferChanged) { what |= eBufferChanged; buffer = other.buffer; Loading libs/gui/SurfaceComposerClient.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1246,6 +1246,20 @@ SurfaceComposerClient::Transaction::setTransformToDisplayInverse(const sp<Surfac return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame( const sp<SurfaceControl>& sc, const Rect& frame) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eFrameChanged; s->orientedDisplaySpaceRect = frame; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffer( const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer, ReleaseBufferCallback callback) { Loading libs/gui/include/gui/BLASTBufferQueue.h +5 −27 Original line number Diff line number Diff line Loading @@ -142,33 +142,6 @@ private: ui::Size mRequestedSize GUARDED_BY(mMutex); int32_t mFormat GUARDED_BY(mMutex); struct BufferInfo { bool hasBuffer = false; uint32_t width; uint32_t height; uint32_t transform; // This is used to check if we should update the blast layer size immediately or wait until // we get the next buffer. This will support scenarios where the layer can change sizes // and the buffer will scale to fit the new size. uint32_t scalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW; void update(bool hasBuffer, uint32_t width, uint32_t height, uint32_t transform, uint32_t scalingMode) { this->hasBuffer = hasBuffer; this->width = width; this->height = height; this->transform = transform; this->scalingMode = scalingMode; } }; // Last acquired buffer's info. This is used to calculate the correct scale when size change is // requested. We need to use the old buffer's info to determine what scale we need to apply to // ensure the correct size. BufferInfo mLastBufferInfo GUARDED_BY(mMutex); void setMatrix(SurfaceComposerClient::Transaction* t, const BufferInfo& bufferInfo) REQUIRES(mMutex); uint32_t mTransformHint GUARDED_BY(mMutex); sp<IGraphicBufferConsumer> mConsumer; Loading @@ -186,6 +159,11 @@ private: std::queue<FrameTimelineInfo> mNextFrameTimelineInfoQueue GUARDED_BY(mMutex); // Last acquired buffer's scaling mode. This is used to check if we should update the blast // layer size immediately or wait until we get the next buffer. This will support scenarios // where the layer can change sizes and the buffer will scale to fit the new size. uint32_t mLastBufferScalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW; // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; Loading libs/gui/include/gui/LayerState.h +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ struct layer_state_t { eHasListenerCallbacksChanged = 0x20000000, eInputInfoChanged = 0x40000000, eCornerRadiusChanged = 0x80000000, /* was eFrameChanged, now available 0x1'00000000, */ eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, eBackgroundColorChanged = 0x4'00000000, eMetadataChanged = 0x8'00000000, Loading Loading
libs/gui/BLASTBufferQueue.cpp +7 −22 Original line number Diff line number Diff line Loading @@ -204,16 +204,13 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, if (mRequestedSize != newSize) { mRequestedSize.set(newSize); mBufferItemConsumer->setDefaultBufferSize(mRequestedSize.width, mRequestedSize.height); if (mLastBufferInfo.scalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) { if (mLastBufferScalingMode != 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; // 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); } t.setFrame(mSurfaceControl, {0, 0, static_cast<int32_t>(mSize.width), static_cast<int32_t>(mSize.height)}); applyTransaction = true; } } Loading Loading @@ -377,10 +374,8 @@ 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 */, Loading @@ -393,7 +388,8 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE); t->addTransactionCompletedCallback(transactionCallbackThunk, static_cast<void*>(this)); setMatrix(t, mLastBufferInfo); t->setFrame(mSurfaceControl, {0, 0, static_cast<int32_t>(mSize.width), static_cast<int32_t>(mSize.height)}); t->setCrop(mSurfaceControl, computeCrop(bufferItem)); t->setTransform(mSurfaceControl, bufferItem.mTransform); t->setTransformToDisplayInverse(mSurfaceControl, bufferItem.mTransformToDisplayInverse); Loading Loading @@ -519,17 +515,6 @@ 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}; Loading
libs/gui/LayerState.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,10 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eCropChanged; crop = other.crop; } if (other.what & eFrameChanged) { what |= eFrameChanged; orientedDisplaySpaceRect = other.orientedDisplaySpaceRect; } if (other.what & eBufferChanged) { what |= eBufferChanged; buffer = other.buffer; Loading
libs/gui/SurfaceComposerClient.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1246,6 +1246,20 @@ SurfaceComposerClient::Transaction::setTransformToDisplayInverse(const sp<Surfac return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame( const sp<SurfaceControl>& sc, const Rect& frame) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eFrameChanged; s->orientedDisplaySpaceRect = frame; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffer( const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer, ReleaseBufferCallback callback) { Loading
libs/gui/include/gui/BLASTBufferQueue.h +5 −27 Original line number Diff line number Diff line Loading @@ -142,33 +142,6 @@ private: ui::Size mRequestedSize GUARDED_BY(mMutex); int32_t mFormat GUARDED_BY(mMutex); struct BufferInfo { bool hasBuffer = false; uint32_t width; uint32_t height; uint32_t transform; // This is used to check if we should update the blast layer size immediately or wait until // we get the next buffer. This will support scenarios where the layer can change sizes // and the buffer will scale to fit the new size. uint32_t scalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW; void update(bool hasBuffer, uint32_t width, uint32_t height, uint32_t transform, uint32_t scalingMode) { this->hasBuffer = hasBuffer; this->width = width; this->height = height; this->transform = transform; this->scalingMode = scalingMode; } }; // Last acquired buffer's info. This is used to calculate the correct scale when size change is // requested. We need to use the old buffer's info to determine what scale we need to apply to // ensure the correct size. BufferInfo mLastBufferInfo GUARDED_BY(mMutex); void setMatrix(SurfaceComposerClient::Transaction* t, const BufferInfo& bufferInfo) REQUIRES(mMutex); uint32_t mTransformHint GUARDED_BY(mMutex); sp<IGraphicBufferConsumer> mConsumer; Loading @@ -186,6 +159,11 @@ private: std::queue<FrameTimelineInfo> mNextFrameTimelineInfoQueue GUARDED_BY(mMutex); // Last acquired buffer's scaling mode. This is used to check if we should update the blast // layer size immediately or wait until we get the next buffer. This will support scenarios // where the layer can change sizes and the buffer will scale to fit the new size. uint32_t mLastBufferScalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW; // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; Loading
libs/gui/include/gui/LayerState.h +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ struct layer_state_t { eHasListenerCallbacksChanged = 0x20000000, eInputInfoChanged = 0x40000000, eCornerRadiusChanged = 0x80000000, /* was eFrameChanged, now available 0x1'00000000, */ eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, eBackgroundColorChanged = 0x4'00000000, eMetadataChanged = 0x8'00000000, Loading