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" |
| 11 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "ui/gl/gl_context.h" | 13 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
14 #include "ui/gl/gl_state_restorer.h" | 15 #include "ui/gl/gl_state_restorer.h" |
15 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
16 #include "ui/gl/gl_switches.h" | 17 #include "ui/gl/gl_switches.h" |
17 #include "ui/gl/gl_version_info.h" | 18 #include "ui/gl/gl_version_info.h" |
18 | 19 |
19 namespace gfx { | 20 namespace gfx { |
20 | 21 |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 VirtualGLApi::~VirtualGLApi() { | 431 VirtualGLApi::~VirtualGLApi() { |
431 } | 432 } |
432 | 433 |
433 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { | 434 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { |
434 InitializeBase(driver); | 435 InitializeBase(driver); |
435 real_context_ = real_context; | 436 real_context_ = real_context; |
436 | 437 |
437 DCHECK(real_context->IsCurrent(NULL)); | 438 DCHECK(real_context->IsCurrent(NULL)); |
438 std::string ext_string( | 439 std::string ext_string( |
439 reinterpret_cast<const char*>(driver_->fn.glGetStringFn(GL_EXTENSIONS))); | 440 reinterpret_cast<const char*>(driver_->fn.glGetStringFn(GL_EXTENSIONS))); |
440 std::vector<std::string> ext; | 441 std::vector<std::string> ext = base::SplitString( |
441 Tokenize(ext_string, " ", &ext); | 442 ext_string, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
442 | 443 |
443 std::vector<std::string>::iterator it; | 444 std::vector<std::string>::iterator it; |
444 // We can't support GL_EXT_occlusion_query_boolean which is | 445 // We can't support GL_EXT_occlusion_query_boolean which is |
445 // based on GL_ARB_occlusion_query without a lot of work virtualizing | 446 // based on GL_ARB_occlusion_query without a lot of work virtualizing |
446 // queries. | 447 // queries. |
447 it = std::find(ext.begin(), ext.end(), "GL_EXT_occlusion_query_boolean"); | 448 it = std::find(ext.begin(), ext.end(), "GL_EXT_occlusion_query_boolean"); |
448 if (it != ext.end()) | 449 if (it != ext.end()) |
449 ext.erase(it); | 450 ext.erase(it); |
450 | 451 |
451 extensions_ = JoinString(ext, " "); | 452 extensions_ = base::JoinString(ext, " "); |
452 } | 453 } |
453 | 454 |
454 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { | 455 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { |
455 bool switched_contexts = g_current_gl_context_tls->Get() != this; | 456 bool switched_contexts = g_current_gl_context_tls->Get() != this; |
456 GLSurface* current_surface = GLSurface::GetCurrent(); | 457 GLSurface* current_surface = GLSurface::GetCurrent(); |
457 if (switched_contexts || surface != current_surface) { | 458 if (switched_contexts || surface != current_surface) { |
458 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() | 459 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() |
459 // calls if the GLSurface uses the same underlying surface or renders to | 460 // calls if the GLSurface uses the same underlying surface or renders to |
460 // an FBO. | 461 // an FBO. |
461 if (switched_contexts || !current_surface || | 462 if (switched_contexts || !current_surface || |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() | 532 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() |
532 : old_gl_api_(GetCurrentGLApi()) { | 533 : old_gl_api_(GetCurrentGLApi()) { |
533 SetGLToRealGLApi(); | 534 SetGLToRealGLApi(); |
534 } | 535 } |
535 | 536 |
536 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { | 537 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { |
537 SetGLApi(old_gl_api_); | 538 SetGLApi(old_gl_api_); |
538 } | 539 } |
539 | 540 |
540 } // namespace gfx | 541 } // namespace gfx |
OLD | NEW |