| 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 20 matching lines...) Expand all Loading... |
| 31 GLContext::ScopedReleaseCurrent::~ScopedReleaseCurrent() { | 31 GLContext::ScopedReleaseCurrent::~ScopedReleaseCurrent() { |
| 32 if (!canceled_ && GetCurrent()) { | 32 if (!canceled_ && GetCurrent()) { |
| 33 GetCurrent()->ReleaseCurrent(NULL); | 33 GetCurrent()->ReleaseCurrent(NULL); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 void GLContext::ScopedReleaseCurrent::Cancel() { | 37 void GLContext::ScopedReleaseCurrent::Cancel() { |
| 38 canceled_ = true; | 38 canceled_ = true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 GLContext::FlushEvent::FlushEvent() { | |
| 42 } | |
| 43 | |
| 44 GLContext::FlushEvent::~FlushEvent() { | |
| 45 } | |
| 46 | |
| 47 void GLContext::FlushEvent::Signal() { | |
| 48 flag_.Set(); | |
| 49 } | |
| 50 | |
| 51 bool GLContext::FlushEvent::IsSignaled() { | |
| 52 return flag_.IsSet(); | |
| 53 } | |
| 54 | |
| 55 GLContext::GLContext(GLShareGroup* share_group) : | 41 GLContext::GLContext(GLShareGroup* share_group) : |
| 56 share_group_(share_group), | 42 share_group_(share_group), |
| 57 swap_interval_(1), | 43 swap_interval_(1), |
| 58 force_swap_interval_zero_(false) { | 44 force_swap_interval_zero_(false) { |
| 59 if (!share_group_.get()) | 45 if (!share_group_.get()) |
| 60 share_group_ = new GLShareGroup; | 46 share_group_ = new GLShareGroup; |
| 61 | 47 |
| 62 share_group_->AddContext(this); | 48 share_group_->AddContext(this); |
| 63 } | 49 } |
| 64 | 50 |
| 65 GLContext::~GLContext() { | 51 GLContext::~GLContext() { |
| 66 share_group_->RemoveContext(this); | 52 share_group_->RemoveContext(this); |
| 67 if (GetCurrent() == this) { | 53 if (GetCurrent() == this) { |
| 68 SetCurrent(NULL); | 54 SetCurrent(NULL); |
| 69 } | 55 } |
| 70 } | 56 } |
| 71 | 57 |
| 72 scoped_refptr<GLContext::FlushEvent> GLContext::SignalFlush() { | |
| 73 DCHECK(IsCurrent(NULL)); | |
| 74 scoped_refptr<FlushEvent> flush_event = new FlushEvent(); | |
| 75 flush_events_.push_back(flush_event); | |
| 76 return flush_event; | |
| 77 } | |
| 78 | |
| 79 bool GLContext::GetTotalGpuMemory(size_t* bytes) { | 58 bool GLContext::GetTotalGpuMemory(size_t* bytes) { |
| 80 DCHECK(bytes); | 59 DCHECK(bytes); |
| 81 *bytes = 0; | 60 *bytes = 0; |
| 82 return false; | 61 return false; |
| 83 } | 62 } |
| 84 | 63 |
| 85 void GLContext::SetSafeToForceGpuSwitch() { | 64 void GLContext::SetSafeToForceGpuSwitch() { |
| 86 } | 65 } |
| 87 | 66 |
| 88 bool GLContext::ForceGpuSwitchIfNeeded() { | 67 bool GLContext::ForceGpuSwitchIfNeeded() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 202 |
| 224 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 203 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
| 225 if (virtual_gl_api_) | 204 if (virtual_gl_api_) |
| 226 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); | 205 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); |
| 227 } | 206 } |
| 228 | 207 |
| 229 void GLContext::SetRealGLApi() { | 208 void GLContext::SetRealGLApi() { |
| 230 SetGLToRealGLApi(); | 209 SetGLToRealGLApi(); |
| 231 } | 210 } |
| 232 | 211 |
| 233 void GLContext::OnFlush() { | |
| 234 for (size_t n = 0; n < flush_events_.size(); n++) | |
| 235 flush_events_[n]->Signal(); | |
| 236 flush_events_.clear(); | |
| 237 } | |
| 238 | |
| 239 GLContextReal::GLContextReal(GLShareGroup* share_group) | 212 GLContextReal::GLContextReal(GLShareGroup* share_group) |
| 240 : GLContext(share_group) {} | 213 : GLContext(share_group) {} |
| 241 | 214 |
| 242 GLContextReal::~GLContextReal() {} | 215 GLContextReal::~GLContextReal() {} |
| 243 | 216 |
| 244 void GLContextReal::SetCurrent(GLSurface* surface) { | 217 void GLContextReal::SetCurrent(GLSurface* surface) { |
| 245 GLContext::SetCurrent(surface); | 218 GLContext::SetCurrent(surface); |
| 246 current_real_context_.Pointer()->Set(surface ? this : NULL); | 219 current_real_context_.Pointer()->Set(surface ? this : NULL); |
| 247 } | 220 } |
| 248 | 221 |
| 249 } // namespace gfx | 222 } // namespace gfx |
| OLD | NEW |