OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "gl/SkNativeGLContext.h" | 8 #include "gl/SkNativeGLContext.h" |
9 | 9 |
10 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { | 10 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 static const EGLint kEGLContextAttribsForOpenGLES[] = { | 59 static const EGLint kEGLContextAttribsForOpenGLES[] = { |
60 EGL_CONTEXT_CLIENT_VERSION, 2, | 60 EGL_CONTEXT_CLIENT_VERSION, 2, |
61 EGL_NONE | 61 EGL_NONE |
62 }; | 62 }; |
63 | 63 |
64 static const struct { | 64 static const struct { |
65 const EGLint* fContextAttribs; | 65 const EGLint* fContextAttribs; |
66 EGLenum fAPI; | 66 EGLenum fAPI; |
67 EGLint fRenderableTypeBit; | 67 EGLint fRenderableTypeBit; |
68 GrGLBinding fBinding; | 68 GrGLStandard fStandard; |
69 } kAPIs[] = { | 69 } kAPIs[] = { |
70 { // OpenGL | 70 { // OpenGL |
71 kEGLContextAttribsForOpenGL, | 71 kEGLContextAttribsForOpenGL, |
72 EGL_OPENGL_API, | 72 EGL_OPENGL_API, |
73 EGL_OPENGL_BIT, | 73 EGL_OPENGL_BIT, |
74 kDesktop_GrGLBinding | 74 kGL_GrGLStandard |
75 }, | 75 }, |
76 { // OpenGL ES. This seems to work for both ES2 and 3 (when available)
. | 76 { // OpenGL ES. This seems to work for both ES2 and 3 (when available)
. |
77 kEGLContextAttribsForOpenGLES, | 77 kEGLContextAttribsForOpenGLES, |
78 EGL_OPENGL_ES_API, | 78 EGL_OPENGL_ES_API, |
79 EGL_OPENGL_ES2_BIT, | 79 EGL_OPENGL_ES2_BIT, |
80 kES_GrGLBinding | 80 kGLES_GrGLStandard |
81 }, | 81 }, |
82 }; | 82 }; |
83 | 83 |
84 const GrGLInterface* interface = NULL; | 84 const GrGLInterface* interface = NULL; |
85 | 85 |
86 for (size_t api = 0; NULL == interface && api < SK_ARRAY_COUNT(kAPIs); ++api
) { | 86 for (size_t api = 0; NULL == interface && api < SK_ARRAY_COUNT(kAPIs); ++api
) { |
87 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); | 87 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
88 | 88 |
89 EGLint majorVersion; | 89 EGLint majorVersion; |
90 EGLint minorVersion; | 90 EGLint minorVersion; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 continue; | 143 continue; |
144 } | 144 } |
145 | 145 |
146 interface = GrGLCreateNativeInterface(); | 146 interface = GrGLCreateNativeInterface(); |
147 if (NULL == interface) { | 147 if (NULL == interface) { |
148 SkDebugf("Failed to create gl interface.\n"); | 148 SkDebugf("Failed to create gl interface.\n"); |
149 this->destroyGLContext(); | 149 this->destroyGLContext(); |
150 continue; | 150 continue; |
151 } | 151 } |
152 | 152 |
153 if (!interface->validate(kAPIs[api].fBinding)) { | 153 if (!interface->validate()) { |
154 interface->unref(); | 154 interface->unref(); |
155 interface = NULL; | 155 interface = NULL; |
156 this->destroyGLContext(); | 156 this->destroyGLContext(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 return interface; | 160 return interface; |
161 } | 161 } |
162 | 162 |
163 void SkNativeGLContext::makeCurrent() const { | 163 void SkNativeGLContext::makeCurrent() const { |
164 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { | 164 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { |
165 SkDebugf("Could not set the context.\n"); | 165 SkDebugf("Could not set the context.\n"); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 void SkNativeGLContext::swapBuffers() const { | 169 void SkNativeGLContext::swapBuffers() const { |
170 if (!eglSwapBuffers(fDisplay, fSurface)) { | 170 if (!eglSwapBuffers(fDisplay, fSurface)) { |
171 SkDebugf("Could not complete eglSwapBuffers.\n"); | 171 SkDebugf("Could not complete eglSwapBuffers.\n"); |
172 } | 172 } |
173 } | 173 } |
OLD | NEW |