OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "android_webview/browser/deferred_gpu_command_service.h" | 5 #include "android_webview/browser/deferred_gpu_command_service.h" |
6 | 6 |
7 #include "android_webview/browser/gl_view_renderer_manager.h" | 7 #include "android_webview/browser/gl_view_renderer_manager.h" |
8 #include "android_webview/browser/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "content/public/browser/android/synchronous_compositor.h" | 12 #include "content/public/browser/android/synchronous_compositor.h" |
13 #include "gpu/command_buffer/service/shader_translator_cache.h" | 13 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 14 #include "gpu/command_buffer/service/sync_point_manager.h" |
14 | 15 |
15 namespace android_webview { | 16 namespace android_webview { |
16 | 17 |
17 namespace { | 18 namespace { |
18 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > | 19 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > |
19 g_service = LAZY_INSTANCE_INITIALIZER; | 20 g_service = LAZY_INSTANCE_INITIALIZER; |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; | 23 base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; |
23 | 24 |
(...skipping 29 matching lines...) Expand all Loading... |
53 content::SynchronousCompositor::SetGpuService(g_service.Get()); | 54 content::SynchronousCompositor::SetGpuService(g_service.Get()); |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 // static | 58 // static |
58 DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() { | 59 DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() { |
59 DCHECK(g_service.Get().get()); | 60 DCHECK(g_service.Get().get()); |
60 return g_service.Get().get(); | 61 return g_service.Get().get(); |
61 } | 62 } |
62 | 63 |
63 DeferredGpuCommandService::DeferredGpuCommandService() {} | 64 DeferredGpuCommandService::DeferredGpuCommandService() |
| 65 : sync_point_manager_(new gpu::SyncPointManager(true)) {} |
64 | 66 |
65 DeferredGpuCommandService::~DeferredGpuCommandService() { | 67 DeferredGpuCommandService::~DeferredGpuCommandService() { |
66 base::AutoLock lock(tasks_lock_); | 68 base::AutoLock lock(tasks_lock_); |
67 DCHECK(tasks_.empty()); | 69 DCHECK(tasks_.empty()); |
68 } | 70 } |
69 | 71 |
70 // This method can be called on any thread. | 72 // This method can be called on any thread. |
71 // static | 73 // static |
72 void DeferredGpuCommandService::RequestProcessGL() { | 74 void DeferredGpuCommandService::RequestProcessGL() { |
73 SharedRendererState* renderer_state = | 75 SharedRendererState* renderer_state = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 146 |
145 bool DeferredGpuCommandService::UseVirtualizedGLContexts() { return true; } | 147 bool DeferredGpuCommandService::UseVirtualizedGLContexts() { return true; } |
146 | 148 |
147 scoped_refptr<gpu::gles2::ShaderTranslatorCache> | 149 scoped_refptr<gpu::gles2::ShaderTranslatorCache> |
148 DeferredGpuCommandService::shader_translator_cache() { | 150 DeferredGpuCommandService::shader_translator_cache() { |
149 if (!shader_translator_cache_.get()) | 151 if (!shader_translator_cache_.get()) |
150 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; | 152 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; |
151 return shader_translator_cache_; | 153 return shader_translator_cache_; |
152 } | 154 } |
153 | 155 |
| 156 gpu::SyncPointManager* DeferredGpuCommandService::sync_point_manager() { |
| 157 return sync_point_manager_.get(); |
| 158 } |
| 159 |
154 void DeferredGpuCommandService::RunTasks() { | 160 void DeferredGpuCommandService::RunTasks() { |
155 TRACE_EVENT0("android_webview", "DeferredGpuCommandService::RunTasks"); | 161 TRACE_EVENT0("android_webview", "DeferredGpuCommandService::RunTasks"); |
156 bool has_more_tasks; | 162 bool has_more_tasks; |
157 { | 163 { |
158 base::AutoLock lock(tasks_lock_); | 164 base::AutoLock lock(tasks_lock_); |
159 has_more_tasks = tasks_.size() > 0; | 165 has_more_tasks = tasks_.size() > 0; |
160 } | 166 } |
161 | 167 |
162 while (has_more_tasks) { | 168 while (has_more_tasks) { |
163 base::Closure task; | 169 base::Closure task; |
(...skipping 12 matching lines...) Expand all Loading... |
176 | 182 |
177 void DeferredGpuCommandService::AddRef() const { | 183 void DeferredGpuCommandService::AddRef() const { |
178 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); | 184 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); |
179 } | 185 } |
180 | 186 |
181 void DeferredGpuCommandService::Release() const { | 187 void DeferredGpuCommandService::Release() const { |
182 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); | 188 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); |
183 } | 189 } |
184 | 190 |
185 } // namespace android_webview | 191 } // namespace android_webview |
OLD | NEW |