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

Commit 0d48072f authored by Robert Carr's avatar Robert Carr
Browse files

Add deferTransaction variant taking GraphicBufferProducer.

For SurfaceView using child layers, the client framework
will not have access to the Handle* for the parent surface,
but still needs a way to defer transactions to it's frames.

Test: Tested with corresponding SurfaceView modifications and existing tests.
Change-Id: I6f01c360e85a95ff0ab08db406741221152e5d5c
parent e7f1979d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -156,6 +156,8 @@ public:
    status_t    setLayerStack(const sp<IBinder>& id, uint32_t layerStack);
    status_t    deferTransactionUntil(const sp<IBinder>& id,
            const sp<IBinder>& handle, uint64_t frameNumber);
    status_t    deferTransactionUntil(const sp<IBinder>& id,
            const sp<Surface>& handle, uint64_t frameNumber);
    status_t    reparentChildren(const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t    setOverrideScalingMode(const sp<IBinder>& id,
+9 −1
Original line number Diff line number Diff line
@@ -80,8 +80,16 @@ public:
    status_t    setGeometryAppliesWithResize();

    // Defers applying any changes made in this transaction until the Layer
    // identified by handle reaches the given frameNumber
    // identified by handle reaches the given frameNumber. If the Layer identified
    // by handle is removed, then we will apply this transaction regardless of
    // what frame number has been reached.
    status_t deferTransactionUntil(const sp<IBinder>& handle, uint64_t frameNumber);

    // A variant of deferTransactionUntil which identifies the Layer we wait for by
    // Surface instead of Handle. Useful for clients which may not have the
    // SurfaceControl for some of their Surfaces. Otherwise behaves identically.
    status_t deferTransactionUntil(const sp<Surface>& barrier, uint64_t frameNumber);

    // Reparents all children of this layer to the new parent handle.
    status_t reparentChildren(const sp<IBinder>& newParentHandle);

+5 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include <ui/Region.h>
#include <ui/Rect.h>
#include <gui/IGraphicBufferProducer.h>

namespace android {

@@ -95,10 +96,13 @@ struct layer_state_t {
            matrix22_t      matrix;
            Rect            crop;
            Rect            finalCrop;
            sp<IBinder>     handle;
            sp<IBinder>     barrierHandle;
            sp<IBinder>     reparentHandle;
            uint64_t        frameNumber;
            int32_t         overrideScalingMode;

            sp<IGraphicBufferProducer> barrierGbp;

            // non POD must be last. see write/read
            Region          transparentRegion;
};
+5 −2
Original line number Diff line number Diff line
@@ -39,10 +39,11 @@ status_t layer_state_t::write(Parcel& output) const
            output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
    output.write(crop);
    output.write(finalCrop);
    output.writeStrongBinder(handle);
    output.writeStrongBinder(barrierHandle);
    output.writeStrongBinder(reparentHandle);
    output.writeUint64(frameNumber);
    output.writeInt32(overrideScalingMode);
    output.writeStrongBinder(IInterface::asBinder(barrierGbp));
    output.write(transparentRegion);
    return NO_ERROR;
}
@@ -68,10 +69,12 @@ status_t layer_state_t::read(const Parcel& input)
    }
    input.read(crop);
    input.read(finalCrop);
    handle = input.readStrongBinder();
    barrierHandle = input.readStrongBinder();
    reparentHandle = input.readStrongBinder();
    frameNumber = input.readUint64();
    overrideScalingMode = input.readInt32();
    barrierGbp =
        interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
    input.read(transparentRegion);
    return NO_ERROR;
}
+24 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceComposerClient.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>

#include <private/gui/ComposerService.h>
@@ -168,6 +169,9 @@ public:
    status_t deferTransactionUntil(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, const sp<IBinder>& handle,
            uint64_t frameNumber);
    status_t deferTransactionUntil(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id, const sp<Surface>& barrierSurface,
            uint64_t frameNumber);
    status_t reparentChildren(const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
@@ -439,7 +443,21 @@ status_t Composer::deferTransactionUntil(
        return BAD_INDEX;
    }
    s->what |= layer_state_t::eDeferTransaction;
    s->handle = handle;
    s->barrierHandle = handle;
    s->frameNumber = frameNumber;
    return NO_ERROR;
}

status_t Composer::deferTransactionUntil(
        const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
        const sp<Surface>& barrierSurface, uint64_t frameNumber) {
    Mutex::Autolock lock(mLock);
    layer_state_t* s = getLayerStateLocked(client, id);
    if (!s) {
        return BAD_INDEX;
    }
    s->what |= layer_state_t::eDeferTransaction;
    s->barrierGbp = barrierSurface->getIGraphicBufferProducer();
    s->frameNumber = frameNumber;
    return NO_ERROR;
}
@@ -777,6 +795,11 @@ status_t SurfaceComposerClient::deferTransactionUntil(const sp<IBinder>& id,
    return getComposer().deferTransactionUntil(this, id, handle, frameNumber);
}

status_t SurfaceComposerClient::deferTransactionUntil(const sp<IBinder>& id,
        const sp<Surface>& barrierSurface, uint64_t frameNumber) {
    return getComposer().deferTransactionUntil(this, id, barrierSurface, frameNumber);
}

status_t SurfaceComposerClient::reparentChildren(const sp<IBinder>& id,
        const sp<IBinder>& newParentHandle) {
    return getComposer().reparentChildren(this, id, newParentHandle);
Loading