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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 292 } |
293 | 293 |
294 void InitializeStaticGLBindingsGL() { | 294 void InitializeStaticGLBindingsGL() { |
295 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; | 295 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; |
296 g_driver_gl.InitializeStaticBindings(); | 296 g_driver_gl.InitializeStaticBindings(); |
297 if (!g_real_gl) { | 297 if (!g_real_gl) { |
298 g_real_gl = new RealGLApi(); | 298 g_real_gl = new RealGLApi(); |
299 g_trace_gl = new TraceGLApi(g_real_gl); | 299 g_trace_gl = new TraceGLApi(g_real_gl); |
300 g_no_context_gl = new NoContextGLApi(); | 300 g_no_context_gl = new NoContextGLApi(); |
301 } | 301 } |
302 g_real_gl->Initialize(&g_driver_gl); | 302 g_real_gl->Initialize(&g_driver_gl, nullptr); |
303 g_gl = g_real_gl; | 303 g_gl = g_real_gl; |
304 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 304 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
305 switches::kEnableGPUServiceTracing)) { | 305 switches::kEnableGPUServiceTracing)) { |
306 g_gl = g_trace_gl; | 306 g_gl = g_trace_gl; |
307 } | 307 } |
308 SetGLToRealGLApi(); | 308 SetGLToRealGLApi(); |
309 } | 309 } |
310 | 310 |
311 GLApi* GetCurrentGLApi() { | 311 GLApi* GetCurrentGLApi() { |
312 return g_current_gl_context_tls->Get(); | 312 return g_current_gl_context_tls->Get(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 if (g_version_info) { | 375 if (g_version_info) { |
376 delete g_version_info; | 376 delete g_version_info; |
377 g_version_info = NULL; | 377 g_version_info = NULL; |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 GLApi::GLApi() { | 381 GLApi::GLApi() { |
382 } | 382 } |
383 | 383 |
384 GLApi::~GLApi() { | 384 GLApi::~GLApi() { |
385 if (GetCurrentGLApi() == this) | 385 if (g_current_gl_context_tls /* for testing */ && GetCurrentGLApi() == this) |
386 SetGLApi(NULL); | 386 SetGLApi(NULL); |
387 } | 387 } |
388 | 388 |
389 GLApiBase::GLApiBase() | 389 GLApiBase::GLApiBase() |
390 : driver_(NULL) { | 390 : driver_(NULL) { |
391 } | 391 } |
392 | 392 |
393 GLApiBase::~GLApiBase() { | 393 GLApiBase::~GLApiBase() { |
394 } | 394 } |
395 | 395 |
396 void GLApiBase::InitializeBase(DriverGL* driver) { | 396 void GLApiBase::InitializeBase(DriverGL* driver) { |
397 driver_ = driver; | 397 driver_ = driver; |
398 } | 398 } |
399 | 399 |
400 RealGLApi::RealGLApi() { | 400 RealGLApi::RealGLApi() { |
401 } | 401 } |
402 | 402 |
403 RealGLApi::~RealGLApi() { | 403 RealGLApi::~RealGLApi() { |
404 } | 404 } |
405 | 405 |
406 void RealGLApi::Initialize(DriverGL* driver) { | 406 void RealGLApi::Initialize(DriverGL* driver, base::CommandLine* command_line) { |
407 InitializeBase(driver); | 407 InitializeBase(driver); |
408 } | 408 } |
409 | 409 |
410 void RealGLApi::glFlushFn() { | 410 void RealGLApi::glFlushFn() { |
411 GLApiBase::glFlushFn(); | 411 GLApiBase::glFlushFn(); |
412 } | 412 } |
413 | 413 |
414 void RealGLApi::glFinishFn() { | 414 void RealGLApi::glFinishFn() { |
415 GLApiBase::glFinishFn(); | 415 GLApiBase::glFinishFn(); |
416 } | 416 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() | 532 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() |
533 : old_gl_api_(GetCurrentGLApi()) { | 533 : old_gl_api_(GetCurrentGLApi()) { |
534 SetGLToRealGLApi(); | 534 SetGLToRealGLApi(); |
535 } | 535 } |
536 | 536 |
537 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { | 537 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { |
538 SetGLApi(old_gl_api_); | 538 SetGLApi(old_gl_api_); |
539 } | 539 } |
540 | 540 |
541 } // namespace gfx | 541 } // namespace gfx |
OLD | NEW |