| 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 |
| 41 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { | 55 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { |
| 42 if (!share_group_.get()) | 56 if (!share_group_.get()) |
| 43 share_group_ = new GLShareGroup; | 57 share_group_ = new GLShareGroup; |
| 44 | 58 |
| 45 share_group_->AddContext(this); | 59 share_group_->AddContext(this); |
| 46 } | 60 } |
| 47 | 61 |
| 48 GLContext::~GLContext() { | 62 GLContext::~GLContext() { |
| 49 share_group_->RemoveContext(this); | 63 share_group_->RemoveContext(this); |
| 50 if (GetCurrent() == this) { | 64 if (GetCurrent() == this) { |
| 51 SetCurrent(NULL); | 65 SetCurrent(NULL); |
| 52 } | 66 } |
| 53 } | 67 } |
| 54 | 68 |
| 69 scoped_refptr<GLContext::FlushEvent> GLContext::SignalFlush() { |
| 70 DCHECK(IsCurrent(NULL)); |
| 71 scoped_refptr<FlushEvent> flush_event = new FlushEvent(); |
| 72 flush_events_.push_back(flush_event); |
| 73 return flush_event; |
| 74 } |
| 75 |
| 55 bool GLContext::GetTotalGpuMemory(size_t* bytes) { | 76 bool GLContext::GetTotalGpuMemory(size_t* bytes) { |
| 56 DCHECK(bytes); | 77 DCHECK(bytes); |
| 57 *bytes = 0; | 78 *bytes = 0; |
| 58 return false; | 79 return false; |
| 59 } | 80 } |
| 60 | 81 |
| 61 void GLContext::SetSafeToForceGpuSwitch() { | 82 void GLContext::SetSafeToForceGpuSwitch() { |
| 62 } | 83 } |
| 63 | 84 |
| 64 void GLContext::SetUnbindFboOnMakeCurrent() { | 85 void GLContext::SetUnbindFboOnMakeCurrent() { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 204 |
| 184 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 205 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
| 185 if (virtual_gl_api_) | 206 if (virtual_gl_api_) |
| 186 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); | 207 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); |
| 187 } | 208 } |
| 188 | 209 |
| 189 void GLContext::SetRealGLApi() { | 210 void GLContext::SetRealGLApi() { |
| 190 SetGLToRealGLApi(); | 211 SetGLToRealGLApi(); |
| 191 } | 212 } |
| 192 | 213 |
| 214 void GLContext::OnFlush() { |
| 215 for (size_t n = 0; n < flush_events_.size(); n++) |
| 216 flush_events_[n]->Signal(); |
| 217 flush_events_.clear(); |
| 218 } |
| 219 |
| 193 GLContextReal::GLContextReal(GLShareGroup* share_group) | 220 GLContextReal::GLContextReal(GLShareGroup* share_group) |
| 194 : GLContext(share_group) {} | 221 : GLContext(share_group) {} |
| 195 | 222 |
| 196 GLContextReal::~GLContextReal() {} | 223 GLContextReal::~GLContextReal() {} |
| 197 | 224 |
| 198 void GLContextReal::SetCurrent(GLSurface* surface) { | 225 void GLContextReal::SetCurrent(GLSurface* surface) { |
| 199 GLContext::SetCurrent(surface); | 226 GLContext::SetCurrent(surface); |
| 200 current_real_context_.Pointer()->Set(surface ? this : NULL); | 227 current_real_context_.Pointer()->Set(surface ? this : NULL); |
| 201 } | 228 } |
| 202 | 229 |
| 203 } // namespace gfx | 230 } // namespace gfx |
| OLD | NEW |