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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 // queries. | 105 // queries. |
| 106 it = std::find(ext.begin(), ext.end(), "GL_EXT_occlusion_query_boolean"); | 106 it = std::find(ext.begin(), ext.end(), "GL_EXT_occlusion_query_boolean"); |
| 107 if (it != ext.end()) | 107 if (it != ext.end()) |
| 108 ext.erase(it); | 108 ext.erase(it); |
| 109 | 109 |
| 110 extensions_ = JoinString(ext, " "); | 110 extensions_ = JoinString(ext, " "); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { | 113 bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) { |
| 114 bool switched_contexts = g_current_gl_context != this; | 114 bool switched_contexts = g_current_gl_context != this; |
| 115 GLSurface* current_surface = GLSurface::GetCurrent(); | 115 bool switched_surfaces = GLSurface::GetCurrent() != surface; |
|
brianderson
2013/01/04 22:00:56
Note:
This comparison is almost always false beca
| |
| 116 if (switched_contexts || surface != current_surface) { | 116 if (switched_contexts || switched_surfaces) { |
| 117 if (!switched_contexts && current_surface && | 117 if (!switched_contexts && GLSurface::GetCurrent() && |
| 118 virtual_context->IsCurrent(surface)) { | 118 virtual_context->IsCurrent(surface)) { |
| 119 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() | 119 // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent() |
| 120 // calls if the GLSurface uses the same underlying surface or renders to | 120 // calls if the GLSurface uses the same underlying surface or renders to |
| 121 // an FBO. | 121 // an FBO. |
| 122 if (!surface->OnMakeCurrent(real_context_)) { | 122 if (!surface->OnMakeCurrent(real_context_)) { |
| 123 LOG(ERROR) << "Could not make GLSurface current."; | 123 LOG(ERROR) << "Could not make GLSurface current."; |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 } else if (!real_context_->MakeCurrent(surface)) { | 126 } else if (!real_context_->MakeCurrent(surface)) { |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 DCHECK(GLSurface::GetCurrent()); | 131 DCHECK(GLSurface::GetCurrent()); |
| 132 DCHECK(real_context_->IsCurrent(GLSurface::GetCurrent())); | 132 DCHECK(real_context_->IsCurrent(GLSurface::GetCurrent())); |
| 133 DCHECK(virtual_context->IsCurrent(surface)); | 133 DCHECK(virtual_context->IsCurrent(surface)); |
| 134 | 134 |
| 135 if (switched_contexts || virtual_context != current_context_) { | 135 // This work around restores gl state on virtual context switches |
| 136 // where only the surface changes. | |
| 137 bool qualcomm_WAR_enabled = true; // TODO: Set this only when needed. | |
| 138 bool use_qualcomm_WAR = qualcomm_WAR_enabled && switched_surfaces; | |
| 139 | |
| 140 if (switched_contexts || virtual_context != current_context_ || | |
| 141 use_qualcomm_WAR) { | |
| 136 // There should be no errors from the previous context leaking into the | 142 // There should be no errors from the previous context leaking into the |
| 137 // new context. | 143 // new context. |
| 138 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); | 144 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); |
| 139 | 145 |
| 140 current_context_ = virtual_context; | 146 current_context_ = virtual_context; |
| 141 // Set all state that is different from the real state | 147 // Set all state that is different from the real state |
| 142 // NOTE: !!! This is a temporary implementation that just restores all | 148 // NOTE: !!! This is a temporary implementation that just restores all |
| 143 // state to let us test that it works. | 149 // state to let us test that it works. |
| 144 // TODO: ASAP, change this to something that only restores the state | 150 // TODO: ASAP, change this to something that only restores the state |
| 145 // needed for individual GL calls. | 151 // needed for individual GL calls. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 160 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 166 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
| 161 switch (name) { | 167 switch (name) { |
| 162 case GL_EXTENSIONS: | 168 case GL_EXTENSIONS: |
| 163 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 169 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
| 164 default: | 170 default: |
| 165 return driver_->fn.glGetStringFn(name); | 171 return driver_->fn.glGetStringFn(name); |
| 166 } | 172 } |
| 167 } | 173 } |
| 168 | 174 |
| 169 } // namespace gfx | 175 } // namespace gfx |
| OLD | NEW |