Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: tools/viewer/sk_app/android/GLWindowContext_android.cpp

Issue 2066743003: If we fail to create a window surface with sRGB, try again without. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include <GLES/gl.h> 9 #include <GLES/gl.h>
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 SkASSERT(numConfigs > 0); 79 SkASSERT(numConfigs > 0);
80 80
81 static const EGLint kEGLContextAttribsForOpenGLES[] = { 81 static const EGLint kEGLContextAttribsForOpenGLES[] = {
82 EGL_CONTEXT_CLIENT_VERSION, 2, 82 EGL_CONTEXT_CLIENT_VERSION, 2,
83 EGL_NONE 83 EGL_NONE
84 }; 84 };
85 fEGLContext = eglCreateContext( 85 fEGLContext = eglCreateContext(
86 fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES); 86 fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES);
87 SkASSERT(EGL_NO_CONTEXT != fEGLContext); 87 SkASSERT(EGL_NO_CONTEXT != fEGLContext);
88 88
89 // SkDebugf("EGL: %d.%d", majorVersion, minorVersion);
90 // SkDebugf("Vendor: %s", eglQueryString(fDisplay, EGL_VENDOR));
91 // SkDebugf("Extensions: %s", eglQueryString(fDisplay, EGL_EXTENSIONS));
92
89 // These values are the same as the corresponding VG colorspace attributes, 93 // These values are the same as the corresponding VG colorspace attributes,
90 // which were accepted starting in EGL 1.2. For some reason in 1.4, sRGB 94 // which were accepted starting in EGL 1.2. For some reason in 1.4, sRGB
91 // became hidden behind an extension, but it looks like devices aren't 95 // became hidden behind an extension, but it looks like devices aren't
92 // advertising that extension (including Nexus 5X). So just check version? 96 // advertising that extension (including Nexus 5X). So just check version?
93 const EGLint srgbWindowAttribs[] = { 97 const EGLint srgbWindowAttribs[] = {
94 /*EGL_GL_COLORSPACE_KHR*/ 0x309D, /*EGL_GL_COLORSPACE_SRGB_KHR*/ 0x3089, 98 /*EGL_GL_COLORSPACE_KHR*/ 0x309D, /*EGL_GL_COLORSPACE_SRGB_KHR*/ 0x3089,
95 EGL_NONE, 99 EGL_NONE,
96 }; 100 };
97 const EGLint* windowAttribs = nullptr; 101 const EGLint* windowAttribs = nullptr;
98 if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 && minorVersion >= 2) { 102 if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 && minorVersion >= 2) {
99 windowAttribs = srgbWindowAttribs; 103 windowAttribs = srgbWindowAttribs;
100 } 104 }
101 105
102 fSurface = eglCreateWindowSurface( 106 fSurface = eglCreateWindowSurface(fDisplay, surfaceConfig, fNativeWindow, wi ndowAttribs);
103 fDisplay, surfaceConfig, fNativeWindow, windowAttribs); 107 if (EGL_NO_SURFACE == fSurface && windowAttribs) {
108 // Try again without sRGB
109 fSurface = eglCreateWindowSurface(fDisplay, surfaceConfig, fNativeWindow , nullptr);
110 }
104 SkASSERT(EGL_NO_SURFACE != fSurface); 111 SkASSERT(EGL_NO_SURFACE != fSurface);
105 112
106 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext)); 113 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext));
107 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so we 114 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so we
108 // won't call it here. 115 // won't call it here.
109 116
110 glClearStencil(0); 117 glClearStencil(0);
111 glClearColor(0, 0, 0, 0); 118 glClearColor(0, 0, 0, 0);
112 glStencilMask(0xffffffff); 119 glStencilMask(0xffffffff);
113 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 120 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
(...skipping 18 matching lines...) Expand all
132 fSurface = EGL_NO_SURFACE; 139 fSurface = EGL_NO_SURFACE;
133 } 140 }
134 141
135 void GLWindowContext_android::onSwapBuffers() { 142 void GLWindowContext_android::onSwapBuffers() {
136 if (fDisplay && fEGLContext && fSurface) { 143 if (fDisplay && fEGLContext && fSurface) {
137 eglSwapBuffers(fDisplay, fSurface); 144 eglSwapBuffers(fDisplay, fSurface);
138 } 145 }
139 } 146 }
140 147
141 } 148 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698