Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: android_webview/browser/deferred_gpu_command_service.cc

Issue 287993004: [Android WebView] Implement Ubercomp for Render Thread support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/public/browser/android/synchronous_compositor.h" 9 #include "content/public/browser/android/synchronous_compositor.h"
10 #include "gpu/command_buffer/service/shader_translator_cache.h" 10 #include "gpu/command_buffer/service/shader_translator_cache.h"
(...skipping 23 matching lines...) Expand all
34 ScopedAllowGL::~ScopedAllowGL() { allow_gl.Get().Set(false); } 34 ScopedAllowGL::~ScopedAllowGL() { allow_gl.Get().Set(false); }
35 35
36 // static 36 // static
37 void DeferredGpuCommandService::SetInstance() { 37 void DeferredGpuCommandService::SetInstance() {
38 if (!g_service.Get()) { 38 if (!g_service.Get()) {
39 g_service.Get() = new DeferredGpuCommandService; 39 g_service.Get() = new DeferredGpuCommandService;
40 content::SynchronousCompositor::SetGpuService(g_service.Get()); 40 content::SynchronousCompositor::SetGpuService(g_service.Get());
41 } 41 }
42 } 42 }
43 43
44 // static
45 DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() {
46 DCHECK(g_service.Get().get());
47 return g_service.Get().get();
48 }
49
44 DeferredGpuCommandService::DeferredGpuCommandService() {} 50 DeferredGpuCommandService::DeferredGpuCommandService() {}
45 51
46 DeferredGpuCommandService::~DeferredGpuCommandService() { 52 DeferredGpuCommandService::~DeferredGpuCommandService() {
47 base::AutoLock lock(tasks_lock_); 53 base::AutoLock lock(tasks_lock_);
48 DCHECK(tasks_.empty()); 54 DCHECK(tasks_.empty());
49 } 55 }
50 56
57 // This method can be called on any thread.
51 // static 58 // static
52 void DeferredGpuCommandService::RequestProcessGLOnUIThread() { 59 void DeferredGpuCommandService::RequestProcessGL() {
53 SharedRendererState* renderer_state = 60 SharedRendererState* renderer_state =
54 GLViewRendererManager::GetInstance()->GetMostRecentlyDrawn(); 61 GLViewRendererManager::GetInstance()->GetMostRecentlyDrawn();
55 if (!renderer_state) { 62 if (!renderer_state) {
56 LOG(ERROR) << "No hardware renderer. Deadlock likely"; 63 LOG(ERROR) << "No hardware renderer. Deadlock likely";
57 return; 64 return;
58 } 65 }
59 renderer_state->ClientRequestDrawGL(); 66 renderer_state->ClientRequestDrawGL();
60 } 67 }
61 68
62 // Called from different threads! 69 // Called from different threads!
63 void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) { 70 void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) {
64 { 71 {
65 base::AutoLock lock(tasks_lock_); 72 base::AutoLock lock(tasks_lock_);
66 tasks_.push(task); 73 tasks_.push(task);
67 } 74 }
68 if (ScopedAllowGL::IsAllowed()) { 75 if (ScopedAllowGL::IsAllowed()) {
69 RunTasks(); 76 RunTasks();
70 } else { 77 } else {
71 RequestProcessGLOnUIThread(); 78 // TODO(boliu): Improve this to avoid PostTask storm.
79 RequestProcessGL();
72 } 80 }
73 } 81 }
74 82
75 void DeferredGpuCommandService::ScheduleIdleWork( 83 void DeferredGpuCommandService::ScheduleIdleWork(
76 const base::Closure& callback) { 84 const base::Closure& callback) {
77 // TODO(sievers): Should this do anything? 85 // TODO(sievers): Should this do anything?
78 } 86 }
79 87
80 bool DeferredGpuCommandService::UseVirtualizedGLContexts() { return true; } 88 bool DeferredGpuCommandService::UseVirtualizedGLContexts() { return true; }
81 89
(...skipping 28 matching lines...) Expand all
110 118
111 void DeferredGpuCommandService::AddRef() const { 119 void DeferredGpuCommandService::AddRef() const {
112 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); 120 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef();
113 } 121 }
114 122
115 void DeferredGpuCommandService::Release() const { 123 void DeferredGpuCommandService::Release() const {
116 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); 124 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release();
117 } 125 }
118 126
119 } // namespace android_webview 127 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698