Revert "Remove incorrect isDataSpaceValid"
This reverts commit e4f832e21dbad52f7b455d557584d8baad66dd6f.
Reason for revert:
DroidMonitor: Potential culprit for Bug b/277122111 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.”
Change-Id: I0fc4f98eb83448562c57433aa68018bcfee746bf
diff --git a/libs/nativewindow/ANativeWindow.cpp b/libs/nativewindow/ANativeWindow.cpp
index dd5958d..5306529 100644
--- a/libs/nativewindow/ANativeWindow.cpp
+++ b/libs/nativewindow/ANativeWindow.cpp
@@ -79,6 +79,27 @@
return res < 0 ? res : value;
}
+static bool isDataSpaceValid(ANativeWindow* window, int32_t dataSpace) {
+ bool supported = false;
+ switch (dataSpace) {
+ case HAL_DATASPACE_UNKNOWN:
+ case HAL_DATASPACE_V0_SRGB:
+ return true;
+ // These data space need wide gamut support.
+ case HAL_DATASPACE_V0_SCRGB_LINEAR:
+ case HAL_DATASPACE_V0_SCRGB:
+ case HAL_DATASPACE_DISPLAY_P3:
+ native_window_get_wide_color_support(window, &supported);
+ return supported;
+ // These data space need HDR support.
+ case HAL_DATASPACE_BT2020_PQ:
+ native_window_get_hdr_support(window, &supported);
+ return supported;
+ default:
+ return false;
+ }
+}
+
/**************************************************************************************************
* NDK
**************************************************************************************************/
@@ -198,7 +219,8 @@
static_assert(static_cast<int>(ADATASPACE_DEPTH) == static_cast<int>(HAL_DATASPACE_DEPTH));
static_assert(static_cast<int>(ADATASPACE_DYNAMIC_DEPTH) == static_cast<int>(HAL_DATASPACE_DYNAMIC_DEPTH));
- if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
+ if (!window || !query(window, NATIVE_WINDOW_IS_VALID) ||
+ !isDataSpaceValid(window, dataSpace)) {
return -EINVAL;
}
return native_window_set_buffers_data_space(window,