libui: remove gralloc0/gralloc1 support
We now talk to HIDL gralloc exclusively.
Bug: 37433368
Test: boots
Change-Id: Iecd2f9a02c7066b2f33f24c1de57e9c4af8e28f5
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index eb5c7b6..b0cb012 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -188,18 +188,6 @@
uint64_t producerUsage, uint64_t consumerUsage,
uint32_t stride)
{
- native_handle_t* clone = nullptr;
-
- if (method == CLONE_HANDLE) {
- clone = native_handle_clone(handle);
- if (!clone) {
- return NO_MEMORY;
- }
-
- handle = clone;
- method = TAKE_UNREGISTERED_HANDLE;
- }
-
ANativeWindowBuffer::width = static_cast<int>(width);
ANativeWindowBuffer::height = static_cast<int>(height);
ANativeWindowBuffer::stride = static_cast<int>(stride);
@@ -208,25 +196,28 @@
android_convertGralloc1To0Usage(producerUsage, consumerUsage);
ANativeWindowBuffer::layerCount = layerCount;
- ANativeWindowBuffer::handle = handle;
mOwner = (method == WRAP_HANDLE) ? ownNone : ownHandle;
- if (method == TAKE_UNREGISTERED_HANDLE) {
- status_t err = mBufferMapper.importBuffer(this);
+ if (method == TAKE_UNREGISTERED_HANDLE || method == CLONE_HANDLE) {
+ buffer_handle_t importedHandle;
+ status_t err = mBufferMapper.importBuffer(handle, &importedHandle);
if (err != NO_ERROR) {
- // clean up cloned handle
- if (clone) {
- native_handle_close(clone);
- native_handle_delete(clone);
- }
-
initWithHandle(nullptr, WRAP_HANDLE, 0, 0, 0, 0, 0, 0, 0);
return err;
}
+
+ if (method == TAKE_UNREGISTERED_HANDLE) {
+ native_handle_close(handle);
+ native_handle_delete(const_cast<native_handle_t*>(handle));
+ }
+
+ handle = importedHandle;
}
+ ANativeWindowBuffer::handle = handle;
+
return NO_ERROR;
}
@@ -447,7 +438,8 @@
mOwner = ownHandle;
if (handle != 0) {
- status_t err = mBufferMapper.importBuffer(this);
+ buffer_handle_t importedHandle;
+ status_t err = mBufferMapper.importBuffer(handle, &importedHandle);
if (err != NO_ERROR) {
width = height = stride = format = layerCount = usage = 0;
handle = NULL;
@@ -455,6 +447,10 @@
strerror(-err), err);
return err;
}
+
+ native_handle_close(handle);
+ native_handle_delete(const_cast<native_handle_t*>(handle));
+ handle = importedHandle;
}
buffer = static_cast<void const*>(static_cast<uint8_t const*>(buffer) + sizeNeeded);