| 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();
|
|
|