summaryrefslogtreecommitdiff
path: root/libs/nativewindow/AHardwareBuffer.cpp
diff options
context:
space:
mode:
author Valerie Hau <vhau@google.com> 2019-02-07 13:42:43 -0800
committer Valerie Hau <vhau@google.com> 2019-02-07 13:47:26 -0800
commita2414f06bd4330e58c1ea3626c20dace7b1c6b7d (patch)
treef6c680f924bd7135f1ab42b8a839c3750a12ffb6 /libs/nativewindow/AHardwareBuffer.cpp
parente34aa6162e5f3eceefec489b4a048aa5d1e02e45 (diff)
Adding support for Hal query in AHardwareBuffer isSupported
Bug: 120440873 Test: Build, boot, AHardwareBufferGLTest cts test Change-Id: I980f621598214ca514f02fc2d9861dfb3fa3bb12
Diffstat (limited to 'libs/nativewindow/AHardwareBuffer.cpp')
-rw-r--r--libs/nativewindow/AHardwareBuffer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index 6ea127064b..8ef4896d61 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -263,8 +263,17 @@ int AHardwareBuffer_isSupported(const AHardwareBuffer_Desc* desc) {
if (!desc) return 0;
if (!AHardwareBuffer_isValidDescription(desc, /*log=*/false)) return 0;
- // Make a trial allocation.
- // TODO(b/115660272): add implementation that uses a HAL query.
+ bool supported = false;
+ GraphicBuffer* gBuffer = new GraphicBuffer();
+ status_t err = gBuffer->isSupported(desc->width, desc->height, desc->format, desc->layers,
+ desc->usage, &supported);
+
+ if (err == NO_ERROR) {
+ return supported;
+ }
+
+ // function isSupported is not implemented on device or an error occurred during HAL
+ // query. Make a trial allocation.
AHardwareBuffer_Desc trialDesc = *desc;
trialDesc.width = 4;
trialDesc.height = desc->format == AHARDWAREBUFFER_FORMAT_BLOB ? 1 : 4;