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 | |
239 } // anonyous namespace | 224 } // anonyous namespace |
240 | 225 |
241 InProcessCommandBuffer::Service::Service() {} | 226 InProcessCommandBuffer::Service::Service() {} |
242 | 227 |
243 InProcessCommandBuffer::Service::~Service() {} | 228 InProcessCommandBuffer::Service::~Service() {} |
244 | 229 |
245 scoped_refptr<gfx::GLShareGroup> | 230 scoped_refptr<gfx::GLShareGroup> |
246 InProcessCommandBuffer::Service::share_group() { | 231 InProcessCommandBuffer::Service::share_group() { |
247 if (!share_group_.get()) | 232 if (!share_group_.get()) |
248 share_group_ = new gfx::GLShareGroup; | 233 share_group_ = new gfx::GLShareGroup; |
(...skipping 30 matching lines...) Expand all Loading... |
279 } | 264 } |
280 | 265 |
281 InProcessCommandBuffer::InProcessCommandBuffer( | 266 InProcessCommandBuffer::InProcessCommandBuffer( |
282 const scoped_refptr<Service>& service) | 267 const scoped_refptr<Service>& service) |
283 : context_lost_(false), | 268 : context_lost_(false), |
284 idle_work_pending_(false), | 269 idle_work_pending_(false), |
285 image_factory_(nullptr), | 270 image_factory_(nullptr), |
286 last_put_offset_(-1), | 271 last_put_offset_(-1), |
287 gpu_memory_buffer_manager_(nullptr), | 272 gpu_memory_buffer_manager_(nullptr), |
288 flush_event_(false, false), | 273 flush_event_(false, false), |
289 service_(GetInitialService(service)), | 274 service_(service.get() ? service : g_default_service.Get().gpu_thread), |
290 gpu_thread_weak_ptr_factory_(this) { | 275 gpu_thread_weak_ptr_factory_(this) { |
291 DCHECK(service_.get()); | 276 DCHECK(service_.get()); |
292 next_image_id_.GetNext(); | 277 next_image_id_.GetNext(); |
293 } | 278 } |
294 | 279 |
295 InProcessCommandBuffer::~InProcessCommandBuffer() { | 280 InProcessCommandBuffer::~InProcessCommandBuffer() { |
296 Destroy(); | 281 Destroy(); |
297 } | 282 } |
298 | 283 |
299 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { | 284 void InProcessCommandBuffer::OnResizeView(gfx::Size size, float scale_factor) { |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 | 987 |
1003 #if defined(OS_ANDROID) | 988 #if defined(OS_ANDROID) |
1004 scoped_refptr<gfx::SurfaceTexture> | 989 scoped_refptr<gfx::SurfaceTexture> |
1005 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 990 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
1006 DCHECK(stream_texture_manager_); | 991 DCHECK(stream_texture_manager_); |
1007 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 992 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
1008 } | 993 } |
1009 #endif | 994 #endif |
1010 | 995 |
1011 } // namespace gpu | 996 } // namespace gpu |
OLD | NEW |