EGL: Plumb HDR metadata
HDR metadata comes in bit by bit via eglSurfaceAttribute.
Don't want to call native_window_set_buffers_smpte2086_metadata
for every piece, instead wait until eglSwapBuffers and call
native_window_set_buffers_smpte2086_metadata then.
Does require changing the state of the surface, so some const
goes away.
Bug: 63710530
Test: adb -d shell am start -n \
com.drawelements.deqp/android.app.NativeActivity \
-e cmdLine '"deqp --deqp-case=dEQP-EGL.functional.hdr_metadata.* \
--deqp-log-filename=/sdcard/dEQP-Log.qpa"'
Test: adb shell /data/nativetest/test-opengl-gl2_basic/test-opengl-gl2_basic
Test: adb shell /data/nativetest/test-opengl-gl_basic/test-opengl-gl_basic
Change-Id: I2e428ec18737f6caa8c0e1893705b7796fd77272
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index b68fd61..f879254 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -64,8 +64,17 @@
cnx(cnx),
connected(true),
colorSpace(colorSpace),
- egl_smpte2086_metadata({}),
- egl_cta861_3_metadata({}) {
+ egl_smpte2086_dirty(false),
+ egl_cta861_3_dirty(false) {
+ egl_smpte2086_metadata.displayPrimaryRed = { EGL_DONT_CARE, EGL_DONT_CARE };
+ egl_smpte2086_metadata.displayPrimaryGreen = { EGL_DONT_CARE, EGL_DONT_CARE };
+ egl_smpte2086_metadata.displayPrimaryBlue = { EGL_DONT_CARE, EGL_DONT_CARE };
+ egl_smpte2086_metadata.whitePoint = { EGL_DONT_CARE, EGL_DONT_CARE };
+ egl_smpte2086_metadata.maxLuminance = EGL_DONT_CARE;
+ egl_smpte2086_metadata.minLuminance = EGL_DONT_CARE;
+ egl_cta861_3_metadata.maxFrameAverageLightLevel = EGL_DONT_CARE;
+ egl_cta861_3_metadata.maxContentLightLevel = EGL_DONT_CARE;
+
if (win) {
win->incStrong(this);
}
@@ -92,33 +101,43 @@
switch (attribute) {
case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
egl_smpte2086_metadata.displayPrimaryRed.x = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT:
egl_smpte2086_metadata.displayPrimaryRed.y = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT:
egl_smpte2086_metadata.displayPrimaryGreen.x = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT:
egl_smpte2086_metadata.displayPrimaryGreen.y = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT:
egl_smpte2086_metadata.displayPrimaryBlue.x = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT:
egl_smpte2086_metadata.displayPrimaryBlue.y = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_WHITE_POINT_X_EXT:
egl_smpte2086_metadata.whitePoint.x = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_WHITE_POINT_Y_EXT:
egl_smpte2086_metadata.whitePoint.y = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_MAX_LUMINANCE_EXT:
egl_smpte2086_metadata.maxLuminance = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
case EGL_SMPTE2086_MIN_LUMINANCE_EXT:
egl_smpte2086_metadata.minLuminance = value;
+ egl_smpte2086_dirty = true;
return EGL_TRUE;
}
return EGL_FALSE;
@@ -128,16 +147,32 @@
switch (attribute) {
case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
egl_cta861_3_metadata.maxContentLightLevel = value;
+ egl_cta861_3_dirty = true;
return EGL_TRUE;
case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
egl_cta861_3_metadata.maxFrameAverageLightLevel = value;
+ egl_cta861_3_dirty = true;
return EGL_TRUE;
}
return EGL_FALSE;
}
-const android_smpte2086_metadata egl_surface_t::getSmpte2086Metadata() {
- android_smpte2086_metadata metadata;
+EGLBoolean egl_surface_t::getSmpte2086Metadata(android_smpte2086_metadata& metadata) const {
+ if (!egl_smpte2086_dirty) return EGL_FALSE;
+ if (egl_smpte2086_metadata.displayPrimaryRed.x == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.displayPrimaryRed.y == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.displayPrimaryGreen.x == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.displayPrimaryGreen.y == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.displayPrimaryBlue.x == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.displayPrimaryBlue.y == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.whitePoint.x == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.whitePoint.y == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.maxLuminance == EGL_DONT_CARE ||
+ egl_smpte2086_metadata.minLuminance == EGL_DONT_CARE) {
+ ALOGW("egl_surface_t: incomplete SMPTE 2086 metadata!");
+ return EGL_FALSE;
+ }
+
metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) / EGL_METADATA_SCALING_EXT;
metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) / EGL_METADATA_SCALING_EXT;
metadata.displayPrimaryGreen.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) / EGL_METADATA_SCALING_EXT;
@@ -149,14 +184,22 @@
metadata.maxLuminance = static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT;
metadata.minLuminance = static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT;
- return metadata;
+ return EGL_TRUE;
}
-const android_cta861_3_metadata egl_surface_t::getCta8613Metadata() {
- android_cta861_3_metadata metadata;
+EGLBoolean egl_surface_t::getCta8613Metadata(android_cta861_3_metadata& metadata) const {
+ if (!egl_cta861_3_dirty) return EGL_FALSE;
+
+ if (egl_cta861_3_metadata.maxContentLightLevel == EGL_DONT_CARE ||
+ egl_cta861_3_metadata.maxFrameAverageLightLevel == EGL_DONT_CARE) {
+ ALOGW("egl_surface_t: incomplete CTA861.3 metadata!");
+ return EGL_FALSE;
+ }
+
metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) / EGL_METADATA_SCALING_EXT;
metadata.maxFrameAverageLightLevel = static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) / EGL_METADATA_SCALING_EXT;
- return metadata;
+
+ return EGL_TRUE;
}