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

Unified Diff: src/gpu/gl/angle/SkANGLEGLContext.cpp

Issue 954453002: Use D3D11 backend for ANGLE when available. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace Created 5 years, 10 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/angle/SkANGLEGLContext.h ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/gpu/gl/angle/SkANGLEGLContext.h ('k') | src/views/win/SkOSWindow_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698