Index: src/gpu/gl/angle/SkANGLEGLContext.cpp |
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp |
index 2cff750fa041d5b1dcab3c9200c23d0bea6a80ed..9470bf036041bf0b0b5c4ddae935b228ff50065c 100644 |
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp |
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp |
@@ -8,15 +8,50 @@ |
#include "gl/angle/SkANGLEGLContext.h" |
+#define EGL_PLATFORM_ANGLE_ANGLE 0x3201 |
+#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3202 |
+#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3206 |
+#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3207 |
+ |
+EGLDisplay SkANGLEGLContext::GetD3DEGLDisplay(EGLNativeDisplayType nativeDisplay) { |
+ |
+ typedef EGLDisplay (*EGLGetPlatformDisplayEXT)(EGLenum platform, |
+ void *native_display, |
+ const EGLint *attrib_list); |
+ EGLGetPlatformDisplayEXT eglGetPlatformDisplayEXT; |
+ eglGetPlatformDisplayEXT = |
+ (EGLGetPlatformDisplayEXT) eglGetProcAddress("eglGetPlatformDisplayEXT"); |
+ |
+ if (!eglGetPlatformDisplayEXT) { |
+ return eglGetDisplay(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) { |
+ display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
+ nativeDisplay, attribs[i]); |
+ } |
+ return display; |
+} |
+ |
SkANGLEGLContext::SkANGLEGLContext() |
: fContext(EGL_NO_CONTEXT) |
, fDisplay(EGL_NO_DISPLAY) |
, fSurface(EGL_NO_SURFACE) { |
- fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
- |
- EGLint majorVersion; |
- EGLint minorVersion; |
- eglInitialize(fDisplay, &majorVersion, &minorVersion); |
EGLint numConfigs; |
static const EGLint configAttribs[] = { |
@@ -29,6 +64,16 @@ SkANGLEGLContext::SkANGLEGLContext() |
EGL_NONE |
}; |
+ fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY); |
+ if (EGL_NO_DISPLAY == fDisplay) { |
+ SkDebugf("Could not create EGL display!"); |
+ return; |
+ } |
+ |
+ EGLint majorVersion; |
+ EGLint minorVersion; |
+ eglInitialize(fDisplay, &majorVersion, &minorVersion); |
+ |
EGLConfig surfaceConfig; |
eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs); |
@@ -40,10 +85,11 @@ SkANGLEGLContext::SkANGLEGLContext() |
static const EGLint surfaceAttribs[] = { |
- EGL_WIDTH, 1, |
- EGL_HEIGHT, 1, |
- EGL_NONE |
- }; |
+ EGL_WIDTH, 1, |
+ EGL_HEIGHT, 1, |
+ EGL_NONE |
+ }; |
+ |
fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs); |
eglMakeCurrent(fDisplay, fSurface, fSurface, fContext); |