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

Unified Diff: ui/gl/gl_context_wgl.cc

Issue 2017623002: Create core profile contexts with WGL when --enable-unsafe-es3-apis is used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « ui/gl/gl_bindings_autogen_wgl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_context_wgl.cc
diff --git a/ui/gl/gl_context_wgl.cc b/ui/gl/gl_context_wgl.cc
index 638623cea6bac82045361261418bc187e20e29aa..135c05f7bc5fed703dd2093d50fbdde3d8515179 100644
--- a/ui/gl/gl_context_wgl.cc
+++ b/ui/gl/gl_context_wgl.cc
@@ -6,6 +6,7 @@
#include "ui/gl/gl_context_wgl.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_bindings.h"
@@ -25,8 +26,42 @@ bool GLContextWGL::Initialize(
// and could potentially be returned by GetHandle.
HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle());
- context_ = wglCreateContext(
- static_cast<HDC>(compatible_surface->GetHandle()));
+ HDC device_context = static_cast<HDC>(compatible_surface->GetHandle());
+ bool has_wgl_create_context_arb =
+ strstr(wglGetExtensionsStringARB(device_context),
+ "WGL_ARB_create_context") != nullptr;
+ bool create_core_profile = has_wgl_create_context_arb &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableUnsafeES3APIs);
+
+ if (create_core_profile) {
+ std::pair<int, int> attempt_versions[] = {
+ {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}, {3, 2},
+ };
+
+ for (const auto& version : attempt_versions) {
+ const int attribs[] = {
+ WGL_CONTEXT_MAJOR_VERSION_ARB,
+ version.first,
+ WGL_CONTEXT_MINOR_VERSION_ARB,
+ version.second,
+ WGL_CONTEXT_PROFILE_MASK_ARB,
+ WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ 0,
+ 0,
+ };
+
+ context_ =
+ wglCreateContextAttribsARB(device_context, share_handle, attribs);
+ if (context_) {
+ break;
+ }
+ }
+ }
+
+ if (!context_) {
+ context_ = wglCreateContext(device_context);
+ }
if (!context_) {
LOG(ERROR) << "Failed to create GL context.";
Destroy();
« no previous file with comments | « ui/gl/gl_bindings_autogen_wgl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698