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

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

Merge "Add additional parameters for the captureLayer functions."

parents c5de5b39 7206d49b
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -124,12 +124,13 @@ public:

    virtual status_t captureLayers(const sp<IBinder>& layerHandleBinder,
                                   const sp<IGraphicBufferProducer>& producer,
                                   ISurfaceComposer::Rotation rotation) {
                                   const Rect& sourceCrop, float frameScale) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(layerHandleBinder);
        data.writeStrongBinder(IInterface::asBinder(producer));
        data.writeInt32(static_cast<int32_t>(rotation));
        data.write(sourceCrop);
        data.writeFloat(frameScale);
        remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);
        return reply.readInt32();
    }
@@ -605,10 +606,11 @@ status_t BnSurfaceComposer::onTransact(
            sp<IBinder> layerHandleBinder = data.readStrongBinder();
            sp<IGraphicBufferProducer> producer =
                    interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
            int32_t rotation = data.readInt32();
            Rect sourceCrop(Rect::EMPTY_RECT);
            data.read(sourceCrop);
            float frameScale = data.readFloat();

            status_t res = captureLayers(layerHandleBinder, producer,
                                         static_cast<ISurfaceComposer::Rotation>(rotation));
            status_t res = captureLayers(layerHandleBinder, producer, sourceCrop, frameScale);
            reply->writeInt32(res);
            return NO_ERROR;
        }
+26 −3
Original line number Diff line number Diff line
@@ -757,11 +757,34 @@ status_t ScreenshotClient::captureToBuffer(const sp<IBinder>& display,

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

status_t ScreenshotClient::captureLayersToBuffer(const sp<IBinder>& layerHandle, Rect sourceCrop,
                                                 float frameScale, sp<GraphicBuffer>* outBuffer) {
    sp<ISurfaceComposer> s(ComposerService::getComposerService());
    if (s == NULL) return NO_INIT;

    sp<IGraphicBufferConsumer> gbpConsumer;
    sp<IGraphicBufferProducer> producer;
    BufferQueue::createBufferQueue(&producer, &gbpConsumer);
    sp<BufferItemConsumer> consumer(new BufferItemConsumer(gbpConsumer,
                                                           GRALLOC_USAGE_HW_TEXTURE |
                                                                   GRALLOC_USAGE_SW_READ_NEVER |
                                                                   GRALLOC_USAGE_SW_WRITE_NEVER,
                                                           1, true));

    status_t ret = s->captureLayers(layerHandle, producer, sourceCrop, frameScale);
    if (ret != NO_ERROR) {
        return ret;
    }
    BufferItem b;
    consumer->acquireBuffer(&b, 0, true);
    *outBuffer = b.mGraphicBuffer;
    return ret;
}

ScreenshotClient::ScreenshotClient()
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public:

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

    /* Clears the frame statistics for animations.
     *
+5 −1
Original line number Diff line number Diff line
@@ -297,8 +297,12 @@ public:
            bool useIdentityTransform,
            uint32_t rotation,
            sp<GraphicBuffer>* outbuffer);

    static status_t captureLayers(const sp<IBinder>& layerHandle,
                                  const sp<IGraphicBufferProducer>& producer, uint32_t rotation);
                                  const sp<IGraphicBufferProducer>& producer, Rect sourceCrop,
                                        float frameScale);
    static status_t captureLayersToBuffer(const sp<IBinder>& layerHandle, Rect sourceCrop,
                                          float frameScale, sp<GraphicBuffer>* outBuffer);

private:
    mutable sp<CpuConsumer> mCpuConsumer;
+1 −1
Original line number Diff line number Diff line
@@ -531,7 +531,7 @@ public:
            Rotation /*rotation*/) override { return NO_ERROR; }
    virtual status_t captureLayers(const sp<IBinder>& /*parentHandle*/,
                                   const sp<IGraphicBufferProducer>& /*producer*/,
                                   ISurfaceComposer::Rotation /*rotation*/) override {
                                   const Rect& /*sourceCrop*/, float /*frameScale*/) override {
        return NO_ERROR;
    }
    status_t clearAnimationFrameStats() override { return NO_ERROR; }
Loading