aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-02-23 08:57:23 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-23 08:57:23 -0800
commit42380174ca509e78ab932fa8c6dae953e1eaaa5a (patch)
treefe233d7e7715e962fe0f8b6da2a85604d2c0ff7d /src/gpu
parent332c729ceca3db4bde5b6382db5f67ba066ae48a (diff)
Use D3D11 backend for ANGLE when available.
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gl/angle/SkANGLEGLContext.cpp64
-rw-r--r--src/gpu/gl/angle/SkANGLEGLContext.h47
2 files changed, 55 insertions, 56 deletions
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/gpu/gl/angle/SkANGLEGLContext.h b/src/gpu/gl/angle/SkANGLEGLContext.h
deleted file mode 100644
index 604de42b37..0000000000
--- a/src/gpu/gl/angle/SkANGLEGLContext.h
+++ /dev/null
@@ -1,47 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkANGLEGLContext_DEFINED
-#define SkANGLEGLContext_DEFINED
-
-#if SK_ANGLE
-
-#include "gl/SkGLContext.h"
-
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
-
-class SkANGLEGLContext : public SkGLContext {
-public:
- ~SkANGLEGLContext() SK_OVERRIDE;
- void makeCurrent() const SK_OVERRIDE;
- void swapBuffers() const SK_OVERRIDE;
-
- static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI) {
- if (kGL_GrGLStandard == forcedGpuAPI) {
- return NULL;
- }
- SkANGLEGLContext* ctx = SkNEW(SkANGLEGLContext);
- if (!ctx->isValid()) {
- SkDELETE(ctx);
- return NULL;
- }
- return ctx;
- }
-
-private:
- SkANGLEGLContext();
- void destroyGLContext();
-
- EGLContext fContext;
- EGLDisplay fDisplay;
- EGLSurface fSurface;
-};
-
-#endif
-
-#endif