Chromium Code Reviews| Index: ui/gl/gl_context.cc |
| diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc |
| index cd9a28c387dcfabd66c18b7ccf7bbd3b88c3ff44..d7e6695bf98570b8611e77d25dd68bea867176e0 100644 |
| --- a/ui/gl/gl_context.cc |
| +++ b/ui/gl/gl_context.cc |
| @@ -26,6 +26,20 @@ base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky |
| current_real_context_ = LAZY_INSTANCE_INITIALIZER; |
| } // namespace |
| +GLContext::FlushEvent::FlushEvent() : state_(0) { |
| +} |
| + |
| +GLContext::FlushEvent::~FlushEvent() { |
| +} |
| + |
| +void GLContext::FlushEvent::Signal() { |
| + base::subtle::NoBarrier_AtomicExchange(&state_, 1); |
|
piman
2014/03/15 00:18:40
I'm not convinced whether this is correct or not.
no sievers
2014/03/19 01:25:21
Done.
|
| +} |
| + |
| +bool GLContext::FlushEvent::IsSignaled() { |
| + return base::subtle::NoBarrier_CompareAndSwap(&state_, 1, 1) != 0; |
| +} |
| + |
| GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { |
| if (!share_group_.get()) |
| share_group_ = new GLShareGroup; |
| @@ -40,6 +54,13 @@ GLContext::~GLContext() { |
| } |
| } |
| +scoped_refptr<GLContext::FlushEvent> |
| +GLContext::SignalFlush() { |
| + scoped_refptr<FlushEvent> flush_event = new FlushEvent(); |
| + flush_events_.push_back(flush_event); |
| + return flush_event; |
| +} |
| + |
| bool GLContext::GetTotalGpuMemory(size_t* bytes) { |
| DCHECK(bytes); |
| *bytes = 0; |
| @@ -172,6 +193,12 @@ void GLContext::SetRealGLApi() { |
| SetGLToRealGLApi(); |
| } |
| +void GLContext::OnFlush() { |
| + for (size_t n = 0; n < flush_events_.size(); n++) |
| + flush_events_[n]->Signal(); |
| + flush_events_.clear(); |
| +} |
| + |
| GLContextReal::GLContextReal(GLShareGroup* share_group) |
| : GLContext(share_group) {} |