Update V8 to version 4.7.47.
[chromium-blink-merge.git] / ui / gl / gl_wgl_api_implementation.cc
blobd3957e3407a4041070a0ab5eb3b8a96039aa0820
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"
12 namespace gfx {
14 RealWGLApi* g_real_wgl;
16 void InitializeStaticGLBindingsWGL() {
17 g_driver_wgl.InitializeStaticBindings();
18 if (!g_real_wgl) {
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() {
31 if (g_real_wgl) {
32 delete g_real_wgl;
33 g_real_wgl = NULL;
35 g_current_wgl_context = NULL;
36 g_driver_wgl.ClearBindings();
39 WGLApi::WGLApi() {
42 WGLApi::~WGLApi() {
45 WGLApiBase::WGLApiBase()
46 : driver_(NULL) {
49 WGLApiBase::~WGLApiBase() {
52 void WGLApiBase::InitializeBase(DriverWGL* driver) {
53 driver_ = 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) {
68 DCHECK(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()) {
77 disabled_exts_ =
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)
89 return NULL;
91 const char* str = WGLApiBase::wglGetExtensionsStringARBFn(hDC);
92 if (!str)
93 return NULL;
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)
104 return NULL;
106 const char* str = WGLApiBase::wglGetExtensionsStringEXTFn();
107 if (!str)
108 return NULL;
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();
120 if (extensions)
121 info->extensions = extensions;
122 return true;
125 } // namespace gfx