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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void GLContext::FlushEvent::Signal() { | 47 void GLContext::FlushEvent::Signal() { |
48 flag_.Set(); | 48 flag_.Set(); |
49 } | 49 } |
50 | 50 |
51 bool GLContext::FlushEvent::IsSignaled() { | 51 bool GLContext::FlushEvent::IsSignaled() { |
52 return flag_.IsSet(); | 52 return flag_.IsSet(); |
53 } | 53 } |
54 | 54 |
55 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { | 55 GLContext::GLContext(GLShareGroup* share_group) : |
| 56 share_group_(share_group), |
| 57 swap_interval_(1), |
| 58 force_swap_interval_zero_(false) { |
56 if (!share_group_.get()) | 59 if (!share_group_.get()) |
57 share_group_ = new GLShareGroup; | 60 share_group_ = new GLShareGroup; |
58 | 61 |
59 share_group_->AddContext(this); | 62 share_group_->AddContext(this); |
60 } | 63 } |
61 | 64 |
62 GLContext::~GLContext() { | 65 GLContext::~GLContext() { |
63 share_group_->RemoveContext(this); | 66 share_group_->RemoveContext(this); |
64 if (GetCurrent() == this) { | 67 if (GetCurrent() == this) { |
65 SetCurrent(NULL); | 68 SetCurrent(NULL); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 174 } |
172 | 175 |
173 GLStateRestorer* GLContext::GetGLStateRestorer() { | 176 GLStateRestorer* GLContext::GetGLStateRestorer() { |
174 return state_restorer_.get(); | 177 return state_restorer_.get(); |
175 } | 178 } |
176 | 179 |
177 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { | 180 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { |
178 state_restorer_ = make_scoped_ptr(state_restorer); | 181 state_restorer_ = make_scoped_ptr(state_restorer); |
179 } | 182 } |
180 | 183 |
| 184 void GLContext::SetSwapInterval(int interval) { |
| 185 swap_interval_ = interval; |
| 186 OnSetSwapInterval(force_swap_interval_zero_ ? 0 : swap_interval_); |
| 187 } |
| 188 |
| 189 void GLContext::ForceSwapIntervalZero(bool force) { |
| 190 force_swap_interval_zero_ = force; |
| 191 OnSetSwapInterval(force_swap_interval_zero_ ? 0 : swap_interval_); |
| 192 } |
| 193 |
181 bool GLContext::WasAllocatedUsingRobustnessExtension() { | 194 bool GLContext::WasAllocatedUsingRobustnessExtension() { |
182 return false; | 195 return false; |
183 } | 196 } |
184 | 197 |
185 bool GLContext::InitializeDynamicBindings() { | 198 bool GLContext::InitializeDynamicBindings() { |
186 DCHECK(IsCurrent(NULL)); | 199 DCHECK(IsCurrent(NULL)); |
187 static bool initialized = false; | 200 static bool initialized = false; |
188 if (initialized) | 201 if (initialized) |
189 return initialized; | 202 return initialized; |
190 initialized = InitializeDynamicGLBindings(GetGLImplementation(), this); | 203 initialized = InitializeDynamicGLBindings(GetGLImplementation(), this); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 : GLContext(share_group) {} | 240 : GLContext(share_group) {} |
228 | 241 |
229 GLContextReal::~GLContextReal() {} | 242 GLContextReal::~GLContextReal() {} |
230 | 243 |
231 void GLContextReal::SetCurrent(GLSurface* surface) { | 244 void GLContextReal::SetCurrent(GLSurface* surface) { |
232 GLContext::SetCurrent(surface); | 245 GLContext::SetCurrent(surface); |
233 current_real_context_.Pointer()->Set(surface ? this : NULL); | 246 current_real_context_.Pointer()->Set(surface ? this : NULL); |
234 } | 247 } |
235 | 248 |
236 } // namespace gfx | 249 } // namespace gfx |
OLD | NEW |