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

Unified Diff: src/gpu/gl/android/SkNativeGLContext_android.cpp

Issue 23702015: Add OpenGL 4.4 support to SkNativeGLContext and GrGLCreateNativeInterface android versions. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: remove prints Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/android/SkNativeGLContext_android.cpp
diff --git a/src/gpu/gl/android/SkNativeGLContext_android.cpp b/src/gpu/gl/android/SkNativeGLContext_android.cpp
index f21eed866610dbacfc03165e96cdfdef18679a7c..9599647e1d0a33c220e9210f6202ffde6d6bdebc 100644
--- a/src/gpu/gl/android/SkNativeGLContext_android.cpp
+++ b/src/gpu/gl/android/SkNativeGLContext_android.cpp
@@ -52,6 +52,30 @@ void SkNativeGLContext::destroyGLContext() {
}
const GrGLInterface* SkNativeGLContext::createGLContext() {
+ static const EGLint kEGLContextAttribsForOpenGL[] = {
+ EGL_NONE
+ };
+
+ static const EGLint kEGLContextAttribsForOpenGLES[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ // Try first for OpenGL, then fall back to OpenGL ES.
+ EGLint renderableTypeBit = EGL_OPENGL_BIT;
+ const EGLint* contextAttribs = kEGLContextAttribsForOpenGL;
+ EGLBoolean apiBound = eglBindAPI(EGL_OPENGL_API);
+
+ if (!apiBound) {
+ apiBound = eglBindAPI(EGL_OPENGL_ES_API);
+ renderableTypeBit = EGL_OPENGL_ES_BIT;
+ contextAttribs = kEGLContextAttribsForOpenGLES;
+ }
+
+ if (!apiBound) {
+ return NULL;
+ }
+
fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint majorVersion;
@@ -59,9 +83,9 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
eglInitialize(fDisplay, &majorVersion, &minorVersion);
EGLint numConfigs;
- static const EGLint configAttribs[] = {
+ const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RENDERABLE_TYPE, renderableTypeBit,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -70,30 +94,43 @@ const GrGLInterface* SkNativeGLContext::createGLContext() {
};
EGLConfig surfaceConfig;
- eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs);
+ if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs)) {
+ SkDebugf("eglChooseConfig failed.\n");
+ return NULL;
+ }
- static const EGLint contextAttribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
fContext = eglCreateContext(fDisplay, surfaceConfig, NULL, contextAttribs);
+ if (EGL_NO_CONTEXT == fContext) {
+ SkDebugf("eglCreateContext failed.\n");
+ return NULL;
+ }
+ static const EGLint kSurfaceAttribs[] = {
+ EGL_WIDTH, 1,
+ EGL_HEIGHT, 1,
+ EGL_NONE
+ };
- static const EGLint surfaceAttribs[] = {
- EGL_WIDTH, 1,
- EGL_HEIGHT, 1,
- EGL_NONE
- };
- fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);
+ fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, kSurfaceAttribs);
+ if (EGL_NO_SURFACE == fSurface) {
+ SkDebugf("eglCreatePbufferSurface failed.\n");
+ this->destroyGLContext();
+ return NULL;
+ }
- eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
+ if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
+ SkDebugf("eglMakeCurrent failed.\n");
+ this->destroyGLContext();
+ return NULL;
+ }
const GrGLInterface* interface = GrGLCreateNativeInterface();
if (!interface) {
- SkDebugf("Failed to create gl interface");
+ SkDebugf("Failed to create gl interface.\n");
this->destroyGLContext();
return NULL;
}
+
return interface;
}
« no previous file with comments | « src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698