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

Commit a76b271f authored by chaviw's avatar chaviw
Browse files

Add captureLayers function to capture a layer and its children.

The captureLayers function gets a root layer as its argument.
It will capture the content for that layer and its descendants. The
capture will set the root layer's transform back to (0, 0).

Test: Transaction_test ScreenCaptureTest
Change-Id: I84fb66a65cd91434cddc99506b1924cf9f950935
parent cd8ad332
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -122,6 +122,18 @@ public:
        return reply.readInt32();
    }

    virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
                                   const sp<IGraphicBufferProducer>& producer,
                                   ISurfaceComposer::Rotation rotation) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(layerHandleBinder);
        data.writeStrongBinder(IInterface::asBinder(producer));
        data.writeInt32(static_cast<int32_t>(rotation));
        remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
        return reply.readInt32();
    }

    virtual bool authenticateSurfaceTexture(
            const sp<IGraphicBufferProducer>& bufferProducer) const
    {
@@ -588,6 +600,18 @@ status_t BnSurfaceComposer::onTransact(
            reply->writeInt32(res);
            return NO_ERROR;
        }
        case CAPTURE_LAYERS: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> layerHandleBinder = data.readStrongBinder();
            sp<IGraphicBufferProducer> producer =
                    interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
            int32_t rotation = data.readInt32();

            status_t res = captureLayers(layerHandleBinder, producer,
                                         static_cast<ISurfaceComposer::Rotation>(rotation));
            reply->writeInt32(res);
            return NO_ERROR;
        }
        case AUTHENTICATE_SURFACE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IGraphicBufferProducer> bufferProducer =
+9 −0
Original line number Diff line number Diff line
@@ -731,6 +731,15 @@ status_t ScreenshotClient::captureToBuffer(const sp<IBinder>& display,
    return ret;
}

status_t ScreenshotClient::captureLayers(const sp<IBinder>& layerHandle,
                                         const sp<IGraphicBufferProducer>& producer,
                                         uint32_t rotation) {
    sp<ISurfaceComposer> s(ComposerService::getComposerService());
    if (s == NULL) return NO_INIT;
    return s->captureLayers(layerHandle, producer,
                            static_cast<ISurfaceComposer::Rotation>(rotation));
}

ScreenshotClient::ScreenshotClient()
    : mHaveBuffer(false) {
    memset(&mBuffer, 0, sizeof(mBuffer));
+5 −0
Original line number Diff line number Diff line
@@ -174,6 +174,10 @@ public:
            bool useIdentityTransform,
            Rotation rotation = eRotateNone) = 0;

    virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
                                   const sp<IGraphicBufferProducer>& producer,
                                   Rotation rotation = eRotateNone) = 0;

    /* Clears the frame statistics for animations.
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
@@ -226,6 +230,7 @@ public:
        SET_ACTIVE_CONFIG,
        CONNECT_DISPLAY,
        CAPTURE_SCREEN,
        CAPTURE_LAYERS,
        CLEAR_ANIMATION_FRAME_STATS,
        GET_ANIMATION_FRAME_STATS,
        SET_POWER_MODE,
+3 −0
Original line number Diff line number Diff line
@@ -297,6 +297,9 @@ public:
            bool useIdentityTransform,
            uint32_t rotation,
            sp<GraphicBuffer>* outbuffer);
    static status_t captureLayers(const sp<IBinder>& layerHandle,
                                  const sp<IGraphicBufferProducer>& producer, uint32_t rotation);

private:
    mutable sp<CpuConsumer> mCpuConsumer;
    mutable sp<IGraphicBufferProducer> mProducer;
+5 −0
Original line number Diff line number Diff line
@@ -529,6 +529,11 @@ public:
            int32_t /*minLayerZ*/, int32_t /*maxLayerZ*/,
            bool /*useIdentityTransform*/,
            Rotation /*rotation*/) override { return NO_ERROR; }
    virtual status_t captureLayers(const sp<IBinder>& /*parentHandle*/,
                                   const sp<IGraphicBufferProducer>& /*producer*/,
                                   ISurfaceComposer::Rotation /*rotation*/) override {
        return NO_ERROR;
    }
    status_t clearAnimationFrameStats() override { return NO_ERROR; }
    status_t getAnimationFrameStats(FrameStats* /*outStats*/) const override {
        return NO_ERROR;
Loading