Index: src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
index cf9da9365b195a43775305e8f0f98d08d3511eef..727010f6d8354064f2f2a6aac5fca539997d4b97 100644 |
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
+++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
@@ -33,6 +33,7 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); |
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) |
#define EGL_SURFACE_TYPE 0x3033 |
#define EGL_PBUFFER_BIT 0x0001 |
+#define EGL_WINDOW_BIT 0x0004 |
#define EGL_RENDERABLE_TYPE 0x3040 |
#define EGL_RED_SIZE 0x3024 |
#define EGL_GREEN_SIZE 0x3023 |
@@ -52,6 +53,11 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); |
#endif |
+#ifndef EGL_OPENGL_ES3_BIT |
+// Part of EGL 1.5, typical headers are 1.4. |
+#define EGL_OPENGL_ES3_BIT 0x0040 |
+#endif |
+ |
typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id); |
typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *minor); |
typedef EGLBoolean (*TerminateProc)(EGLDisplay dpy); |
@@ -137,14 +143,14 @@ const GrGLInterface* GrGLCreateCommandBufferInterface() { |
return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc); |
} |
-SkCommandBufferGLContext::SkCommandBufferGLContext() |
+SkCommandBufferGLContext::SkCommandBufferGLContext(ContextVersion minContextVersion) |
: fContext(EGL_NO_CONTEXT) |
, fDisplay(EGL_NO_DISPLAY) |
, fSurface(EGL_NO_SURFACE) { |
static const EGLint configAttribs[] = { |
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
+ EGL_RENDERABLE_TYPE, minContextVersion == kGLES3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, |
EGL_RED_SIZE, 8, |
EGL_GREEN_SIZE, 8, |
EGL_BLUE_SIZE, 8, |
@@ -158,13 +164,15 @@ SkCommandBufferGLContext::SkCommandBufferGLContext() |
EGL_NONE |
}; |
- initializeGLContext(nullptr, configAttribs, surfaceAttribs); |
+ initializeGLContext(minContextVersion, nullptr, configAttribs, surfaceAttribs); |
} |
SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount) { |
static const EGLint surfaceAttribs[] = { EGL_NONE }; |
EGLint configAttribs[] = { |
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
EGL_RED_SIZE, 8, |
EGL_GREEN_SIZE, 8, |
EGL_BLUE_SIZE, 8, |
@@ -179,10 +187,11 @@ SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaS |
configAttribs[12] = EGL_NONE; |
} |
- initializeGLContext(nativeWindow, configAttribs, surfaceAttribs); |
+ initializeGLContext(kGLES2, nativeWindow, configAttribs, surfaceAttribs); |
} |
-void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs, |
+void SkCommandBufferGLContext::initializeGLContext(ContextVersion minContextVersion, |
+ void* nativeWindow, const int* configAttribs, |
const int* surfaceAttribs) { |
LoadCommandBufferOnce(); |
if (!gfFunctionsLoadedSuccessfully) { |
@@ -231,7 +240,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int |
} |
static const EGLint contextAttribs[] = { |
- EGL_CONTEXT_CLIENT_VERSION, 2, |
+ EGL_CONTEXT_CLIENT_VERSION, minContextVersion == kGLES3 ? 3 : 2, |
EGL_NONE |
}; |
fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullptr, contextAttribs); |