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

Commit 9030721b authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "[Mirror Layers] Added mirrorSurface API to enable mirroring (3/4)"

parents 4d1b46c6 fe94a225
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ enum class Tag : uint32_t {
    CREATE_WITH_SURFACE_PARENT,
    CLEAR_LAYER_FRAME_STATS,
    GET_LAYER_FRAME_STATS,
    LAST = GET_LAYER_FRAME_STATS,
    MIRROR_SURFACE,
    LAST = MIRROR_SURFACE,
};

} // Anonymous namespace
@@ -80,6 +81,12 @@ public:
                &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GET_LAYER_FRAME_STATS, handle,
                                                              outStats);
    }

    status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle) override {
        return callRemote<decltype(&ISurfaceComposerClient::mirrorSurface)>(Tag::MIRROR_SURFACE,
                                                                            mirrorFromHandle,
                                                                            outHandle);
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -105,6 +112,8 @@ status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data,
            return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
        case Tag::GET_LAYER_FRAME_STATS:
            return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
        case Tag::MIRROR_SURFACE:
            return callLocal(data, reply, &ISurfaceComposerClient::mirrorSurface);
    }
}

+14 −0
Original line number Diff line number Diff line
@@ -1505,6 +1505,20 @@ status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32
    return err;
}

sp<SurfaceControl> SurfaceComposerClient::mirrorSurface(SurfaceControl* mirrorFromSurface) {
    if (mirrorFromSurface == nullptr) {
        return nullptr;
    }

    sp<IBinder> handle;
    sp<IBinder> mirrorFromHandle = mirrorFromSurface->getHandle();
    status_t err = mClient->mirrorSurface(mirrorFromHandle, &handle);
    if (err == NO_ERROR) {
        return new SurfaceControl(this, handle, nullptr, true /* owned */);
    }
    return nullptr;
}

status_t SurfaceComposerClient::clearLayerFrameStats(const sp<IBinder>& token) const {
    if (mStatus != NO_ERROR) {
        return mStatus;
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ public:
     * Requires ACCESS_SURFACE_FLINGER permission
     */
    virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const = 0;

    virtual status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle) = 0;
};

class BnSurfaceComposerClient : public SafeBnInterface<ISurfaceComposerClient> {
+11 −0
Original line number Diff line number Diff line
@@ -245,6 +245,17 @@ public:
                                               LayerMetadata metadata = LayerMetadata() // metadata
    );

    // Creates a mirrored hierarchy for the mirrorFromSurface. This returns a SurfaceControl
    // which is a parent of the root of the mirrored hierarchy.
    //
    //  Real Hierarchy    Mirror
    //                      SC (value that's returned)
    //                      |
    //      A               A'
    //      |               |
    //      B               B'
    sp<SurfaceControl> mirrorSurface(SurfaceControl* mirrorFromSurface);

    //! Create a virtual display
    static sp<IBinder> createDisplay(const String8& displayName, bool secure);

+4 −0
Original line number Diff line number Diff line
@@ -106,6 +106,10 @@ status_t Client::createWithSurfaceParent(const String8& name, uint32_t w, uint32
                                 nullptr, layer);
}

status_t Client::mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle) {
    return mFlinger->mirrorLayer(this, mirrorFromHandle, outHandle);
}

status_t Client::clearLayerFrameStats(const sp<IBinder>& handle) const {
    sp<Layer> layer = getLayerUser(handle);
    if (layer == nullptr) {
Loading