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

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

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 years, 10 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 CustomRenderbufferStorageEXT); 173 CustomRenderbufferStorageEXT);
174 174
175 DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL); 175 DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL);
176 orig_fn.glRenderbufferStorageMultisampleEXTFn = 176 orig_fn.glRenderbufferStorageMultisampleEXTFn =
177 fn.glRenderbufferStorageMultisampleEXTFn; 177 fn.glRenderbufferStorageMultisampleEXTFn;
178 fn.glRenderbufferStorageMultisampleEXTFn = 178 fn.glRenderbufferStorageMultisampleEXTFn =
179 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>( 179 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>(
180 CustomRenderbufferStorageMultisampleEXT); 180 CustomRenderbufferStorageMultisampleEXT);
181 } 181 }
182 182
183 static void GL_BINDING_CALL NullDrawClearFn(GLbitfield mask) {
184 if (!g_driver_gl.null_draw_bindings_enabled)
185 g_driver_gl.orig_fn.glClearFn(mask);
186 }
187
188 static void GL_BINDING_CALL
189 NullDrawDrawArraysFn(GLenum mode, GLint first, GLsizei count) {
190 if (!g_driver_gl.null_draw_bindings_enabled)
191 g_driver_gl.orig_fn.glDrawArraysFn(mode, first, count);
192 }
193
194 static void GL_BINDING_CALL NullDrawDrawElementsFn(GLenum mode,
195 GLsizei count,
196 GLenum type,
197 const void* indices) {
198 if (!g_driver_gl.null_draw_bindings_enabled)
199 g_driver_gl.orig_fn.glDrawElementsFn(mode, count, type, indices);
200 }
201
202 void DriverGL::InitializeNullDrawBindings() {
203 DCHECK(orig_fn.glClearFn == NULL);
204 orig_fn.glClearFn = fn.glClearFn;
205 fn.glClearFn = NullDrawClearFn;
206
207 DCHECK(orig_fn.glDrawArraysFn == NULL);
208 orig_fn.glDrawArraysFn = fn.glDrawArraysFn;
209 fn.glDrawArraysFn = NullDrawDrawArraysFn;
210
211 DCHECK(orig_fn.glDrawElementsFn == NULL);
212 orig_fn.glDrawElementsFn = fn.glDrawElementsFn;
213 fn.glDrawElementsFn = NullDrawDrawElementsFn;
214
215 null_draw_bindings_enabled = true;
216 }
217
218 bool DriverGL::SetNullDrawBindingsEnabled(bool enabled) {
219 DCHECK(orig_fn.glClearFn != NULL);
220 DCHECK(orig_fn.glDrawArraysFn != NULL);
221 DCHECK(orig_fn.glDrawElementsFn != NULL);
222
223 bool before = null_draw_bindings_enabled;
224 null_draw_bindings_enabled = enabled;
225 return before;
226 }
227
183 void InitializeStaticGLBindingsGL() { 228 void InitializeStaticGLBindingsGL() {
184 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; 229 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>;
185 g_driver_gl.InitializeStaticBindings(); 230 g_driver_gl.InitializeStaticBindings();
186 if (!g_real_gl) { 231 if (!g_real_gl) {
187 g_real_gl = new RealGLApi(); 232 g_real_gl = new RealGLApi();
188 g_trace_gl = new TraceGLApi(g_real_gl); 233 g_trace_gl = new TraceGLApi(g_real_gl);
189 } 234 }
190 g_real_gl->Initialize(&g_driver_gl); 235 g_real_gl->Initialize(&g_driver_gl);
191 g_gl = g_real_gl; 236 g_gl = g_real_gl;
192 if (CommandLine::ForCurrentProcess()->HasSwitch( 237 if (CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 20 matching lines...) Expand all
213 } 258 }
214 259
215 void InitializeDebugGLBindingsGL() { 260 void InitializeDebugGLBindingsGL() {
216 g_driver_gl.InitializeDebugBindings(); 261 g_driver_gl.InitializeDebugBindings();
217 } 262 }
218 263
219 void InitializeNullDrawGLBindingsGL() { 264 void InitializeNullDrawGLBindingsGL() {
220 g_driver_gl.InitializeNullDrawBindings(); 265 g_driver_gl.InitializeNullDrawBindings();
221 } 266 }
222 267
268 bool SetNullDrawGLBindingsEnabledGL(bool enabled) {
269 return g_driver_gl.SetNullDrawBindingsEnabled(enabled);
270 }
271
223 void ClearGLBindingsGL() { 272 void ClearGLBindingsGL() {
224 if (g_real_gl) { 273 if (g_real_gl) {
225 delete g_real_gl; 274 delete g_real_gl;
226 g_real_gl = NULL; 275 g_real_gl = NULL;
227 } 276 }
228 if (g_trace_gl) { 277 if (g_trace_gl) {
229 delete g_trace_gl; 278 delete g_trace_gl;
230 g_trace_gl = NULL; 279 g_trace_gl = NULL;
231 } 280 }
232 g_gl = NULL; 281 g_gl = NULL;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 401 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
353 switch (name) { 402 switch (name) {
354 case GL_EXTENSIONS: 403 case GL_EXTENSIONS:
355 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 404 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
356 default: 405 default:
357 return driver_->fn.glGetStringFn(name); 406 return driver_->fn.glGetStringFn(name);
358 } 407 }
359 } 408 }
360 409
361 } // namespace gfx 410 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698