Index: src/gpu/gl/angle/SkANGLEGLContext.cpp |
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp |
index 8ebdcb661eacc69587feaa06ae25f919c2ea309b..64a3bdec74381365db58936fe4d43db3a424bc16 100644 |
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp |
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp |
@@ -15,8 +15,9 @@ |
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 |
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 |
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 |
+#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D |
-void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) { |
+void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) { |
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; |
eglGetPlatformDisplayEXT = |
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); |
@@ -25,29 +26,44 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) { |
return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay)); |
} |
- // Try for an ANGLE D3D11 context, fall back to D3D9. |
- EGLint attribs[2][3] = { |
- { |
- EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
- EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, |
- EGL_NONE |
- }, |
- { |
- EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
- EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, |
- EGL_NONE |
- } |
- }; |
- |
EGLDisplay display = EGL_NO_DISPLAY; |
- for (int i = 0; i < 2 && display == EGL_NO_DISPLAY; ++i) { |
+ if (useGLBackend) { |
+ // Try for an ANGLE D3D11 context, fall back to D3D9. |
+ EGLint attribs[3] = { |
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
+ EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, |
+ EGL_NONE |
+ }; |
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
- nativeDisplay, attribs[i]); |
+ nativeDisplay, attribs); |
+ } else { |
+ // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL. |
+ EGLint attribs[3][3] = { |
+ { |
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
+ EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, |
+ EGL_NONE |
+ }, |
+ { |
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
+ EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, |
+ EGL_NONE |
+ }, |
+ { |
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE, |
+ EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, |
+ EGL_NONE |
+ } |
+ }; |
+ for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) { |
+ display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
+ nativeDisplay, attribs[i]); |
+ } |
} |
return display; |
} |
-SkANGLEGLContext::SkANGLEGLContext() |
+SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend) |
: fContext(EGL_NO_CONTEXT) |
, fDisplay(EGL_NO_DISPLAY) |
, fSurface(EGL_NO_SURFACE) { |
@@ -63,7 +79,7 @@ SkANGLEGLContext::SkANGLEGLContext() |
EGL_NONE |
}; |
- fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY); |
+ fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend); |
if (EGL_NO_DISPLAY == fDisplay) { |
SkDebugf("Could not create EGL display!"); |
return; |