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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 298 |
299 DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); | 299 DCHECK_EQ(real_context_, GLContext::GetRealCurrent()); |
300 DCHECK(real_context_->IsCurrent(NULL)); | 300 DCHECK(real_context_->IsCurrent(NULL)); |
301 DCHECK(virtual_context->IsCurrent(surface)); | 301 DCHECK(virtual_context->IsCurrent(surface)); |
302 | 302 |
303 if (switched_contexts || virtual_context != current_context_) { | 303 if (switched_contexts || virtual_context != current_context_) { |
304 // There should be no errors from the previous context leaking into the | 304 // There should be no errors from the previous context leaking into the |
305 // new context. | 305 // new context. |
306 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); | 306 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); |
307 | 307 |
308 current_context_ = virtual_context; | |
309 // Set all state that is different from the real state | 308 // Set all state that is different from the real state |
310 // NOTE: !!! This is a temporary implementation that just restores all | |
311 // state to let us test that it works. | |
312 // TODO: ASAP, change this to something that only restores the state | |
313 // needed for individual GL calls. | |
314 GLApi* temp = GetCurrentGLApi(); | 309 GLApi* temp = GetCurrentGLApi(); |
315 SetGLToRealGLApi(); | 310 SetGLToRealGLApi(); |
316 if (virtual_context->GetGLStateRestorer()->IsInitialized()) | 311 if (virtual_context->GetGLStateRestorer()->IsInitialized()) { |
317 virtual_context->GetGLStateRestorer()->RestoreState(); | 312 virtual_context->GetGLStateRestorer()->RestoreState( |
313 (current_context_) | |
Sami
2013/12/18 16:04:07
It might be worth checking how often we go from Ma
kaanb
2013/12/18 17:24:55
I see MakeCurrent(NULL) -> MakeCurrent(some_contex
| |
314 ? current_context_->GetGLStateRestorer()->GetContextState() | |
315 : NULL); | |
316 } | |
318 SetGLApi(temp); | 317 SetGLApi(temp); |
318 current_context_ = virtual_context; | |
319 } | 319 } |
320 SetGLApi(this); | 320 SetGLApi(this); |
321 | 321 |
322 virtual_context->SetCurrent(surface); | 322 virtual_context->SetCurrent(surface); |
323 if (!surface->OnMakeCurrent(virtual_context)) { | 323 if (!surface->OnMakeCurrent(virtual_context)) { |
324 LOG(ERROR) << "Could not make GLSurface current."; | 324 LOG(ERROR) << "Could not make GLSurface current."; |
325 return false; | 325 return false; |
326 } | 326 } |
327 return true; | 327 return true; |
328 } | 328 } |
329 | 329 |
330 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 330 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
331 if (current_context_ == virtual_context) | 331 if (current_context_ == virtual_context) |
332 current_context_ = NULL; | 332 current_context_ = NULL; |
333 } | 333 } |
334 | 334 |
335 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 335 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
336 switch (name) { | 336 switch (name) { |
337 case GL_EXTENSIONS: | 337 case GL_EXTENSIONS: |
338 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 338 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
339 default: | 339 default: |
340 return driver_->fn.glGetStringFn(name); | 340 return driver_->fn.glGetStringFn(name); |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 } // namespace gfx | 344 } // namespace gfx |
OLD | NEW |