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

Commit 7ebff4af authored by Vishnu Nair's avatar Vishnu Nair Committed by Automerger Merge Worker
Browse files

Merge "SurfaceView: Synchronize destframe updates with SurfaceView size...

Merge "SurfaceView: Synchronize destframe updates with SurfaceView size changes" into sc-dev am: edec715c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15363852

Change-Id: If77029f7df94092da9ff01972dfec8ed8fa6c7db
parents 3a93be54 edec715c
Loading
Loading
Loading
Loading
+17 −8
Original line number Original line Diff line number Diff line
@@ -168,6 +168,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont
    SurfaceComposerClient::Transaction()
    SurfaceComposerClient::Transaction()
            .setFlags(surface, layer_state_t::eEnableBackpressure,
            .setFlags(surface, layer_state_t::eEnableBackpressure,
                      layer_state_t::eEnableBackpressure)
                      layer_state_t::eEnableBackpressure)
            .setApplyToken(mApplyToken)
            .apply();
            .apply();
    mNumAcquired = 0;
    mNumAcquired = 0;
    mNumFrameAvailable = 0;
    mNumFrameAvailable = 0;
@@ -190,7 +191,7 @@ BLASTBufferQueue::~BLASTBufferQueue() {
}
}


void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height,
void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height,
                              int32_t format) {
                              int32_t format, SurfaceComposerClient::Transaction* outTransaction) {
    std::unique_lock _lock{mMutex};
    std::unique_lock _lock{mMutex};
    if (mFormat != format) {
    if (mFormat != format) {
        mFormat = format;
        mFormat = format;
@@ -227,15 +228,18 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width,
            // We only need to update the scale if we've received at least one buffer. The reason
            // 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.
            // 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 there's no buffer, the scale will always be 1.
            SurfaceComposerClient::Transaction* destFrameTransaction =
                    (outTransaction) ? outTransaction : &t;
            if (mSurfaceControl != nullptr && mLastBufferInfo.hasBuffer) {
            if (mSurfaceControl != nullptr && mLastBufferInfo.hasBuffer) {
                t.setDestinationFrame(mSurfaceControl,
                destFrameTransaction->setDestinationFrame(mSurfaceControl,
                                      Rect(0, 0, newSize.getWidth(), newSize.getHeight()));
                                                          Rect(0, 0, newSize.getWidth(),
                                                               newSize.getHeight()));
            }
            }
            applyTransaction = true;
            applyTransaction = true;
        }
        }
    }
    }
    if (applyTransaction) {
    if (applyTransaction) {
        t.apply();
        t.setApplyToken(mApplyToken).apply();
    }
    }
}
}


@@ -453,6 +457,9 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {
    incStrong((void*)transactionCallbackThunk);
    incStrong((void*)transactionCallbackThunk);


    Rect crop = computeCrop(bufferItem);
    Rect crop = computeCrop(bufferItem);
    const bool updateDestinationFrame =
            bufferItem.mScalingMode == NATIVE_WINDOW_SCALING_MODE_FREEZE ||
            !mLastBufferInfo.hasBuffer;
    mLastBufferInfo.update(true /* hasBuffer */, bufferItem.mGraphicBuffer->getWidth(),
    mLastBufferInfo.update(true /* hasBuffer */, bufferItem.mGraphicBuffer->getWidth(),
                           bufferItem.mGraphicBuffer->getHeight(), bufferItem.mTransform,
                           bufferItem.mGraphicBuffer->getHeight(), bufferItem.mTransform,
                           bufferItem.mScalingMode, crop);
                           bufferItem.mScalingMode, crop);
@@ -470,7 +477,9 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {
    t->addTransactionCompletedCallback(transactionCallbackThunk, static_cast<void*>(this));
    t->addTransactionCompletedCallback(transactionCallbackThunk, static_cast<void*>(this));
    mSurfaceControlsWithPendingCallback.push(mSurfaceControl);
    mSurfaceControlsWithPendingCallback.push(mSurfaceControl);


    if (updateDestinationFrame) {
        t->setDestinationFrame(mSurfaceControl, Rect(0, 0, mSize.getWidth(), mSize.getHeight()));
        t->setDestinationFrame(mSurfaceControl, Rect(0, 0, mSize.getWidth(), mSize.getHeight()));
    }
    t->setBufferCrop(mSurfaceControl, crop);
    t->setBufferCrop(mSurfaceControl, crop);
    t->setTransform(mSurfaceControl, bufferItem.mTransform);
    t->setTransform(mSurfaceControl, bufferItem.mTransform);
    t->setTransformToDisplayInverse(mSurfaceControl, bufferItem.mTransformToDisplayInverse);
    t->setTransformToDisplayInverse(mSurfaceControl, bufferItem.mTransformToDisplayInverse);
+2 −1
Original line number Original line Diff line number Diff line
@@ -96,7 +96,8 @@ public:
    void setTransactionCompleteCallback(uint64_t frameNumber,
    void setTransactionCompleteCallback(uint64_t frameNumber,
                                        std::function<void(int64_t)>&& transactionCompleteCallback);
                                        std::function<void(int64_t)>&& transactionCompleteCallback);


    void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format);
    void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format,
                SurfaceComposerClient::Transaction* outTransaction = nullptr);
    void flushShadowQueue() {}
    void flushShadowQueue() {}


    status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless);
    status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless);