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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); | 278 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); |
279 | 279 |
280 current_context_ = virtual_context; | 280 current_context_ = virtual_context; |
281 // Set all state that is different from the real state | 281 // Set all state that is different from the real state |
282 // NOTE: !!! This is a temporary implementation that just restores all | 282 // NOTE: !!! This is a temporary implementation that just restores all |
283 // state to let us test that it works. | 283 // state to let us test that it works. |
284 // TODO: ASAP, change this to something that only restores the state | 284 // TODO: ASAP, change this to something that only restores the state |
285 // needed for individual GL calls. | 285 // needed for individual GL calls. |
286 GLApi* temp = GetCurrentGLApi(); | 286 GLApi* temp = GetCurrentGLApi(); |
287 SetGLToRealGLApi(); | 287 SetGLToRealGLApi(); |
288 virtual_context->GetGLStateRestorer()->RestoreState(); | 288 if (virtual_context->GetGLStateRestorer()->IsInitialized()) |
| 289 virtual_context->GetGLStateRestorer()->RestoreState(); |
289 SetGLApi(temp); | 290 SetGLApi(temp); |
290 } | 291 } |
291 SetGLApi(this); | 292 SetGLApi(this); |
292 return true; | 293 return true; |
293 } | 294 } |
294 | 295 |
295 void VirtualGLApi::OnDestroyVirtualContext(GLContext* virtual_context) { | 296 void VirtualGLApi::OnDestroyVirtualContext(GLContext* virtual_context) { |
296 if (current_context_ == virtual_context) | 297 if (current_context_ == virtual_context) |
297 current_context_ = NULL; | 298 current_context_ = NULL; |
298 } | 299 } |
299 | 300 |
300 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 301 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
301 switch (name) { | 302 switch (name) { |
302 case GL_EXTENSIONS: | 303 case GL_EXTENSIONS: |
303 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 304 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
304 default: | 305 default: |
305 return driver_->fn.glGetStringFn(name); | 306 return driver_->fn.glGetStringFn(name); |
306 } | 307 } |
307 } | 308 } |
308 | 309 |
309 } // namespace gfx | 310 } // namespace gfx |
OLD | NEW |