summaryrefslogtreecommitdiff
path: root/libs/ui/Gralloc2.cpp
diff options
context:
space:
mode:
author Chris Forbes <chrisforbes@google.com> 2022-01-26 18:48:55 +1300
committer Chris Forbes <chrisforbes@google.com> 2022-01-29 06:56:27 +1300
commit6c09ee7f4ec0c38766f6de2ad922d85a5035f565 (patch)
tree117f8f4f0a8d46800ec5ba86c3e567746d6d94c7 /libs/ui/Gralloc2.cpp
parenta9ff73831c26cb01e5164f3dd19c4c5b6307f9ae (diff)
gralloc: Move validation of non-blob/gpu_data_buffer down to libui
AIDL gralloc implementations may choose to support this combination. Existing implementations of HIDL gralloc 2/3/4 do not support it, and do not reliably reject it due to having been previously protected by validation at the AHardwareBuffer layer. Move the check down to the gralloc layer, and defer to the HAL only in the AIDL case. Bug: b/195944622 Test: build; real CTS/VTS to land soon after. Change-Id: I7b0b9de005a9b0f564915f9c71cc8aea3ef0618a
Diffstat (limited to 'libs/ui/Gralloc2.cpp')
-rw-r--r--libs/ui/Gralloc2.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
index 040a62b542..f23f10a1a9 100644
--- a/libs/ui/Gralloc2.cpp
+++ b/libs/ui/Gralloc2.cpp
@@ -110,6 +110,15 @@ status_t Gralloc2Mapper::validateBufferDescriptorInfo(
descriptorInfo->usage & ~validUsageBits);
return BAD_VALUE;
}
+
+ // Gralloc2 implementations never understand non-BLOB with GPU_DATA_BUFFER
+ // and do not reliably reject it.
+ if (descriptorInfo->usage & BufferUsage::GPU_DATA_BUFFER &&
+ descriptorInfo->format != hardware::graphics::common::V1_1::PixelFormat::BLOB) {
+ ALOGE("gralloc2 does not support non-BLOB pixel formats with GPU_DATA_BUFFER usage");
+ return BAD_VALUE;
+ }
+
return NO_ERROR;
}