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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 // an FBO. | 261 // an FBO. |
262 if (!surface->OnMakeCurrent(real_context_)) { | 262 if (!surface->OnMakeCurrent(real_context_)) { |
263 LOG(ERROR) << "Could not make GLSurface current."; | 263 LOG(ERROR) << "Could not make GLSurface current."; |
264 return false; | 264 return false; |
265 } | 265 } |
266 } else if (!real_context_->MakeCurrent(surface)) { | 266 } else if (!real_context_->MakeCurrent(surface)) { |
267 return false; | 267 return false; |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 DCHECK(GLSurface::GetCurrent()); | 271 DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); |
272 DCHECK(real_context_->IsCurrent(GLSurface::GetCurrent())); | 272 DCHECK(GLSurface::GetRealCurrent()); |
273 DCHECK(real_context_->IsCurrent(GLSurface::GetRealCurrent())); | |
jonathan.backer
2013/05/23 21:00:53
Switching to a real surface is necessary because G
| |
273 DCHECK(virtual_context->IsCurrent(surface)); | 274 DCHECK(virtual_context->IsCurrent(surface)); |
274 | 275 |
275 if (switched_contexts || virtual_context != current_context_) { | 276 if (switched_contexts || virtual_context != current_context_) { |
276 // There should be no errors from the previous context leaking into the | 277 // There should be no errors from the previous context leaking into the |
277 // new context. | 278 // new context. |
278 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); | 279 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); |
279 | 280 |
280 current_context_ = virtual_context; | 281 current_context_ = virtual_context; |
281 // Set all state that is different from the real state | 282 // Set all state that is different from the real state |
282 // NOTE: !!! This is a temporary implementation that just restores all | 283 // NOTE: !!! This is a temporary implementation that just restores all |
283 // state to let us test that it works. | 284 // state to let us test that it works. |
284 // TODO: ASAP, change this to something that only restores the state | 285 // TODO: ASAP, change this to something that only restores the state |
285 // needed for individual GL calls. | 286 // needed for individual GL calls. |
286 GLApi* temp = GetCurrentGLApi(); | 287 GLApi* temp = GetCurrentGLApi(); |
287 SetGLToRealGLApi(); | 288 SetGLToRealGLApi(); |
288 virtual_context->GetGLStateRestorer()->RestoreState(); | 289 virtual_context->GetGLStateRestorer()->RestoreState(); |
289 SetGLApi(temp); | 290 SetGLApi(temp); |
290 } | 291 } |
291 SetGLApi(this); | 292 SetGLApi(this); |
293 | |
292 return true; | 294 return true; |
293 } | 295 } |
294 | 296 |
295 void VirtualGLApi::OnDestroyVirtualContext(GLContext* virtual_context) { | 297 void VirtualGLApi::OnDestroyVirtualContext(GLContext* virtual_context) { |
296 if (current_context_ == virtual_context) | 298 if (current_context_ == virtual_context) |
297 current_context_ = NULL; | 299 current_context_ = NULL; |
298 } | 300 } |
299 | 301 |
300 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 302 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
301 switch (name) { | 303 switch (name) { |
302 case GL_EXTENSIONS: | 304 case GL_EXTENSIONS: |
303 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 305 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
304 default: | 306 default: |
305 return driver_->fn.glGetStringFn(name); | 307 return driver_->fn.glGetStringFn(name); |
306 } | 308 } |
307 } | 309 } |
308 | 310 |
309 } // namespace gfx | 311 } // namespace gfx |
OLD | NEW |