| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 InProcessCommandBuffer::InProcessCommandBuffer( | 266 InProcessCommandBuffer::InProcessCommandBuffer( |
| 267 const scoped_refptr<Service>& service) | 267 const scoped_refptr<Service>& service) |
| 268 : context_lost_(false), | 268 : context_lost_(false), |
| 269 idle_work_pending_(false), | 269 idle_work_pending_(false), |
| 270 image_factory_(nullptr), | 270 image_factory_(nullptr), |
| 271 last_put_offset_(-1), | 271 last_put_offset_(-1), |
| 272 gpu_memory_buffer_manager_(nullptr), | 272 gpu_memory_buffer_manager_(nullptr), |
| 273 flush_event_(false, false), | 273 flush_event_(false, false), |
| 274 service_(service.get() ? service : g_default_service.Get().gpu_thread), | 274 service_(GetInitialService(service)), |
| 275 gpu_thread_weak_ptr_factory_(this) { | 275 gpu_thread_weak_ptr_factory_(this) { |
| 276 DCHECK(service_.get()); | 276 DCHECK(service_.get()); |
| 277 next_image_id_.GetNext(); | 277 next_image_id_.GetNext(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 InProcessCommandBuffer::~InProcessCommandBuffer() { | 280 InProcessCommandBuffer::~InProcessCommandBuffer() { |
| 281 Destroy(); | 281 Destroy(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 scoped_refptr<InProcessCommandBuffer::Service> |
| 285 InProcessCommandBuffer::GetInitialService( |
| 286 const scoped_refptr<Service>& service) { |
| 287 if (service) |
| 288 return service; |
| 289 |
| 290 // Call base::ThreadTaskRunnerHandle::IsSet() to ensure that it is |
| 291 // instantiated before we create the GPU thread, otherwise shutdown order will |
| 292 // delete the ThreadTaskRunnerHandle before the GPU thread's message loop, |
| 293 // and when the message loop is shutdown, it will recreate |
| 294 // ThreadTaskRunnerHandle, which will re-add a new task to the, AtExitManager, |
| 295 // which causes a deadlock because it's already locked. |
| 296 base::ThreadTaskRunnerHandle::IsSet(); |
| 297 return g_default_service.Get().gpu_thread; |
| 298 } |
| 299 |
| 284 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { | 300 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { |
| 285 CheckSequencedThread(); | 301 CheckSequencedThread(); |
| 286 DCHECK(!surface_->IsOffscreen()); | 302 DCHECK(!surface_->IsOffscreen()); |
| 287 surface_->Resize(size); | 303 surface_->Resize(size); |
| 288 } | 304 } |
| 289 | 305 |
| 290 bool InProcessCommandBuffer::MakeCurrent() { | 306 bool InProcessCommandBuffer::MakeCurrent() { |
| 291 CheckSequencedThread(); | 307 CheckSequencedThread(); |
| 292 command_buffer_lock_.AssertAcquired(); | 308 command_buffer_lock_.AssertAcquired(); |
| 293 | 309 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 986 |
| 971 #if defined(OS_ANDROID) | 987 #if defined(OS_ANDROID) |
| 972 scoped_refptr<gfx::SurfaceTexture> | 988 scoped_refptr<gfx::SurfaceTexture> |
| 973 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 989 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
| 974 DCHECK(stream_texture_manager_); | 990 DCHECK(stream_texture_manager_); |
| 975 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 991 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
| 976 } | 992 } |
| 977 #endif | 993 #endif |
| 978 | 994 |
| 979 } // namespace gpu | 995 } // namespace gpu |
| OLD | NEW |