diff options
author | bsalomon <bsalomon@google.com> | 2015-02-23 08:57:23 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-23 08:57:23 -0800 |
commit | 42380174ca509e78ab932fa8c6dae953e1eaaa5a (patch) | |
tree | fe233d7e7715e962fe0f8b6da2a85604d2c0ff7d | |
parent | 332c729ceca3db4bde5b6382db5f67ba066ae48a (diff) |
Use D3D11 backend for ANGLE when available.
Review URL: https://codereview.chromium.org/954453002
-rw-r--r-- | gyp/gpu.gypi | 2 | ||||
-rw-r--r-- | gyp/views.gyp | 1 | ||||
-rw-r--r-- | include/gpu/gl/angle/SkANGLEGLContext.h (renamed from src/gpu/gl/angle/SkANGLEGLContext.h) | 2 | ||||
-rw-r--r-- | src/gpu/gl/angle/SkANGLEGLContext.cpp | 64 | ||||
-rw-r--r-- | src/views/win/SkOSWindow_win.cpp | 11 |
5 files changed, 66 insertions, 14 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index fe21d830cf..9803c42019 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -352,8 +352,8 @@ '<(skia_src_path)/gpu/gl/angle/GrGLCreateANGLEInterface.cpp', # Sk files + '<(skia_include_path)/gpu/gl/angle/SkANGLEGLContext.h', '<(skia_src_path)/gpu/gl/angle/SkANGLEGLContext.cpp', - '<(skia_src_path)/gpu/gl/angle/SkANGLEGLContext.h', ], 'skgpu_debug_gl_sources': [ '<(skia_src_path)/gpu/gl/debug/GrGLCreateDebugInterface.cpp', diff --git a/gyp/views.gyp b/gyp/views.gyp index 381e125393..7f53637c12 100644 --- a/gyp/views.gyp +++ b/gyp/views.gyp @@ -18,6 +18,7 @@ 'include_dirs': [ '../include/views', '../include/views/unix', + '../src/gpu', ], 'sources': [ '../include/views/SkApplication.h', diff --git a/src/gpu/gl/angle/SkANGLEGLContext.h b/include/gpu/gl/angle/SkANGLEGLContext.h index 604de42b37..774e0a215d 100644 --- a/src/gpu/gl/angle/SkANGLEGLContext.h +++ b/include/gpu/gl/angle/SkANGLEGLContext.h @@ -33,6 +33,8 @@ public: return ctx; } + static EGLDisplay GetD3DEGLDisplay(EGLNativeDisplayType nativeDisplay); + private: SkANGLEGLContext(); void destroyGLContext(); diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp index 2cff750fa0..9470bf0360 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); diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp index 315ac2b05a..08bbdd3a9e 100644 --- a/src/views/win/SkOSWindow_win.cpp +++ b/src/views/win/SkOSWindow_win.cpp @@ -21,8 +21,8 @@ #include "SkGraphics.h" #if SK_ANGLE +#include "gl/angle/SkANGLEGLContext.h" #include "gl/GrGLInterface.h" - #include "GLES2/gl2.h" #define ANGLE_GL_CALL(IFACE, X) \ @@ -384,6 +384,7 @@ void SkOSWindow::presentGL() { } #if SK_ANGLE + bool create_ANGLE(EGLNativeWindowType hWnd, int msaaSampleCount, EGLDisplay* eglDisplay, @@ -407,9 +408,11 @@ bool create_ANGLE(EGLNativeWindowType hWnd, EGL_NONE, EGL_NONE }; - EGLDisplay display = eglGetDisplay(GetDC(hWnd)); - if (display == EGL_NO_DISPLAY ) { - return false; + EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd)); + + if (EGL_NO_DISPLAY == display) { + SkDebugf("Could not create ANGLE egl display!\n"); + return false; } // Initialize EGL |