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

Unified Diff: ui/gl/gl_surface_egl.cc

Issue 435383002: adds WARP support to Chromium, for Metro mode only, on Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 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
Index: ui/gl/gl_surface_egl.cc
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 5a0538e0adda45cc8264c9fc78aea58e4b2e00ee..439401accc0e0e907261f9ea64dc58d3e2af9cc2 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -8,6 +8,7 @@
#include <android/native_window_jni.h>
#endif
+#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -36,6 +37,19 @@ extern "C" {
#define EGL_FIXED_SIZE_ANGLE 0x3201
#endif
+#if defined(OS_WIN)
+// From ANGLE's egl/eglext.h.
+#if !defined(EGL_PLATFORM_ANGLE_ANGLE)
+#define EGL_PLATFORM_ANGLE_ANGLE 0x3201
+#endif
+#if !defined(EGL_PLATFORM_ANGLE_TYPE_ANGLE)
+#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3202
+#endif
+#if !defined(EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE)
+#define EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE 0x3206
+#endif
+#endif // defined(OS_WIN)
+
using ui::GetLastEGLErrorString;
namespace gfx {
@@ -98,7 +112,13 @@ bool GLSurfaceEGL::InitializeOneOff() {
return true;
g_native_display = GetPlatformDefaultEGLNativeDisplay();
+
+#if defined(OS_WIN)
+ g_display = GetPlatformDisplay(g_native_display);
+#else
g_display = eglGetDisplay(g_native_display);
+#endif
+
if (!g_display) {
LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString();
return false;
@@ -228,6 +248,39 @@ bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() {
GLSurfaceEGL::~GLSurfaceEGL() {}
+#if defined(OS_WIN)
+static const EGLint kDisplayAttribsWarp[] {
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE,
+ EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE,
+ EGL_NONE
+};
+
+// static
+EGLDisplay GLSurfaceEGL::GetPlatformDisplay(
+ EGLNativeDisplayType native_display) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseWarp)) {
+ // Check for availability of WARP via ANGLE extension.
+ bool supports_warp = false;
+ const char* no_display_extensions = eglQueryString(EGL_NO_DISPLAY,
+ EGL_EXTENSIONS);
+ // If EGL_EXT_client_extensions not supported this call to eglQueryString
+ // will return NULL.
+ if (no_display_extensions)
+ supports_warp =
+ ExtensionsContain(no_display_extensions, "ANGLE_platform_angle") &&
+ ExtensionsContain(no_display_extensions, "ANGLE_platform_angle_d3d");
+
+ if (!supports_warp)
+ return NULL;
+
+ return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, native_display,
+ kDisplayAttribsWarp);
+ }
+
+ return eglGetDisplay(native_display);
+}
+#endif
+
NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window)
: window_(window),
surface_(NULL),

Powered by Google App Engine
This is Rietveld 408576698