summaryrefslogtreecommitdiff
path: root/libs/ui/Gralloc1On0Adapter.cpp
diff options
context:
space:
mode:
author Chia-I Wu <olv@google.com> 2017-04-11 10:03:38 -0700
committer Chia-I Wu <olv@google.com> 2017-04-11 12:03:32 -0700
commita3c428afbfd8ecfafb7712dafa2cc51aa042a9ba (patch)
tree53970e8f641b8b5dc6dfc5f78f3c3159f1f70357 /libs/ui/Gralloc1On0Adapter.cpp
parentd5de418cf53c50a5a1286bd2c832cbb6a0f52b37 (diff)
libui: support GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE
Honor GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE in GraphicBufferMapper and advertise the cap in the adapter. Bug: 36355756 Test: boots on gralloc0 and gralloc1 devices Change-Id: I54a4855883904255fba9a0821ff9d866d265d25a
Diffstat (limited to 'libs/ui/Gralloc1On0Adapter.cpp')
-rw-r--r--libs/ui/Gralloc1On0Adapter.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/libs/ui/Gralloc1On0Adapter.cpp b/libs/ui/Gralloc1On0Adapter.cpp
index bd7c6a1a46..9ee9838b39 100644
--- a/libs/ui/Gralloc1On0Adapter.cpp
+++ b/libs/ui/Gralloc1On0Adapter.cpp
@@ -20,6 +20,9 @@
#include <ui/Gralloc1On0Adapter.h>
+#include <algorithm>
+#include <array>
+
#include <grallocusage/GrallocUsageConversion.h>
#include <hardware/gralloc.h>
@@ -67,13 +70,18 @@ Gralloc1On0Adapter::~Gralloc1On0Adapter()
void Gralloc1On0Adapter::doGetCapabilities(uint32_t* outCount,
int32_t* outCapabilities)
{
+ constexpr std::array<int32_t, 2> supportedCapabilities = {{
+ GRALLOC1_CAPABILITY_ON_ADAPTER,
+ GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE,
+ }};
+
if (outCapabilities == nullptr) {
- *outCount = 1;
- return;
- }
- if (*outCount >= 1) {
- *outCapabilities = GRALLOC1_CAPABILITY_ON_ADAPTER;
- *outCount = 1;
+ *outCount = supportedCapabilities.size();
+ } else {
+ *outCount = std::min(*outCount, static_cast<uint32_t>(
+ supportedCapabilities.size()));
+ std::copy_n(supportedCapabilities.begin(),
+ *outCount, outCapabilities);
}
}
@@ -325,6 +333,9 @@ gralloc1_error_t Gralloc1On0Adapter::release(
if (result != 0) {
ALOGE("gralloc0 unregister failed: %d", result);
}
+
+ native_handle_close(handle);
+ native_handle_delete(const_cast<native_handle_t*>(handle));
}
mBuffers.erase(handle);