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

Commit 82364e3c authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceFlinger: Add mode to apply position with resize.

For some cases, like scaled windows with shadows,
we need to be able to apply the position concurrent with
window resize. This is because the scaling of the shadows causes
the top left coordinate of the non shadow surface content
to change before and after the resize.

Bug: 28899837
Change-Id: I522eacfbbcd79707dc1e5ab71901a263b3004ba9
parent d224e611
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -140,6 +140,8 @@ public:
            const sp<IBinder>& handle, uint64_t frameNumber);
    status_t    setOverrideScalingMode(const sp<IBinder>& id,
            int32_t overrideScalingMode);
    status_t    setPositionAppliesWithResize(const sp<IBinder>& id);

    status_t    destroySurface(const sp<IBinder>& id);

    status_t clearLayerFrameStats(const sp<IBinder>& token) const;
+5 −0
Original line number Diff line number Diff line
@@ -73,6 +73,11 @@ public:
    status_t    setCrop(const Rect& crop);
    status_t    setFinalCrop(const Rect& crop);

    // If the size changes in this transaction, position updates specified
    // in this transaction will not complete until a buffer of the new size
    // arrives.
    status_t    setPositionAppliesWithResize();

    // Defers applying any changes made in this transaction until the Layer
    // identified by handle reaches the given frameNumber
    status_t deferTransactionUntil(sp<IBinder> handle, uint64_t frameNumber);
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ struct layer_state_t {
        eCropChanged                = 0x00000100,
        eDeferTransaction           = 0x00000200,
        eFinalCropChanged           = 0x00000400,
        eOverrideScalingModeChanged = 0x00000800
        eOverrideScalingModeChanged = 0x00000800,
        ePositionAppliesWithResize  = 0x00001000,
    };

    layer_state_t()
+19 −0
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ public:
            uint64_t frameNumber);
    status_t setOverrideScalingMode(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, int32_t overrideScalingMode);
    status_t setPositionAppliesWithResize(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id);

    void setDisplaySurface(const sp<IBinder>& token,
            const sp<IGraphicBufferProducer>& bufferProducer);
@@ -443,6 +445,18 @@ status_t Composer::setOverrideScalingMode(
    return NO_ERROR;
}

status_t Composer::setPositionAppliesWithResize(
        const sp<SurfaceComposerClient>& client,
        const sp<IBinder>& id) {
    Mutex::Autolock lock(mLock);
    layer_state_t* s = getLayerStateLocked(client, id);
    if (!s) {
        return BAD_INDEX;
    }
    s->what |= layer_state_t::ePositionAppliesWithResize;
    return NO_ERROR;
}

// ---------------------------------------------------------------------------

DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
@@ -685,6 +699,11 @@ status_t SurfaceComposerClient::setOverrideScalingMode(
            this, id, overrideScalingMode);
}

status_t SurfaceComposerClient::setPositionAppliesWithResize(
        const sp<IBinder>& id) {
    return getComposer().setPositionAppliesWithResize(this, id);
}

// ----------------------------------------------------------------------------

void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token,
+5 −0
Original line number Diff line number Diff line
@@ -112,6 +112,11 @@ status_t SurfaceControl::setPosition(float x, float y) {
    if (err < 0) return err;
    return mClient->setPosition(mHandle, x, y);
}
status_t SurfaceControl::setPositionAppliesWithResize() {
    status_t err = validate();
    if (err < 0) return err;
    return mClient->setPositionAppliesWithResize(mHandle);
}
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
    status_t err = validate();
    if (err < 0) return err;
Loading