Adds support for more gralloc1 functions to GrallocMapper.
Bug: 34939453
Test: added native CTS tests checked with
cts-tradefed run cts-dev -m CtsNativeHardwareTestCases
Change-Id: I2393f6ec6c7eff5d229a5aa61ff2a52a9366fd1e
diff --git a/include/ui/Gralloc1.h b/include/ui/Gralloc1.h
index 64dacd7..640e29c 100644
--- a/include/ui/Gralloc1.h
+++ b/include/ui/Gralloc1.h
@@ -88,8 +88,6 @@
std::shared_ptr<Descriptor> createDescriptor();
- gralloc1_error_t getStride(buffer_handle_t buffer, uint32_t* outStride);
-
gralloc1_error_t allocate(
const std::vector<std::shared_ptr<const Descriptor>>& descriptors,
std::vector<buffer_handle_t>* outBuffers);
@@ -102,6 +100,19 @@
gralloc1_error_t release(buffer_handle_t buffer);
+ gralloc1_error_t getDimensions(buffer_handle_t buffer,
+ uint32_t* outWidth, uint32_t* outHeight);
+ gralloc1_error_t getFormat(buffer_handle_t buffer,
+ int32_t* outFormat);
+ gralloc1_error_t getLayerCount(buffer_handle_t buffer,
+ uint32_t* outLayerCount);
+ gralloc1_error_t getProducerUsage(buffer_handle_t buffer,
+ uint64_t* outProducerUsage);
+ gralloc1_error_t getConsumerUsage(buffer_handle_t buffer,
+ uint64_t* outConsumerUsage);
+ gralloc1_error_t getBackingStore(buffer_handle_t buffer,
+ uint64_t* outBackingStore);
+ gralloc1_error_t getStride(buffer_handle_t buffer, uint32_t* outStride);
gralloc1_error_t getNumFlexPlanes(buffer_handle_t buffer,
uint32_t* outNumPlanes);
diff --git a/include/ui/Gralloc1On0Adapter.h b/include/ui/Gralloc1On0Adapter.h
index 2508ce9..fcd2245 100644
--- a/include/ui/Gralloc1On0Adapter.h
+++ b/include/ui/Gralloc1On0Adapter.h
@@ -325,7 +325,7 @@
auto usage = GRALLOC1_CONSUMER_USAGE_NONE;
auto error = callBufferFunction(device, bufferHandle,
&Buffer::getConsumerUsage, &usage);
- if (error != GRALLOC1_ERROR_NONE) {
+ if (error == GRALLOC1_ERROR_NONE) {
*outUsage = static_cast<uint64_t>(usage);
}
return error;
@@ -336,7 +336,7 @@
auto usage = GRALLOC1_PRODUCER_USAGE_NONE;
auto error = callBufferFunction(device, bufferHandle,
&Buffer::getProducerUsage, &usage);
- if (error != GRALLOC1_ERROR_NONE) {
+ if (error == GRALLOC1_ERROR_NONE) {
*outUsage = static_cast<uint64_t>(usage);
}
return error;
diff --git a/include/ui/GrallocMapper.h b/include/ui/GrallocMapper.h
index f533dfb..5a23b68 100644
--- a/include/ui/GrallocMapper.h
+++ b/include/ui/GrallocMapper.h
@@ -45,17 +45,23 @@
Error retain(buffer_handle_t handle) const;
void release(buffer_handle_t handle) const;
+ Error getDimensions(buffer_handle_t handle,
+ uint32_t* outWidth, uint32_t* outHeight) const;
+ Error getFormat(buffer_handle_t handle, int32_t* outFormat) const;
+ Error getLayerCount(buffer_handle_t handle, uint32_t* outLayerCount) const;
+ Error getProducerUsage(buffer_handle_t handle,
+ uint64_t* outProducerUsage) const;
+ Error getConsumerUsage(buffer_handle_t handle,
+ uint64_t* outConsumerUsage) const;
+ Error getBackingStore(buffer_handle_t handle,
+ uint64_t* outBackingStore) const;
Error getStride(buffer_handle_t handle, uint32_t* outStride) const;
- Error lock(buffer_handle_t handle,
- uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion,
+ Error lock(buffer_handle_t handle, uint64_t producerUsage,
+ uint64_t consumerUsage, const IMapper::Rect& accessRegion,
int acquireFence, void** outData) const;
- Error lock(buffer_handle_t handle,
- uint64_t producerUsageMask,
- uint64_t consumerUsageMask,
- const IMapper::Rect& accessRegion,
+ Error lock(buffer_handle_t handle, uint64_t producerUsage,
+ uint64_t consumerUsage, const IMapper::Rect& accessRegion,
int acquireFence, FlexLayout* outLayout) const;
int unlock(buffer_handle_t handle) const;
diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h
index acba353..8e93f72 100644
--- a/include/ui/GraphicBufferMapper.h
+++ b/include/ui/GraphicBufferMapper.h
@@ -44,6 +44,25 @@
status_t unregisterBuffer(buffer_handle_t handle);
+ status_t getDimensions(buffer_handle_t handle,
+ uint32_t* outWidth, uint32_t* outHeight) const;
+
+ status_t getFormat(buffer_handle_t handle, int32_t* outFormat) const;
+
+ status_t getLayerCount(buffer_handle_t handle,
+ uint32_t* outLayerCount) const;
+
+ status_t getProducerUsage(buffer_handle_t handle,
+ uint64_t* outProducerUsage) const;
+
+ status_t getConsumerUsage(buffer_handle_t handle,
+ uint64_t* outConsumerUsage) const;
+
+ status_t getBackingStore(buffer_handle_t handle,
+ uint64_t* outBackingStore) const;
+
+ status_t getStride(buffer_handle_t handle, uint32_t* outStride) const;
+
status_t lock(buffer_handle_t handle,
uint32_t usage, const Rect& bounds, void** vaddr);