aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/sk_app
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-06-14 08:23:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-14 08:23:48 -0700
commitd76fcda961caa7d71dad45730c5f8e122d8be93f (patch)
tree044e31c6a82a393332b05c5c18232a47e8f920e2 /tools/viewer/sk_app
parent0bbc3713de2f51c17fad935ccfd87dd68c7062ef (diff)
If we fail to create a window surface with sRGB, try again without.
Fixes crash when switching to sRGB mode on Nexus 9, among others. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2066743003 Review-Url: https://codereview.chromium.org/2066743003
Diffstat (limited to 'tools/viewer/sk_app')
-rw-r--r--tools/viewer/sk_app/android/GLWindowContext_android.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
index 5ff641d2e4..79425b4115 100644
--- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
@@ -86,6 +86,10 @@ void GLWindowContext_android::onInitializeContext(void* platformData, const Disp
fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES);
SkASSERT(EGL_NO_CONTEXT != fEGLContext);
+// SkDebugf("EGL: %d.%d", majorVersion, minorVersion);
+// SkDebugf("Vendor: %s", eglQueryString(fDisplay, EGL_VENDOR));
+// SkDebugf("Extensions: %s", eglQueryString(fDisplay, EGL_EXTENSIONS));
+
// 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
@@ -99,8 +103,11 @@ void GLWindowContext_android::onInitializeContext(void* platformData, const Disp
windowAttribs = srgbWindowAttribs;
}
- fSurface = eglCreateWindowSurface(
- fDisplay, surfaceConfig, fNativeWindow, windowAttribs);
+ fSurface = eglCreateWindowSurface(fDisplay, surfaceConfig, fNativeWindow, windowAttribs);
+ if (EGL_NO_SURFACE == fSurface && windowAttribs) {
+ // Try again without sRGB
+ fSurface = eglCreateWindowSurface(fDisplay, surfaceConfig, fNativeWindow, nullptr);
+ }
SkASSERT(EGL_NO_SURFACE != fSurface);
SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext));