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 <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 case gfx::SURFACE_TEXTURE_BUFFER: | 214 case gfx::SURFACE_TEXTURE_BUFFER: |
215 case gfx::OZONE_NATIVE_BUFFER: | 215 case gfx::OZONE_NATIVE_BUFFER: |
216 *requires_sync_point = true; | 216 *requires_sync_point = true; |
217 return source_handle; | 217 return source_handle; |
218 default: | 218 default: |
219 NOTREACHED(); | 219 NOTREACHED(); |
220 return gfx::GpuMemoryBufferHandle(); | 220 return gfx::GpuMemoryBufferHandle(); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
| 224 scoped_refptr<InProcessCommandBuffer::Service> GetInitialService( |
| 225 const scoped_refptr<InProcessCommandBuffer::Service>& service) { |
| 226 if (service) |
| 227 return service; |
| 228 |
| 229 // Call base::ThreadTaskRunnerHandle::IsSet() to ensure that it is |
| 230 // instantiated before we create the GPU thread, otherwise shutdown order will |
| 231 // delete the ThreadTaskRunnerHandle before the GPU thread's message loop, |
| 232 // and when the message loop is shutdown, it will recreate |
| 233 // ThreadTaskRunnerHandle, which will re-add a new task to the, AtExitManager, |
| 234 // which causes a deadlock because it's already locked. |
| 235 base::ThreadTaskRunnerHandle::IsSet(); |
| 236 return g_default_service.Get().gpu_thread; |
| 237 } |
| 238 |
224 } // anonyous namespace | 239 } // anonyous namespace |
225 | 240 |
226 InProcessCommandBuffer::Service::Service() {} | 241 InProcessCommandBuffer::Service::Service() {} |
227 | 242 |
228 InProcessCommandBuffer::Service::~Service() {} | 243 InProcessCommandBuffer::Service::~Service() {} |
229 | 244 |
230 scoped_refptr<gfx::GLShareGroup> | 245 scoped_refptr<gfx::GLShareGroup> |
231 InProcessCommandBuffer::Service::share_group() { | 246 InProcessCommandBuffer::Service::share_group() { |
232 if (!share_group_.get()) | 247 if (!share_group_.get()) |
233 share_group_ = new gfx::GLShareGroup; | 248 share_group_ = new gfx::GLShareGroup; |
(...skipping 30 matching lines...) Expand all Loading... |
264 } | 279 } |
265 | 280 |
266 InProcessCommandBuffer::InProcessCommandBuffer( | 281 InProcessCommandBuffer::InProcessCommandBuffer( |
267 const scoped_refptr<Service>& service) | 282 const scoped_refptr<Service>& service) |
268 : context_lost_(false), | 283 : context_lost_(false), |
269 idle_work_pending_(false), | 284 idle_work_pending_(false), |
270 image_factory_(nullptr), | 285 image_factory_(nullptr), |
271 last_put_offset_(-1), | 286 last_put_offset_(-1), |
272 gpu_memory_buffer_manager_(nullptr), | 287 gpu_memory_buffer_manager_(nullptr), |
273 flush_event_(false, false), | 288 flush_event_(false, false), |
274 service_(service.get() ? service : g_default_service.Get().gpu_thread), | 289 service_(GetInitialService(service)), |
275 gpu_thread_weak_ptr_factory_(this) { | 290 gpu_thread_weak_ptr_factory_(this) { |
276 DCHECK(service_.get()); | 291 DCHECK(service_.get()); |
277 next_image_id_.GetNext(); | 292 next_image_id_.GetNext(); |
278 } | 293 } |
279 | 294 |
280 InProcessCommandBuffer::~InProcessCommandBuffer() { | 295 InProcessCommandBuffer::~InProcessCommandBuffer() { |
281 Destroy(); | 296 Destroy(); |
282 } | 297 } |
283 | 298 |
284 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { | 299 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 | 1002 |
988 #if defined(OS_ANDROID) | 1003 #if defined(OS_ANDROID) |
989 scoped_refptr<gfx::SurfaceTexture> | 1004 scoped_refptr<gfx::SurfaceTexture> |
990 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 1005 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
991 DCHECK(stream_texture_manager_); | 1006 DCHECK(stream_texture_manager_); |
992 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 1007 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
993 } | 1008 } |
994 #endif | 1009 #endif |
995 | 1010 |
996 } // namespace gpu | 1011 } // namespace gpu |
OLD | NEW |