Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f22c4c07 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "BlastBufferQueue: Update layer size immediately if the buffer can scale"

parents 3acd4b31 53c936ca
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -150,6 +150,16 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width,
    if (mRequestedSize != newSize) {
    if (mRequestedSize != newSize) {
        mRequestedSize.set(newSize);
        mRequestedSize.set(newSize);
        mBufferItemConsumer->setDefaultBufferSize(mRequestedSize.width, mRequestedSize.height);
        mBufferItemConsumer->setDefaultBufferSize(mRequestedSize.width, mRequestedSize.height);
        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;
            SurfaceComposerClient::Transaction t;
            t.setFrame(mSurfaceControl,
                       {0, 0, static_cast<int32_t>(mSize.width),
                        static_cast<int32_t>(mSize.height)});
            t.apply();
        }
    }
    }
}
}


@@ -276,6 +286,8 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {
    // Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback.
    // Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback.
    incStrong((void*)transactionCallbackThunk);
    incStrong((void*)transactionCallbackThunk);


    mLastBufferScalingMode = bufferItem.mScalingMode;

    t->setBuffer(mSurfaceControl, buffer);
    t->setBuffer(mSurfaceControl, buffer);
    t->setAcquireFence(mSurfaceControl,
    t->setAcquireFence(mSurfaceControl,
                       bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE);
                       bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE);
@@ -348,7 +360,6 @@ void BLASTBufferQueue::setNextTransaction(SurfaceComposerClient::Transaction* t)


bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) {
bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) {
    if (item.mScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) {
    if (item.mScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE) {
        mSize = mRequestedSize;
        // Only reject buffers if scaling mode is freeze.
        // Only reject buffers if scaling mode is freeze.
        return false;
        return false;
    }
    }
+5 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,11 @@ private:
    bool mAutoRefresh GUARDED_BY(mMutex) = false;
    bool mAutoRefresh GUARDED_BY(mMutex) = false;


    std::queue<int64_t> mNextFrameTimelineVsyncIdQueue GUARDED_BY(mMutex);
    std::queue<int64_t> mNextFrameTimelineVsyncIdQueue 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;
};
};


} // namespace android
} // namespace android