OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_gl_api_implementation.h" | 5 #include "ui/gl/gl_gl_api_implementation.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 static void GL_BINDING_CALL CustomRenderbufferStorageMultisampleEXT( | 139 static void GL_BINDING_CALL CustomRenderbufferStorageMultisampleEXT( |
140 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, | 140 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, |
141 GLsizei height) { | 141 GLsizei height) { |
142 GLenum gl_internal_format = GetInternalFormat(internalformat); | 142 GLenum gl_internal_format = GetInternalFormat(internalformat); |
143 return g_driver_gl.orig_fn.glRenderbufferStorageMultisampleEXTFn( | 143 return g_driver_gl.orig_fn.glRenderbufferStorageMultisampleEXTFn( |
144 target, samples, gl_internal_format, width, height); | 144 target, samples, gl_internal_format, width, height); |
145 } | 145 } |
146 | 146 |
147 } // anonymous namespace | 147 } // anonymous namespace |
148 | 148 |
149 void DriverGL::Initialize() { | 149 void DriverGL::InitializeCustomDynamicBindings(GLContext* context) { |
150 InitializeBindings(); | 150 InitializeDynamicBindings(context); |
151 } | |
152 | |
153 void DriverGL::InitializeExtensions(GLContext* context) { | |
154 InitializeExtensionBindings(context); | |
155 orig_fn = fn; | 151 orig_fn = fn; |
156 fn.glTexImage2DFn = | 152 fn.glTexImage2DFn = |
157 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D); | 153 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D); |
158 fn.glTexSubImage2DFn = | 154 fn.glTexSubImage2DFn = |
159 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D); | 155 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D); |
160 fn.glTexStorage2DEXTFn = | 156 fn.glTexStorage2DEXTFn = |
161 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT); | 157 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT); |
162 fn.glRenderbufferStorageEXTFn = | 158 fn.glRenderbufferStorageEXTFn = |
163 reinterpret_cast<glRenderbufferStorageEXTProc>( | 159 reinterpret_cast<glRenderbufferStorageEXTProc>( |
164 CustomRenderbufferStorageEXT); | 160 CustomRenderbufferStorageEXT); |
165 fn.glRenderbufferStorageMultisampleEXTFn = | 161 fn.glRenderbufferStorageMultisampleEXTFn = |
166 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>( | 162 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>( |
167 CustomRenderbufferStorageMultisampleEXT); | 163 CustomRenderbufferStorageMultisampleEXT); |
168 } | 164 } |
169 | 165 |
170 void InitializeGLBindingsGL() { | 166 void InitializeStaticGLBindingsGL() { |
171 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; | 167 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; |
172 g_driver_gl.Initialize(); | 168 g_driver_gl.InitializeStaticBindings(); |
173 if (!g_real_gl) { | 169 if (!g_real_gl) { |
174 g_real_gl = new RealGLApi(); | 170 g_real_gl = new RealGLApi(); |
175 g_trace_gl = new TraceGLApi(g_real_gl); | 171 g_trace_gl = new TraceGLApi(g_real_gl); |
176 } | 172 } |
177 g_real_gl->Initialize(&g_driver_gl); | 173 g_real_gl->Initialize(&g_driver_gl); |
178 g_gl = g_real_gl; | 174 g_gl = g_real_gl; |
179 if (CommandLine::ForCurrentProcess()->HasSwitch( | 175 if (CommandLine::ForCurrentProcess()->HasSwitch( |
180 switches::kEnableGPUServiceTracing)) { | 176 switches::kEnableGPUServiceTracing)) { |
181 g_gl = g_trace_gl; | 177 g_gl = g_trace_gl; |
182 } | 178 } |
183 SetGLToRealGLApi(); | 179 SetGLToRealGLApi(); |
184 } | 180 } |
185 | 181 |
186 GLApi* GetCurrentGLApi() { | 182 GLApi* GetCurrentGLApi() { |
187 return g_current_gl_context_tls->Get(); | 183 return g_current_gl_context_tls->Get(); |
188 } | 184 } |
189 | 185 |
190 void SetGLApi(GLApi* api) { | 186 void SetGLApi(GLApi* api) { |
191 g_current_gl_context_tls->Set(api); | 187 g_current_gl_context_tls->Set(api); |
192 } | 188 } |
193 | 189 |
194 void SetGLToRealGLApi() { | 190 void SetGLToRealGLApi() { |
195 SetGLApi(g_gl); | 191 SetGLApi(g_gl); |
196 } | 192 } |
197 | 193 |
198 void InitializeGLExtensionBindingsGL(GLContext* context) { | 194 void InitializeDynamicGLBindingsGL(GLContext* context) { |
199 g_driver_gl.InitializeExtensions(context); | 195 g_driver_gl.InitializeCustomDynamicBindings(context); |
200 } | 196 } |
201 | 197 |
202 void InitializeDebugGLBindingsGL() { | 198 void InitializeDebugGLBindingsGL() { |
203 g_driver_gl.InitializeDebugBindings(); | 199 g_driver_gl.InitializeDebugBindings(); |
204 } | 200 } |
205 | 201 |
206 void ClearGLBindingsGL() { | 202 void ClearGLBindingsGL() { |
207 if (g_real_gl) { | 203 if (g_real_gl) { |
208 delete g_real_gl; | 204 delete g_real_gl; |
209 g_real_gl = NULL; | 205 g_real_gl = NULL; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 331 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
336 switch (name) { | 332 switch (name) { |
337 case GL_EXTENSIONS: | 333 case GL_EXTENSIONS: |
338 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 334 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
339 default: | 335 default: |
340 return driver_->fn.glGetStringFn(name); | 336 return driver_->fn.glGetStringFn(name); |
341 } | 337 } |
342 } | 338 } |
343 | 339 |
344 } // namespace gfx | 340 } // namespace gfx |
OLD | NEW |