| OLD | NEW |
| 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 Loading... |
| 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 // 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 |
| 91 // became hidden behind an extension, but it looks like devices aren't |
| 92 // advertising that extension (including Nexus 5X). So just check version? |
| 93 const EGLint srgbWindowAttribs[] = { |
| 94 /*EGL_GL_COLORSPACE_KHR*/ 0x309D, /*EGL_GL_COLORSPACE_SRGB_KHR*/ 0x3089, |
| 95 EGL_NONE, |
| 96 }; |
| 97 const EGLint* windowAttribs = nullptr; |
| 98 if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 &&
minorVersion >= 2) { |
| 99 windowAttribs = srgbWindowAttribs; |
| 100 } |
| 101 |
| 89 fSurface = eglCreateWindowSurface( | 102 fSurface = eglCreateWindowSurface( |
| 90 fDisplay, surfaceConfig, fNativeWindow, nullptr); | 103 fDisplay, surfaceConfig, fNativeWindow, windowAttribs); |
| 91 SkASSERT(EGL_NO_SURFACE != fSurface); | 104 SkASSERT(EGL_NO_SURFACE != fSurface); |
| 92 | 105 |
| 93 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext)); | 106 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext)); |
| 94 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so
we | 107 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so
we |
| 95 // won't call it here. | 108 // won't call it here. |
| 96 | 109 |
| 97 glClearStencil(0); | 110 glClearStencil(0); |
| 98 glClearColor(0, 0, 0, 0); | 111 glClearColor(0, 0, 0, 0); |
| 99 glStencilMask(0xffffffff); | 112 glStencilMask(0xffffffff); |
| 100 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); | 113 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 119 fSurface = EGL_NO_SURFACE; | 132 fSurface = EGL_NO_SURFACE; |
| 120 } | 133 } |
| 121 | 134 |
| 122 void GLWindowContext_android::onSwapBuffers() { | 135 void GLWindowContext_android::onSwapBuffers() { |
| 123 if (fDisplay && fEGLContext && fSurface) { | 136 if (fDisplay && fEGLContext && fSurface) { |
| 124 eglSwapBuffers(fDisplay, fSurface); | 137 eglSwapBuffers(fDisplay, fSurface); |
| 125 } | 138 } |
| 126 } | 139 } |
| 127 | 140 |
| 128 } | 141 } |
| OLD | NEW |