aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gpu')
-rw-r--r--tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp69
1 files changed, 33 insertions, 36 deletions
diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
index bf62c64256..03a211d603 100644
--- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
+++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
@@ -72,26 +72,6 @@ private:
EGLSurface fSurface;
};
-static EGLContext create_gles_egl_context(EGLDisplay display,
- EGLConfig surfaceConfig,
- EGLContext eglShareContext,
- EGLint eglContextClientVersion) {
- const EGLint contextAttribsForOpenGLES[] = {
- EGL_CONTEXT_CLIENT_VERSION,
- eglContextClientVersion,
- EGL_NONE
- };
- return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGLES);
-}
-static EGLContext create_gl_egl_context(EGLDisplay display,
- EGLConfig surfaceConfig,
- EGLContext eglShareContext) {
- const EGLint contextAttribsForOpenGL[] = {
- EGL_NONE
- };
- return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGL);
-}
-
EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext* shareContext)
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
@@ -99,19 +79,43 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
EGLContext eglShareContext = shareContext ? shareContext->fContext : nullptr;
- static const GrGLStandard kStandards[] = {
- kGL_GrGLStandard,
- kGLES_GrGLStandard,
+ static const EGLint kEGLContextAttribsForOpenGL[] = {
+ EGL_NONE
};
- size_t apiLimit = SK_ARRAY_COUNT(kStandards);
+ static const EGLint kEGLContextAttribsForOpenGLES[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ static const struct {
+ const EGLint* fContextAttribs;
+ EGLenum fAPI;
+ EGLint fRenderableTypeBit;
+ GrGLStandard fStandard;
+ } kAPIs[] = {
+ { // OpenGL
+ kEGLContextAttribsForOpenGL,
+ EGL_OPENGL_API,
+ EGL_OPENGL_BIT,
+ kGL_GrGLStandard
+ },
+ { // OpenGL ES. This seems to work for both ES2 and 3 (when available).
+ kEGLContextAttribsForOpenGLES,
+ EGL_OPENGL_ES_API,
+ EGL_OPENGL_ES2_BIT,
+ kGLES_GrGLStandard
+ },
+ };
+
+ size_t apiLimit = SK_ARRAY_COUNT(kAPIs);
size_t api = 0;
if (forcedGpuAPI == kGL_GrGLStandard) {
apiLimit = 1;
} else if (forcedGpuAPI == kGLES_GrGLStandard) {
api = 1;
}
- SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kStandards[api] == forcedGpuAPI);
+ SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == forcedGpuAPI);
sk_sp<const GrGLInterface> gl;
@@ -128,16 +132,15 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
#endif
- bool gles = kGLES_GrGLStandard == kStandards[api];
- if (!eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
+ if (!eglBindAPI(kAPIs[api].fAPI)) {
continue;
}
EGLint numConfigs = 0;
const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- EGL_RENDERABLE_TYPE, gles ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
+ EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -156,14 +159,8 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
continue;
}
- if (gles) {
- fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 3);
- if (EGL_NO_CONTEXT == fContext) {
- fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2);
- }
- } else {
- fContext = create_gl_egl_context(fDisplay, surfaceConfig, eglShareContext);
- }
+ fContext = eglCreateContext(fDisplay, surfaceConfig, eglShareContext,
+ kAPIs[api].fContextAttribs);
if (EGL_NO_CONTEXT == fContext) {
SkDebugf("eglCreateContext failed. EGL Error: 0x%08x\n", eglGetError());
continue;