OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 static base::LazyInstance<std::set<SchedulerClientBase*> > all_clients_; | 156 static base::LazyInstance<std::set<SchedulerClientBase*> > all_clients_; |
157 static base::LazyInstance<base::Lock> all_clients_lock_; | 157 static base::LazyInstance<base::Lock> all_clients_lock_; |
158 }; | 158 }; |
159 | 159 |
160 base::LazyInstance<std::set<SchedulerClientBase*> > | 160 base::LazyInstance<std::set<SchedulerClientBase*> > |
161 SchedulerClientBase::all_clients_ = LAZY_INSTANCE_INITIALIZER; | 161 SchedulerClientBase::all_clients_ = LAZY_INSTANCE_INITIALIZER; |
162 base::LazyInstance<base::Lock> SchedulerClientBase::all_clients_lock_ = | 162 base::LazyInstance<base::Lock> SchedulerClientBase::all_clients_lock_ = |
163 LAZY_INSTANCE_INITIALIZER; | 163 LAZY_INSTANCE_INITIALIZER; |
164 | 164 |
165 SchedulerClientBase::SchedulerClientBase(bool need_thread) { | 165 SchedulerClientBase::SchedulerClientBase(bool need_thread) { |
166 base::AutoLock(all_clients_lock_.Get()); | 166 base::AutoLock lock(all_clients_lock_.Get()); |
167 if (need_thread) { | 167 if (need_thread) { |
168 if (!all_clients_.Get().empty()) { | 168 if (!all_clients_.Get().empty()) { |
169 SchedulerClientBase* other = *all_clients_.Get().begin(); | 169 SchedulerClientBase* other = *all_clients_.Get().begin(); |
170 thread_ = other->thread_; | 170 thread_ = other->thread_; |
171 DCHECK(thread_.get()); | 171 DCHECK(thread_.get()); |
172 } else { | 172 } else { |
173 thread_ = new GpuInProcessThread; | 173 thread_ = new GpuInProcessThread; |
174 } | 174 } |
175 } | 175 } |
176 all_clients_.Get().insert(this); | 176 all_clients_.Get().insert(this); |
177 } | 177 } |
178 | 178 |
179 SchedulerClientBase::~SchedulerClientBase() { | 179 SchedulerClientBase::~SchedulerClientBase() { |
180 base::AutoLock(all_clients_lock_.Get()); | 180 base::AutoLock lock(all_clients_lock_.Get()); |
181 all_clients_.Get().erase(this); | 181 all_clients_.Get().erase(this); |
182 } | 182 } |
183 | 183 |
184 bool SchedulerClientBase::HasClients() { | 184 bool SchedulerClientBase::HasClients() { |
185 base::AutoLock(all_clients_lock_.Get()); | 185 base::AutoLock lock(all_clients_lock_.Get()); |
186 return !all_clients_.Get().empty(); | 186 return !all_clients_.Get().empty(); |
187 } | 187 } |
188 | 188 |
189 // A client that talks to the GPU thread | 189 // A client that talks to the GPU thread |
190 class ThreadClient : public SchedulerClientBase { | 190 class ThreadClient : public SchedulerClientBase { |
191 public: | 191 public: |
192 ThreadClient(); | 192 ThreadClient(); |
193 virtual void QueueTask(const base::Closure& task) OVERRIDE; | 193 virtual void QueueTask(const base::Closure& task) OVERRIDE; |
194 virtual void ScheduleIdleWork(const base::Closure& callback) OVERRIDE; | 194 virtual void ScheduleIdleWork(const base::Closure& callback) OVERRIDE; |
195 }; | 195 }; |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 g_gpu_queue.Get().RunTasks(); | 816 g_gpu_queue.Get().RunTasks(); |
817 } | 817 } |
818 | 818 |
819 // static | 819 // static |
820 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( | 820 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( |
821 GpuMemoryBufferFactory* factory) { | 821 GpuMemoryBufferFactory* factory) { |
822 g_gpu_memory_buffer_factory = factory; | 822 g_gpu_memory_buffer_factory = factory; |
823 } | 823 } |
824 | 824 |
825 } // namespace gpu | 825 } // namespace gpu |
OLD | NEW |