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

Side by Side Diff: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp

Issue 762113003: Add extra safety check to the EGL context setup. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 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/SkGLContext.h" 8 #include "gl/SkGLContext.h"
9 9
10 #include <GLES2/gl2.h> 10 #include <GLES2/gl2.h>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR)); 80 SkDebugf("VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR));
81 SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS)); 81 SkDebugf("APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS));
82 SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION)); 82 SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
83 SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS)); 83 SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
84 #endif 84 #endif
85 85
86 if (!eglBindAPI(kAPIs[api].fAPI)) { 86 if (!eglBindAPI(kAPIs[api].fAPI)) {
87 continue; 87 continue;
88 } 88 }
89 89
90 EGLint numConfigs; 90 EGLint numConfigs = 0;
91 const EGLint configAttribs[] = { 91 const EGLint configAttribs[] = {
92 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 92 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
93 EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit, 93 EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
94 EGL_RED_SIZE, 8, 94 EGL_RED_SIZE, 8,
95 EGL_GREEN_SIZE, 8, 95 EGL_GREEN_SIZE, 8,
96 EGL_BLUE_SIZE, 8, 96 EGL_BLUE_SIZE, 8,
97 EGL_ALPHA_SIZE, 8, 97 EGL_ALPHA_SIZE, 8,
98 EGL_NONE 98 EGL_NONE
99 }; 99 };
100 100
101 EGLConfig surfaceConfig; 101 EGLConfig surfaceConfig;
102 if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numCon figs)) { 102 if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numCon figs)) {
103 SkDebugf("eglChooseConfig failed. EGL Error: 0x%08x\n", eglGetError( )); 103 SkDebugf("eglChooseConfig failed. EGL Error: 0x%08x\n", eglGetError( ));
104 continue; 104 continue;
105 } 105 }
106 106
107 if (0 == numConfigs) {
108 SkDebugf("No suitable EGL config found.\n");
109 continue;
110 }
111
107 fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, kAPIs[api].fC ontextAttribs); 112 fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, kAPIs[api].fC ontextAttribs);
108 if (EGL_NO_CONTEXT == fContext) { 113 if (EGL_NO_CONTEXT == fContext) {
109 SkDebugf("eglCreateContext failed. EGL Error: 0x%08x\n", eglGetErro r()); 114 SkDebugf("eglCreateContext failed. EGL Error: 0x%08x\n", eglGetErro r());
110 continue; 115 continue;
111 } 116 }
112 117
113 static const EGLint kSurfaceAttribs[] = { 118 static const EGLint kSurfaceAttribs[] = {
114 EGL_WIDTH, 1, 119 EGL_WIDTH, 1,
115 EGL_HEIGHT, 1, 120 EGL_HEIGHT, 1,
116 EGL_NONE 121 EGL_NONE
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 190
186 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { 191 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
187 EGLGLContext* ctx = SkNEW_ARGS(EGLGLContext, (forcedGpuAPI)); 192 EGLGLContext* ctx = SkNEW_ARGS(EGLGLContext, (forcedGpuAPI));
188 if (!ctx->isValid()) { 193 if (!ctx->isValid()) {
189 SkDELETE(ctx); 194 SkDELETE(ctx);
190 return NULL; 195 return NULL;
191 } 196 }
192 return ctx; 197 return ctx;
193 } 198 }
194 199
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