aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/sk_app/android
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-06-13 07:49:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-13 07:49:07 -0700
commit25d57db23445b5602d968fecf015fa8c36246e4a (patch)
tree6627b140a9ef85fa97deb8f916ab074fae8b88ce /tools/viewer/sk_app/android
parentd2ebe49e1f1046b783ad12992992967e6be86a6e (diff)
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
Diffstat (limited to 'tools/viewer/sk_app/android')
-rw-r--r--tools/viewer/sk_app/android/GLWindowContext_android.cpp15
1 files changed, 14 insertions, 1 deletions
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));