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/compositor_proxy.h" |
7 #include "android_webview/browser/gl_view_renderer_manager.h" | 8 #include "android_webview/browser/gl_view_renderer_manager.h" |
8 #include "android_webview/browser/shared_renderer_state.h" | |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.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 | 14 |
15 namespace android_webview { | 15 namespace android_webview { |
16 | 16 |
17 namespace { | 17 namespace { |
18 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > | 18 base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DeferredGpuCommandService::DeferredGpuCommandService() {} | 63 DeferredGpuCommandService::DeferredGpuCommandService() {} |
64 | 64 |
65 DeferredGpuCommandService::~DeferredGpuCommandService() { | 65 DeferredGpuCommandService::~DeferredGpuCommandService() { |
66 base::AutoLock lock(tasks_lock_); | 66 base::AutoLock lock(tasks_lock_); |
67 DCHECK(tasks_.empty()); | 67 DCHECK(tasks_.empty()); |
68 } | 68 } |
69 | 69 |
70 // This method can be called on any thread. | 70 // This method can be called on any thread. |
71 // static | 71 // static |
72 void DeferredGpuCommandService::RequestProcessGL() { | 72 void DeferredGpuCommandService::RequestProcessGL() { |
73 SharedRendererState* renderer_state = | 73 CompositorProxy* compositor_proxy = |
74 GLViewRendererManager::GetInstance()->GetMostRecentlyDrawn(); | 74 GLViewRendererManager::GetInstance()->GetMostRecentlyDrawn(); |
75 if (!renderer_state) { | 75 if (!compositor_proxy) { |
76 LOG(ERROR) << "No hardware renderer. Deadlock likely"; | 76 LOG(ERROR) << "No hardware renderer. Deadlock likely"; |
77 return; | 77 return; |
78 } | 78 } |
79 renderer_state->ClientRequestDrawGL(); | 79 compositor_proxy->ClientRequestDrawGL(); |
80 } | 80 } |
81 | 81 |
82 // Called from different threads! | 82 // Called from different threads! |
83 void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) { | 83 void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) { |
84 { | 84 { |
85 base::AutoLock lock(tasks_lock_); | 85 base::AutoLock lock(tasks_lock_); |
86 tasks_.push(task); | 86 tasks_.push(task); |
87 } | 87 } |
88 if (ScopedAllowGL::IsAllowed()) { | 88 if (ScopedAllowGL::IsAllowed()) { |
89 RunTasks(); | 89 RunTasks(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 void DeferredGpuCommandService::AddRef() const { | 176 void DeferredGpuCommandService::AddRef() const { |
177 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); | 177 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); |
178 } | 178 } |
179 | 179 |
180 void DeferredGpuCommandService::Release() const { | 180 void DeferredGpuCommandService::Release() const { |
181 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); | 181 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); |
182 } | 182 } |
183 | 183 |
184 } // namespace android_webview | 184 } // namespace android_webview |
OLD | NEW |