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

Side by Side Diff: src/gpu/gl/android/SkNativeGLContext_android.cpp

Issue 341433007: Revert of Support using OpenGL ES context on desktop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (fSurface) { 44 if (fSurface) {
45 eglDestroySurface(fDisplay, fSurface); 45 eglDestroySurface(fDisplay, fSurface);
46 fSurface = EGL_NO_SURFACE; 46 fSurface = EGL_NO_SURFACE;
47 } 47 }
48 48
49 //TODO should we close the display? 49 //TODO should we close the display?
50 fDisplay = EGL_NO_DISPLAY; 50 fDisplay = EGL_NO_DISPLAY;
51 } 51 }
52 } 52 }
53 53
54 const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAP I) { 54 const GrGLInterface* SkNativeGLContext::createGLContext() {
55 static const EGLint kEGLContextAttribsForOpenGL[] = { 55 static const EGLint kEGLContextAttribsForOpenGL[] = {
56 EGL_NONE 56 EGL_NONE
57 }; 57 };
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 GrGLStandard fStandard; 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 kGL_GrGLStandard 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 kGLES_GrGLStandard 80 kGLES_GrGLStandard
81 }, 81 },
82 }; 82 };
83 83
84 size_t apiLimit = SK_ARRAY_COUNT(kAPIs);
85 size_t api = 0;
86 if (forcedGpuAPI == kGL_GrGLStandard) {
87 apiLimit = 1;
88 } else if (forcedGpuAPI == kGLES_GrGLStandard) {
89 api = 1;
90 }
91 SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == force dGpuAPI);
92
93 const GrGLInterface* interface = NULL; 84 const GrGLInterface* interface = NULL;
94 85
95 for (size_t i = 0; NULL == interface && i < apiLimit; ++api) { 86 for (size_t api = 0; NULL == interface && api < SK_ARRAY_COUNT(kAPIs); ++api ) {
96 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); 87 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
97 88
98 EGLint majorVersion; 89 EGLint majorVersion;
99 EGLint minorVersion; 90 EGLint minorVersion;
100 eglInitialize(fDisplay, &majorVersion, &minorVersion); 91 eglInitialize(fDisplay, &majorVersion, &minorVersion);
101 92
102 #if 0 93 #if 0
103 SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR)); 94 SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR));
104 SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS)); 95 SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS));
105 SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION)); 96 SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { 164 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
174 SkDebugf("Could not set the context.\n"); 165 SkDebugf("Could not set the context.\n");
175 } 166 }
176 } 167 }
177 168
178 void SkNativeGLContext::swapBuffers() const { 169 void SkNativeGLContext::swapBuffers() const {
179 if (!eglSwapBuffers(fDisplay, fSurface)) { 170 if (!eglSwapBuffers(fDisplay, fSurface)) {
180 SkDebugf("Could not complete eglSwapBuffers.\n"); 171 SkDebugf("Could not complete eglSwapBuffers.\n");
181 } 172 }
182 } 173 }
OLDNEW
« no previous file with comments | « src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp ('k') | src/gpu/gl/angle/SkANGLEGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698