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

Commit 1db73f66 authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceFlinger: Add support for non-privileged clients.

Allow clients without privilege to create child layers through scoped
connections. We enable this in preparation for allowing SurfaceView
to bypass the WindowManager. We include support for reparenting of
all of a layer's children for the WindowManager to use in cases where
one surface is replacing another (while keeping its children around).

Test: Tested with corresponding SurfaceView modifications.
Change-Id: I9920e6730d719113522a68788e63fb59f70d3406
parent bf89eb7b
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -78,6 +78,17 @@ public:
     */
    virtual sp<ISurfaceComposerClient> createConnection() = 0;

    /** create a scoped connection with surface flinger.
     * Surfaces produced with this connection will act
     * as children of the passed in GBP. That is to say
     * SurfaceFlinger will draw them relative and confined to
     * drawing of buffers from the layer associated with parent.
     * As this is graphically equivalent in reach to just drawing
     * pixels into the parent buffers, it requires no special permission.
     */
    virtual sp<ISurfaceComposerClient> createScopedConnection(
            const sp<IGraphicBufferProducer>& parent) = 0;

    /* create a graphic buffer allocator
     */
    virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
@@ -216,7 +227,8 @@ public:
        GET_ACTIVE_COLOR_MODE,
        SET_ACTIVE_COLOR_MODE,
        ENABLE_VSYNC_INJECTIONS,
        INJECT_VSYNC
        INJECT_VSYNC,
        CREATE_SCOPED_CONNECTION
    };

    virtual status_t onTransact(uint32_t code, const Parcel& data,
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class SurfaceComposerClient : public RefBase
    friend class Composer;
public:
                SurfaceComposerClient();
                SurfaceComposerClient(const sp<IGraphicBufferProducer>& parent);
    virtual     ~SurfaceComposerClient();

    // Always make sure we could initialize
@@ -154,6 +155,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    reparentChildren(const sp<IBinder>& id,
            const sp<IBinder>& newParentHandle);
    status_t    setOverrideScalingMode(const sp<IBinder>& id,
            int32_t overrideScalingMode);
    status_t    setGeometryAppliesWithResize(const sp<IBinder>& id);
@@ -201,6 +204,7 @@ private:
                status_t                    mStatus;
                sp<ISurfaceComposerClient>  mClient;
                Composer&                   mComposer;
                wp<IGraphicBufferProducer>  mParent;
};

// ---------------------------------------------------------------------------
+3 −1
Original line number Diff line number Diff line
@@ -82,7 +82,9 @@ public:

    // 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);
    status_t deferTransactionUntil(const sp<IBinder>& handle, uint64_t frameNumber);
    // Reparents all children of this layer to the new parent handle.
    status_t reparentChildren(const sp<IBinder>& newParentHandle);

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

    layer_state_t()
@@ -96,6 +97,7 @@ struct layer_state_t {
            Rect            crop;
            Rect            finalCrop;
            sp<IBinder>     handle;
            sp<IBinder>     reparentHandle;
            uint64_t        frameNumber;
            int32_t         overrideScalingMode;
            uint32_t        type;
+18 −0
Original line number Diff line number Diff line
@@ -64,6 +64,16 @@ public:
        return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
    }

    virtual sp<ISurfaceComposerClient> createScopedConnection(
            const sp<IGraphicBufferProducer>& parent)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(IInterface::asBinder(parent));
        remote()->transact(BnSurfaceComposer::CREATE_SCOPED_CONNECTION, data, &reply);
        return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
    }

    virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
    {
        Parcel data, reply;
@@ -489,6 +499,14 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeStrongBinder(b);
            return NO_ERROR;
        }
        case CREATE_SCOPED_CONNECTION: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IGraphicBufferProducer> bufferProducer =
                interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
            sp<IBinder> b = IInterface::asBinder(createScopedConnection(bufferProducer));
            reply->writeStrongBinder(b);
            return NO_ERROR;
        }
        case CREATE_GRAPHIC_BUFFER_ALLOC: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
Loading