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

Side by Side Diff: ui/gl/gl_gl_api_implementation.cc

Issue 135213003: Ensure GL initialization only happens once, and provide common init path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initgl: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 DriverGL::DriverGL() { ClearBindings(); }
150
149 void DriverGL::InitializeCustomDynamicBindings(GLContext* context) { 151 void DriverGL::InitializeCustomDynamicBindings(GLContext* context) {
150 InitializeDynamicBindings(context); 152 InitializeDynamicBindings(context);
151 orig_fn = fn; 153
154 DCHECK(orig_fn.glTexImage2DFn == NULL);
155 orig_fn.glTexImage2DFn = fn.glTexImage2DFn;
152 fn.glTexImage2DFn = 156 fn.glTexImage2DFn =
153 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D); 157 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D);
158
159 DCHECK(orig_fn.glTexSubImage2DFn == NULL);
160 orig_fn.glTexSubImage2DFn = fn.glTexSubImage2DFn;
154 fn.glTexSubImage2DFn = 161 fn.glTexSubImage2DFn =
155 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D); 162 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D);
163
164 DCHECK(orig_fn.glTexStorage2DEXTFn == NULL);
165 orig_fn.glTexStorage2DEXTFn = fn.glTexStorage2DEXTFn;
156 fn.glTexStorage2DEXTFn = 166 fn.glTexStorage2DEXTFn =
157 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT); 167 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT);
168
169 DCHECK(orig_fn.glRenderbufferStorageEXTFn == NULL);
170 orig_fn.glRenderbufferStorageEXTFn = fn.glRenderbufferStorageEXTFn;
158 fn.glRenderbufferStorageEXTFn = 171 fn.glRenderbufferStorageEXTFn =
159 reinterpret_cast<glRenderbufferStorageEXTProc>( 172 reinterpret_cast<glRenderbufferStorageEXTProc>(
160 CustomRenderbufferStorageEXT); 173 CustomRenderbufferStorageEXT);
174
175 DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL);
176 orig_fn.glRenderbufferStorageMultisampleEXTFn =
177 fn.glRenderbufferStorageMultisampleEXTFn;
161 fn.glRenderbufferStorageMultisampleEXTFn = 178 fn.glRenderbufferStorageMultisampleEXTFn =
162 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>( 179 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>(
163 CustomRenderbufferStorageMultisampleEXT); 180 CustomRenderbufferStorageMultisampleEXT);
164 } 181 }
165 182
166 void InitializeStaticGLBindingsGL() { 183 void InitializeStaticGLBindingsGL() {
167 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; 184 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>;
168 g_driver_gl.InitializeStaticBindings(); 185 g_driver_gl.InitializeStaticBindings();
169 if (!g_real_gl) { 186 if (!g_real_gl) {
170 g_real_gl = new RealGLApi(); 187 g_real_gl = new RealGLApi();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 352 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
336 switch (name) { 353 switch (name) {
337 case GL_EXTENSIONS: 354 case GL_EXTENSIONS:
338 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 355 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
339 default: 356 default:
340 return driver_->fn.glGetStringFn(name); 357 return driver_->fn.glGetStringFn(name);
341 } 358 }
342 } 359 }
343 360
344 } // namespace gfx 361 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698