1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/gl_wgl_api_implementation.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h"
10 #include "ui/gl/gl_implementation.h"
14 RealWGLApi
* g_real_wgl
;
16 void InitializeStaticGLBindingsWGL() {
17 g_driver_wgl
.InitializeStaticBindings();
19 g_real_wgl
= new RealWGLApi();
21 g_real_wgl
->Initialize(&g_driver_wgl
);
22 g_current_wgl_context
= g_real_wgl
;
23 g_driver_wgl
.InitializeExtensionBindings();
26 void InitializeDebugGLBindingsWGL() {
27 g_driver_wgl
.InitializeDebugBindings();
30 void ClearGLBindingsWGL() {
35 g_current_wgl_context
= NULL
;
36 g_driver_wgl
.ClearBindings();
45 WGLApiBase::WGLApiBase()
49 WGLApiBase::~WGLApiBase() {
52 void WGLApiBase::InitializeBase(DriverWGL
* driver
) {
56 RealWGLApi::RealWGLApi() {
59 RealWGLApi::~RealWGLApi() {
62 void RealWGLApi::Initialize(DriverWGL
* driver
) {
63 InitializeWithCommandLine(driver
, base::CommandLine::ForCurrentProcess());
66 void RealWGLApi::InitializeWithCommandLine(DriverWGL
* driver
,
67 base::CommandLine
* command_line
) {
69 InitializeBase(driver
);
71 const std::string disabled_extensions
= command_line
->GetSwitchValueASCII(
72 switches::kDisableGLExtensions
);
73 disabled_exts_
.clear();
74 filtered_ext_exts_
= "";
75 filtered_arb_exts_
= "";
76 if (!disabled_extensions
.empty()) {
78 base::SplitString(disabled_extensions
, ", ;",
79 base::KEEP_WHITESPACE
,
80 base::SPLIT_WANT_NONEMPTY
);
84 const char* RealWGLApi::wglGetExtensionsStringARBFn(HDC hDC
) {
85 if (filtered_arb_exts_
.size())
86 return filtered_arb_exts_
.c_str();
88 if (!driver_
->fn
.wglGetExtensionsStringARBFn
)
91 const char* str
= WGLApiBase::wglGetExtensionsStringARBFn(hDC
);
95 filtered_arb_exts_
= FilterGLExtensionList(str
, disabled_exts_
);
96 return filtered_arb_exts_
.c_str();
99 const char* RealWGLApi::wglGetExtensionsStringEXTFn() {
100 if (filtered_ext_exts_
.size())
101 return filtered_ext_exts_
.c_str();
103 if (!driver_
->fn
.wglGetExtensionsStringEXTFn
)
106 const char* str
= WGLApiBase::wglGetExtensionsStringEXTFn();
110 filtered_ext_exts_
= FilterGLExtensionList(str
, disabled_exts_
);
111 return filtered_ext_exts_
.c_str();
114 TraceWGLApi::~TraceWGLApi() {
117 bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo
* info
) {
118 const char* extensions
= wglGetExtensionsStringEXT();
119 *info
= GLWindowSystemBindingInfo();
121 info
->extensions
= extensions
;