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 "gpu/command_buffer/service/gl_context_virtual.h" | 5 #include "gpu/command_buffer/service/gl_context_virtual.h" |
6 | 6 |
7 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 7 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 9 #include "ui/gl/gl_gl_api_implementation.h" |
9 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
10 #include "ui/gl/gpu_timing.h" | 11 #include "ui/gl/gpu_timing.h" |
11 | 12 |
12 namespace gpu { | 13 namespace gpu { |
13 | 14 |
14 GLContextVirtual::GLContextVirtual( | 15 GLContextVirtual::GLContextVirtual( |
15 gfx::GLShareGroup* share_group, | 16 gfx::GLShareGroup* share_group, |
16 gfx::GLContext* shared_context, | 17 gfx::GLContext* shared_context, |
17 base::WeakPtr<gles2::GLES2Decoder> decoder) | 18 base::WeakPtr<gles2::GLES2Decoder> decoder) |
18 : GLContext(share_group), | 19 : GLContext(share_group), |
(...skipping 88 matching lines...) Loading... |
107 } | 108 } |
108 | 109 |
109 bool GLContextVirtual::WasAllocatedUsingRobustnessExtension() { | 110 bool GLContextVirtual::WasAllocatedUsingRobustnessExtension() { |
110 return shared_context_->WasAllocatedUsingRobustnessExtension(); | 111 return shared_context_->WasAllocatedUsingRobustnessExtension(); |
111 } | 112 } |
112 | 113 |
113 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { | 114 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { |
114 shared_context_->SetUnbindFboOnMakeCurrent(); | 115 shared_context_->SetUnbindFboOnMakeCurrent(); |
115 } | 116 } |
116 | 117 |
| 118 base::Closure GLContextVirtual::GetStateWasDirtiedExternallyCallback() { |
| 119 return shared_context_->GetStateWasDirtiedExternallyCallback(); |
| 120 } |
| 121 |
| 122 void GLContextVirtual::RestoreStateIfDirtiedExternally() { |
| 123 // The dirty bit should only be cleared after the state has been restored, |
| 124 // which should be done only when the context is current. |
| 125 DCHECK(IsCurrent(NULL)); |
| 126 if (!shared_context_->GetStateWasDirtiedExternally()) |
| 127 return; |
| 128 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api; |
| 129 GetGLStateRestorer()->RestoreState(NULL); |
| 130 shared_context_->SetStateWasDirtiedExternally(false); |
| 131 } |
| 132 |
117 GLContextVirtual::~GLContextVirtual() { | 133 GLContextVirtual::~GLContextVirtual() { |
118 Destroy(); | 134 Destroy(); |
119 } | 135 } |
120 | 136 |
121 } // namespace gpu | 137 } // namespace gpu |
OLD | NEW |