EGL: default to HAL_DATASPACE_UNKNOWN.
The refactoring in ag/3926362 accidentally changed the dataspace used
when no colorspace is specified to HAL_DATASPACE_SRGB_LINEAR. Go back
to using HAL_DATASPACE_UNKNOWN in that case.
Bug: 79248854
Bug: 76088973
Test: Ran some dEQP tests on Pixel XL.
Change-Id: Ie723f8a0da71a2938e2af3b340a1660a976a071f
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 3615577..c65bddf 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -475,6 +475,12 @@
return HAL_DATASPACE_UNKNOWN;
}
+// Get the colorspace value that should be reported from queries. When the colorspace
+// is unknown (no attribute passed), default to reporting LINEAR.
+static EGLint getReportedColorSpace(EGLint colorspace) {
+ return colorspace == EGL_UNKNOWN ? EGL_GL_COLORSPACE_LINEAR_KHR : colorspace;
+}
+
// Returns a list of color spaces understood by the vendor EGL driver.
static std::vector<EGLint> getDriverColorSpaces(egl_display_ptr dp,
android_pixel_format format) {
@@ -569,7 +575,8 @@
// supports wide color.
const bool colorSpaceIsNarrow =
*colorSpace == EGL_GL_COLORSPACE_SRGB_KHR ||
- *colorSpace == EGL_GL_COLORSPACE_LINEAR_KHR;
+ *colorSpace == EGL_GL_COLORSPACE_LINEAR_KHR ||
+ *colorSpace == EGL_UNKNOWN;
if (window && !colorSpaceIsNarrow) {
bool windowSupportsWideColor = true;
// Ordinarily we'd put a call to native_window_get_wide_color_support
@@ -718,7 +725,7 @@
getNativePixelFormat(iDpy, cnx, config, &format);
// now select correct colorspace and dataspace based on user's attribute list
- EGLint colorSpace = EGL_GL_COLORSPACE_LINEAR_KHR;
+ EGLint colorSpace = EGL_UNKNOWN;
std::vector<EGLint> strippedAttribList;
if (!processAttributes(dp, window, format, attrib_list, &colorSpace,
&strippedAttribList)) {
@@ -757,7 +764,8 @@
iDpy, config, window, attrib_list);
if (surface != EGL_NO_SURFACE) {
egl_surface_t* s =
- new egl_surface_t(dp.get(), config, window, surface, colorSpace, cnx);
+ new egl_surface_t(dp.get(), config, window, surface,
+ getReportedColorSpace(colorSpace), cnx);
return s;
}
@@ -782,7 +790,7 @@
getNativePixelFormat(iDpy, cnx, config, &format);
// now select a corresponding sRGB format if needed
- EGLint colorSpace = EGL_GL_COLORSPACE_LINEAR_KHR;
+ EGLint colorSpace = EGL_UNKNOWN;
std::vector<EGLint> strippedAttribList;
if (!processAttributes(dp, nullptr, format, attrib_list, &colorSpace,
&strippedAttribList)) {
@@ -794,7 +802,9 @@
EGLSurface surface = cnx->egl.eglCreatePixmapSurface(
dp->disp.dpy, config, pixmap, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, surface, colorSpace, cnx);
+ egl_surface_t* s =
+ new egl_surface_t(dp.get(), config, NULL, surface,
+ getReportedColorSpace(colorSpace), cnx);
return s;
}
}
@@ -814,7 +824,7 @@
getNativePixelFormat(iDpy, cnx, config, &format);
// Select correct colorspace based on user's attribute list
- EGLint colorSpace = EGL_GL_COLORSPACE_LINEAR_KHR;
+ EGLint colorSpace = EGL_UNKNOWN;
std::vector<EGLint> strippedAttribList;
if (!processAttributes(dp, nullptr, format, attrib_list, &colorSpace,
&strippedAttribList)) {
@@ -826,7 +836,9 @@
EGLSurface surface = cnx->egl.eglCreatePbufferSurface(
dp->disp.dpy, config, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dp.get(), config, NULL, surface, colorSpace, cnx);
+ egl_surface_t* s =
+ new egl_surface_t(dp.get(), config, NULL, surface,
+ getReportedColorSpace(colorSpace), cnx);
return s;
}
}