Chromium Code Reviews| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 | 520 |
| 521 VirtualGLApi::~VirtualGLApi() { | 521 VirtualGLApi::~VirtualGLApi() { |
| 522 } | 522 } |
| 523 | 523 |
| 524 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { | 524 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { |
| 525 InitializeBase(driver); | 525 InitializeBase(driver); |
| 526 real_context_ = real_context; | 526 real_context_ = real_context; |
| 527 | 527 |
| 528 DCHECK(real_context->IsCurrent(NULL)); | 528 DCHECK(real_context->IsCurrent(NULL)); |
| 529 extensions_ = real_context->GetExtensions(); | 529 extensions_ = real_context->GetExtensions(); |
| 530 extensions_vec_ = base::SplitString(extensions_, " ", base::TRIM_WHITESPACE, | |
| 531 base::SPLIT_WANT_ALL); | |
| 530 } | 532 } |
| 531 | 533 |
| 532 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { | 534 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { |
| 533 bool switched_contexts = g_current_gl_context_tls->Get() != this; | 535 bool switched_contexts = g_current_gl_context_tls->Get() != this; |
| 534 GLSurface* current_surface = GLSurface::GetCurrent(); | 536 GLSurface* current_surface = GLSurface::GetCurrent(); |
| 535 if (switched_contexts || surface != current_surface) { | 537 if (switched_contexts || surface != current_surface) { |
| 536 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() | 538 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() |
| 537 // calls if the GLSurface uses the same underlying surface or renders to | 539 // calls if the GLSurface uses the same underlying surface or renders to |
| 538 // an FBO. | 540 // an FBO. |
| 539 if (switched_contexts || !current_surface || | 541 if (switched_contexts || !current_surface || |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 return false; | 595 return false; |
| 594 } | 596 } |
| 595 return true; | 597 return true; |
| 596 } | 598 } |
| 597 | 599 |
| 598 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 600 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
| 599 if (current_context_ == virtual_context) | 601 if (current_context_ == virtual_context) |
| 600 current_context_ = NULL; | 602 current_context_ = NULL; |
| 601 } | 603 } |
| 602 | 604 |
| 605 void VirtualGLApi::glGetIntegervFn(GLenum pname, GLint* params) { | |
| 606 switch (pname) { | |
| 607 case GL_EXTENSIONS: | |
|
no sievers
2015/12/04 20:16:14
did you mean GL_NUM_EXTENSIONS?
David Yen
2015/12/04 22:21:41
Ah yes, thank you for catching this. Done.
| |
| 608 *params = static_cast<GLint>(extensions_vec_.size()); | |
| 609 break; | |
| 610 default: | |
| 611 driver_->fn.glGetIntegervFn(pname, params); | |
| 612 break; | |
| 613 } | |
| 614 } | |
| 615 | |
| 603 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 616 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
| 604 switch (name) { | 617 switch (name) { |
| 605 case GL_EXTENSIONS: | 618 case GL_EXTENSIONS: |
| 606 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 619 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
| 607 default: | 620 default: |
| 608 return driver_->fn.glGetStringFn(name); | 621 return driver_->fn.glGetStringFn(name); |
| 609 } | 622 } |
| 610 } | 623 } |
| 611 | 624 |
| 625 const GLubyte* VirtualGLApi::glGetStringiFn(GLenum name, GLuint index) { | |
| 626 switch (name) { | |
| 627 case GL_EXTENSIONS: | |
| 628 if (index >= extensions_vec_.size()) | |
| 629 return NULL; | |
| 630 return reinterpret_cast<const GLubyte*>(extensions_vec_[index].c_str()); | |
| 631 default: | |
| 632 return driver_->fn.glGetStringiFn(name, index); | |
| 633 } | |
| 634 } | |
| 635 | |
| 612 void VirtualGLApi::glFlushFn() { | 636 void VirtualGLApi::glFlushFn() { |
| 613 GLApiBase::glFlushFn(); | 637 GLApiBase::glFlushFn(); |
| 614 } | 638 } |
| 615 | 639 |
| 616 void VirtualGLApi::glFinishFn() { | 640 void VirtualGLApi::glFinishFn() { |
| 617 GLApiBase::glFinishFn(); | 641 GLApiBase::glFinishFn(); |
| 618 } | 642 } |
| 619 | 643 |
| 620 } // namespace gfx | 644 } // namespace gfx |
| OLD | NEW |