From 25d57db23445b5602d968fecf015fa8c36246e4a Mon Sep 17 00:00:00 2001 From: brianosman Date: Mon, 13 Jun 2016 07:49:07 -0700 Subject: Request an sRGB FBO0 on Android. Fixes sRGB GL mode. Tried to comment my logic, but it's totally possible that we run on some device where this doesn't work. From a strict reading of the relevant specs, what I'm doing shouldn't work on the Nexus 5X, but it's necessary to get correct results. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2054223002 Review-Url: https://codereview.chromium.org/2054223002 --- tools/viewer/sk_app/android/GLWindowContext_android.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tools/viewer/sk_app/android') diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp index 0b3363354b..5ff641d2e4 100644 --- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp +++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp @@ -86,8 +86,21 @@ void GLWindowContext_android::onInitializeContext(void* platformData, const Disp fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES); SkASSERT(EGL_NO_CONTEXT != fEGLContext); + // These values are the same as the corresponding VG colorspace attributes, + // which were accepted starting in EGL 1.2. For some reason in 1.4, sRGB + // became hidden behind an extension, but it looks like devices aren't + // advertising that extension (including Nexus 5X). So just check version? + const EGLint srgbWindowAttribs[] = { + /*EGL_GL_COLORSPACE_KHR*/ 0x309D, /*EGL_GL_COLORSPACE_SRGB_KHR*/ 0x3089, + EGL_NONE, + }; + const EGLint* windowAttribs = nullptr; + if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 && minorVersion >= 2) { + windowAttribs = srgbWindowAttribs; + } + fSurface = eglCreateWindowSurface( - fDisplay, surfaceConfig, fNativeWindow, nullptr); + fDisplay, surfaceConfig, fNativeWindow, windowAttribs); SkASSERT(EGL_NO_SURFACE != fSurface); SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext)); -- cgit v1.2.3