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

Commit e52d9e2a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add layered buffer support to libui and libgui."

parents 97a69d01 6ebc46a7
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ public:
    GraphicBufferAlloc();
    virtual ~GraphicBufferAlloc();
    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
            uint32_t height, PixelFormat format, uint32_t usage,
            std::string requestorName, status_t* error) override;
            uint32_t height, PixelFormat format, uint32_t layerCount,
            uint32_t usage, std::string requestorName,
            status_t* error) override;
};


+6 −4
Original line number Diff line number Diff line
@@ -38,12 +38,14 @@ public:
    /* Create a new GraphicBuffer for the client to use.
     */
    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
            PixelFormat format, uint32_t usage, std::string requestorName,
            status_t* error) = 0;
            PixelFormat format, uint32_t layerCount, uint32_t usage,
            std::string requestorName, status_t* error) = 0;

    sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
            PixelFormat format, uint32_t usage, status_t* error) {
        return createGraphicBuffer(w, h, format, usage, "<Unknown>", error);
            PixelFormat format, uint32_t layerCount, uint32_t usage,
            status_t* error) {
        return createGraphicBuffer(w, h, format, layerCount, usage, "<Unknown>",
                error);
    }
};

+7 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public:
        mWidth(0),
        mHeight(0),
        mFormat(static_cast<android_pixel_format_t>(0)),
        mLayerCount(0),
        mProducerUsage(GRALLOC1_PRODUCER_USAGE_NONE),
        mConsumerUsage(GRALLOC1_CONSUMER_USAGE_NONE) {}

@@ -58,6 +59,7 @@ public:

    gralloc1_error_t setDimensions(uint32_t width, uint32_t height);
    gralloc1_error_t setFormat(android_pixel_format_t format);
    gralloc1_error_t setLayerCount(uint32_t layerCount);
    gralloc1_error_t setProducerUsage(gralloc1_producer_usage_t usage);
    gralloc1_error_t setConsumerUsage(gralloc1_consumer_usage_t usage);

@@ -68,6 +70,7 @@ private:
    uint32_t mWidth;
    uint32_t mHeight;
    android_pixel_format_t mFormat;
    uint32_t mLayerCount;
    gralloc1_producer_usage_t mProducerUsage;
    gralloc1_consumer_usage_t mConsumerUsage;

@@ -178,6 +181,8 @@ private:
                GRALLOC1_FUNCTION_SET_DIMENSIONS> setDimensions;
        FunctionLoader<GRALLOC1_PFN_SET_FORMAT,
                GRALLOC1_FUNCTION_SET_FORMAT> setFormat;
        FunctionLoader<GRALLOC1_PFN_SET_LAYER_COUNT,
                GRALLOC1_FUNCTION_SET_LAYER_COUNT> setLayerCount;
        FunctionLoader<GRALLOC1_PFN_SET_PRODUCER_USAGE,
                GRALLOC1_FUNCTION_SET_PRODUCER_USAGE> setProducerUsage;
        FunctionLoader<GRALLOC1_PFN_GET_BACKING_STORE,
@@ -188,6 +193,8 @@ private:
                GRALLOC1_FUNCTION_GET_DIMENSIONS> getDimensions;
        FunctionLoader<GRALLOC1_PFN_GET_FORMAT,
                GRALLOC1_FUNCTION_GET_FORMAT> getFormat;
        FunctionLoader<GRALLOC1_PFN_GET_LAYER_COUNT,
                GRALLOC1_FUNCTION_GET_LAYER_COUNT> getLayerCount;
        FunctionLoader<GRALLOC1_PFN_GET_PRODUCER_USAGE,
                GRALLOC1_FUNCTION_GET_PRODUCER_USAGE> getProducerUsage;
        FunctionLoader<GRALLOC1_PFN_GET_STRIDE,
+18 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ private:
            width(0),
            height(0),
            format(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED),
            layerCount(1),
            producerUsage(GRALLOC1_PRODUCER_USAGE_NONE),
            consumerUsage(GRALLOC1_CONSUMER_USAGE_NONE) {}

@@ -145,6 +146,11 @@ private:
            return GRALLOC1_ERROR_NONE;
        }

        gralloc1_error_t setLayerCount(uint32_t lc) {
            layerCount = lc;
            return GRALLOC1_ERROR_NONE;
        }

        gralloc1_error_t setProducerUsage(gralloc1_producer_usage_t usage) {
            producerUsage = usage;
            return GRALLOC1_ERROR_NONE;
@@ -161,6 +167,7 @@ private:
        uint32_t width;
        uint32_t height;
        int32_t format;
        uint32_t layerCount;
        gralloc1_producer_usage_t producerUsage;
        gralloc1_consumer_usage_t consumerUsage;
    };
@@ -197,6 +204,12 @@ private:
                &Descriptor::setFormat, format);
    }

    static int32_t setLayerCountHook(gralloc1_device_t* device,
            gralloc1_buffer_descriptor_t descriptorId, uint32_t layerCount) {
        return callDescriptorFunction(device, descriptorId,
                &Descriptor::setLayerCount, layerCount);
    }

    static int32_t setProducerUsageHook(gralloc1_device_t* device,
            gralloc1_buffer_descriptor_t descriptorId, uint64_t intUsage) {
        auto usage = static_cast<gralloc1_producer_usage_t>(intUsage);
@@ -246,6 +259,11 @@ private:
            return GRALLOC1_ERROR_NONE;
        }

        gralloc1_error_t getLayerCount(uint32_t* outLayerCount) const {
            *outLayerCount = mDescriptor.layerCount;
            return GRALLOC1_ERROR_NONE;
        }

        gralloc1_error_t getNumFlexPlanes(uint32_t* outNumPlanes) const {
            // TODO: This is conservative, and we could do better by examining
            // the format, but it won't hurt anything for now
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ public:
        return mMapper->getFormat(mDevice, handle, &format);
    }

    Error getLayerCount(buffer_handle_t handle, uint32_t& layerCount) const
    {
        return mMapper->getLayerCount(mDevice, handle, &layerCount);
    }

    Error getProducerUsageMask(buffer_handle_t handle,
            uint64_t& usageMask) const
    {
Loading