OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/surfaces/deferred_gpu_command_service.h" |
| 6 |
| 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 DeferredGpuCommandService::DeferredGpuCommandService( |
| 13 gpu::SyncPointManager* sync_point_manager, |
| 14 gpu::gles2::MailboxManager* mailbox_manager, |
| 15 scoped_refptr<gl::GLShareGroup> share_group) |
| 16 : task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 17 sync_point_manager_(sync_point_manager), |
| 18 share_group_(share_group) { |
| 19 mailbox_manager_ = mailbox_manager; |
| 20 } |
| 21 |
| 22 void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) { |
| 23 task_runner_->PostTask(FROM_HERE, task); |
| 24 } |
| 25 |
| 26 void DeferredGpuCommandService::ScheduleDelayedWork(const base::Closure& task) { |
| 27 task_runner_->PostDelayedTask(FROM_HERE, task, |
| 28 base::TimeDelta::FromMilliseconds(2)); |
| 29 } |
| 30 bool DeferredGpuCommandService::UseVirtualizedGLContexts() { |
| 31 return true; |
| 32 } |
| 33 |
| 34 scoped_refptr<gpu::gles2::ShaderTranslatorCache> |
| 35 DeferredGpuCommandService::shader_translator_cache() { |
| 36 if (!shader_translator_cache_) { |
| 37 shader_translator_cache_ = make_scoped_refptr( |
| 38 new gpu::gles2::ShaderTranslatorCache(gpu_preferences())); |
| 39 } |
| 40 return shader_translator_cache_; |
| 41 } |
| 42 |
| 43 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> |
| 44 DeferredGpuCommandService::framebuffer_completeness_cache() { |
| 45 if (!framebuffer_completeness_cache_.get()) { |
| 46 framebuffer_completeness_cache_ = |
| 47 make_scoped_refptr(new gpu::gles2::FramebufferCompletenessCache); |
| 48 } |
| 49 return framebuffer_completeness_cache_; |
| 50 } |
| 51 |
| 52 gpu::SyncPointManager* DeferredGpuCommandService::sync_point_manager() { |
| 53 return sync_point_manager_; |
| 54 } |
| 55 |
| 56 void DeferredGpuCommandService::AddRef() const { |
| 57 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); |
| 58 } |
| 59 |
| 60 void DeferredGpuCommandService::Release() const { |
| 61 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); |
| 62 } |
| 63 |
| 64 const scoped_refptr<gl::GLShareGroup>& |
| 65 DeferredGpuCommandService::GetShareGroup() const { |
| 66 return share_group_; |
| 67 } |
| 68 |
| 69 bool DeferredGpuCommandService::BlockThreadOnWaitSyncToken() const { |
| 70 return false; |
| 71 } |
| 72 |
| 73 DeferredGpuCommandService::~DeferredGpuCommandService() { |
| 74 base::AutoLock lock(tasks_lock_); |
| 75 DCHECK(tasks_.empty()); |
| 76 } |
| 77 |
| 78 } // namespace cc |
OLD | NEW |