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

Commit f1961f71 authored by chaviw's avatar chaviw
Browse files

Re-parent invoked on child instead of on parent.

The function to re-parent an individual child is now invoked on
the child instead of the parent. This ensures the child ends up with
the last parent set if multiple reparent requests are made in the same
transaction.
This also allows adding a parent to a layer that didn't have one
previously.

Test: Transaction_test -> Reparent, ReparentToNoParent,
ReparentFromNoParent

Change-Id: Idab429eb2dca5a4ae1b020a5a7629d719dd4d995
parent 931dc01a
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ status_t layer_state_t::write(Parcel& output) const
    output.writeStrongBinder(IInterface::asBinder(barrierGbp));
    output.writeStrongBinder(relativeLayerHandle);
    output.writeStrongBinder(parentHandleForChild);
    output.writeStrongBinder(childHandle);
    output.write(transparentRegion);
    return NO_ERROR;
}
@@ -80,7 +79,6 @@ status_t layer_state_t::read(const Parcel& input)
        interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
    relativeLayerHandle = input.readStrongBinder();
    parentHandleForChild = input.readStrongBinder();
    childHandle = input.readStrongBinder();
    input.read(transparentRegion);
    return NO_ERROR;
}
+8 −11
Original line number Diff line number Diff line
@@ -176,9 +176,8 @@ public:
    status_t reparentChildren(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t reparentChild(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, const sp<IBinder>& newParentHandle,
            const sp<IBinder>& childHandle);
    status_t reparent(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,
@@ -496,18 +495,16 @@ status_t Composer::reparentChildren(
    return NO_ERROR;
}

status_t Composer::reparentChild(const sp<SurfaceComposerClient>& client,
status_t Composer::reparent(const sp<SurfaceComposerClient>& client,
        const sp<IBinder>& id,
        const sp<IBinder>& newParentHandle,
        const sp<IBinder>& childHandle) {
        const sp<IBinder>& newParentHandle) {
    Mutex::Autolock lock(mLock);
    layer_state_t* s = getLayerStateLocked(client, id);
    if (!s) {
        return BAD_INDEX;
    }
    s->what |= layer_state_t::eReparentChild;
    s->what |= layer_state_t::eReparent;
    s->parentHandleForChild = newParentHandle;
    s->childHandle = childHandle;
    return NO_ERROR;
}

@@ -849,9 +846,9 @@ status_t SurfaceComposerClient::reparentChildren(const sp<IBinder>& id,
    return getComposer().reparentChildren(this, id, newParentHandle);
}

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

status_t SurfaceComposerClient::detachChildren(const sp<IBinder>& id) {
+2 −3
Original line number Diff line number Diff line
@@ -191,11 +191,10 @@ status_t SurfaceControl::reparentChildren(const sp<IBinder>& newParentHandle) {
    return mClient->reparentChildren(mHandle, newParentHandle);
}

status_t SurfaceControl::reparentChild(const sp<IBinder>& newParentHandle,
        const sp<IBinder>& childHandle) {
status_t SurfaceControl::reparent(const sp<IBinder>& newParentHandle) {
    status_t err = validate();
    if (err < 0) return err;
    return mClient->reparentChild(mHandle, newParentHandle, childHandle);
    return mClient->reparent(mHandle, newParentHandle);
}

status_t SurfaceControl::detachChildren() {
+1 −2
Original line number Diff line number Diff line
@@ -161,8 +161,7 @@ public:
            const sp<Surface>& handle, uint64_t frameNumber);
    status_t    reparentChildren(const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t    reparentChild(const sp<IBinder>& id, const sp<IBinder>& newParentHandle,
            const sp<IBinder>& childHandle);
    status_t    reparent(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);
+3 −4
Original line number Diff line number Diff line
@@ -124,11 +124,10 @@ public:
    // Reparents all children of this layer to the new parent handle.
    status_t reparentChildren(const sp<IBinder>& newParentHandle);

    // Reparents a specified child from this layer to the new parent handle.
    // The child, parent, and new parent must all have the same client.
    // Reparents the current layer to the new parent handle. The new parent must not be null.
    // This can be used instead of reparentChildren if the caller wants to
    // only re-parent specific children.
    status_t reparentChild(const sp<IBinder>& newParentHandle, const sp<IBinder>& childHandle);
    // only re-parent a specific child.
    status_t reparent(const sp<IBinder>& newParentHandle);

    // Detaches all child surfaces (and their children recursively)
    // from their SurfaceControl.
Loading