Add gralloc1 support for layered images.
Bug: 31686534
Test: manual
Change-Id: I1ceaa7834001071fff2b4a43389d6d44079464f0
diff --git a/include/hardware/gralloc1.h b/include/hardware/gralloc1.h
index a1a2d69..f58403c 100644
--- a/include/hardware/gralloc1.h
+++ b/include/hardware/gralloc1.h
@@ -36,7 +36,10 @@
* allocate may be NULL, which instructs the device to report whether the
* given allocation is possible or not. */
GRALLOC1_CAPABILITY_TEST_ALLOCATE = 1,
- GRALLOC1_LAST_CAPABILITY = 1,
+ /* If this capability is supported, then the implementation supports
+ * allocating buffers with more than one image layer. */
+ GRALLOC1_CAPABILITY_LAYERED_BUFFERS = 2,
+ GRALLOC1_LAST_CAPABILITY = 2,
} gralloc1_capability_t;
typedef enum {
@@ -141,7 +144,9 @@
GRALLOC1_FUNCTION_LOCK = 18,
GRALLOC1_FUNCTION_LOCK_FLEX = 19,
GRALLOC1_FUNCTION_UNLOCK = 20,
- GRALLOC1_LAST_FUNCTION = 20,
+ GRALLOC1_FUNCTION_SET_LAYER_COUNT = 21,
+ GRALLOC1_FUNCTION_GET_LAYER_COUNT = 22,
+ GRALLOC1_LAST_FUNCTION = 22,
} gralloc1_function_descriptor_t;
typedef enum {
@@ -440,6 +445,30 @@
gralloc1_device_t* device, gralloc1_buffer_descriptor_t descriptor,
int32_t /*android_pixel_format_t*/ format);
+/* setLayerCount(..., layerCount)
+ * Function descriptor: GRALLOC1_FUNCTION_SET_LAYER_COUNT
+ * Must be provided by all gralloc1 devices that provide the
+ * GRALLOC1_CAPABILITY_LAYERED_BUFFERS capability.
+ *
+ * Sets the number of layers in the buffer.
+ *
+ * A buffer with multiple layers may be used as the backing store of an array
+ * texture. All layers of a buffer share the same characteristics (e.g.,
+ * dimensions, format, usage). Devices that do not support
+ * GRALLOC1_CAPABILITY_LAYERED_BUFFERS must allocate only buffers with a single
+ * layer.
+ *
+ * Parameters:
+ * layerCount - the desired number of layers, must be non-zero
+ *
+ * Returns GRALLOC1_ERROR_NONE or one of the following errors:
+ * GRALLOC1_ERROR_BAD_DESCRIPTOR - the buffer descriptor is invalid
+ * GRALLOC1_ERROR_BAD_VALUE - the layer count is invalid
+ */
+typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_LAYER_COUNT)(
+ gralloc1_device_t* device, gralloc1_buffer_descriptor_t descriptor,
+ uint32_t layerCount);
+
/* setProducerUsage(..., usage)
* Function descriptor: GRALLOC1_FUNCTION_SET_PRODUCER_USAGE
* Must be provided by all gralloc1 devices
@@ -564,6 +593,28 @@
gralloc1_device_t* device, buffer_handle_t descriptor,
int32_t* outFormat);
+/* getLayerCount(..., outLayerCount)
+ * Function descriptor: GRALLOC1_FUNCTION_GET_LAYER_COUNT
+ * Must be provided by all gralloc1 devices that provide the
+ * GRALLOC1_CAPABILITY_LAYERED_BUFFERS capability.
+ *
+ * Gets the number of layers of the buffer.
+ *
+ * See setLayerCount for more information about this value.
+ *
+ * Parameters:
+ * outLayerCount - the number of layers in the image, must be non-NULL
+ *
+ * Returns GRALLOC1_ERROR_NONE or one of the following errors:
+ * GRALLOC1_ERROR_BAD_HANDLE - the buffer handle is invalid
+ * GRALLOC1_ERROR_UNSUPPORTED - the device is unable to retrieve the
+ * layer count from the buffer; see note [1] in this section's header for
+ * more information
+ */
+typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_LAYER_COUNT)(
+ gralloc1_device_t* device, buffer_handle_t buffer,
+ uint32_t* outLayerCount);
+
/* getProducerUsage(..., outUsage)
* Function descriptor: GRALLOC1_FUNCTION_GET_PRODUCER_USAGE
* Must be provided by all gralloc1 devices