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

Commit 9524cb3b authored by Robert Carr's avatar Robert Carr
Browse files

Add detachChildren transaction.

Add SurfaceControl#detachChildren for use by the WindowManager.
This method is used in cases where the WM would previously preserve
windows the client tried to destroy. For example, when becoming invisible
(in the activity lifecycle sense, not in the SurfaceFlinger sense)
an app will destroy its child surfaces. Previously the WM would keep child
windows alive until the animation finishes to prevent glitches. The new
scheme for this is the WM will detach the children at this point,
at which point the parent layer becomes the owner of the children and the WM
can control the lifecycle as it wishes. I also included a test for reparentChildren
as I realized I had forgotten that.

Test: New test in Transaction_test.cpp
Change-Id: I79c22b2ccccceb9bdcc37b70c491bdf33dcf83d2
parent 0d48072f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ public:
            const sp<Surface>& handle, uint64_t frameNumber);
    status_t    reparentChildren(const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t    detachChildren(const sp<IBinder>& id);
    status_t    setOverrideScalingMode(const sp<IBinder>& id,
            int32_t overrideScalingMode);
    status_t    setGeometryAppliesWithResize(const sp<IBinder>& id);
+12 −0
Original line number Diff line number Diff line
@@ -93,6 +93,18 @@ public:
    // Reparents all children of this layer to the new parent handle.
    status_t reparentChildren(const sp<IBinder>& newParentHandle);

    // Detaches all child surfaces (and their children recursively)
    // from their SurfaceControl.
    // The child SurfaceControl's will not throw exceptions or return errors,
    // but transactions will have no effect.
    // The child surfaces will continue to follow their parent surfaces,
    // and remain eligible for rendering, but their relative state will be
    // frozen. We use this in the WindowManager, in app shutdown/relaunch
    // scenarios, where the app would otherwise clean up its child Surfaces.
    // Sometimes the WindowManager needs to extend their lifetime slightly
    // in order to perform an exit animation or prevent flicker.
    status_t detachChildren();

    // Set an override scaling mode as documented in <system/window.h>
    // the override scaling mode will take precedence over any client
    // specified scaling mode. -1 will clear the override scaling mode.
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ struct layer_state_t {
        eOverrideScalingModeChanged = 0x00000800,
        eGeometryAppliesWithResize  = 0x00001000,
        eReparentChildren           = 0x00002000,
        eDetachChildren             = 0x00004000
    };

    layer_state_t()
+18 −0
Original line number Diff line number Diff line
@@ -175,6 +175,8 @@ public:
    status_t reparentChildren(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t detachChildren(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id);
    status_t setOverrideScalingMode(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, int32_t overrideScalingMode);
    status_t setGeometryAppliesWithResize(const sp<SurfaceComposerClient>& client,
@@ -476,6 +478,18 @@ status_t Composer::reparentChildren(
    return NO_ERROR;
}

status_t Composer::detachChildren(
        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::eDetachChildren;
    return NO_ERROR;
}

status_t Composer::setOverrideScalingMode(
        const sp<SurfaceComposerClient>& client,
        const sp<IBinder>& id, int32_t overrideScalingMode) {
@@ -805,6 +819,10 @@ status_t SurfaceComposerClient::reparentChildren(const sp<IBinder>& id,
    return getComposer().reparentChildren(this, id, newParentHandle);
}

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

status_t SurfaceComposerClient::setOverrideScalingMode(
        const sp<IBinder>& id, int32_t overrideScalingMode) {
    return getComposer().setOverrideScalingMode(
+6 −0
Original line number Diff line number Diff line
@@ -183,6 +183,12 @@ status_t SurfaceControl::reparentChildren(const sp<IBinder>& newParentHandle) {
    return mClient->reparentChildren(mHandle, newParentHandle);
}

status_t SurfaceControl::detachChildren() {
    status_t err = validate();
    if (err < 0) return err;
    return mClient->detachChildren(mHandle);
}

status_t SurfaceControl::setOverrideScalingMode(int32_t overrideScalingMode) {
    status_t err = validate();
    if (err < 0) return err;
Loading