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

Side by Side Diff: android_webview/browser/shared_renderer_state.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/shared_renderer_state.h" 5 #include "android_webview/browser/shared_renderer_state.h"
6 6
7 #include "android_webview/browser/browser_view_renderer_client.h" 7 #include "android_webview/browser/browser_view_renderer_client.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 10
11 namespace android_webview { 11 namespace android_webview {
12 12
13 DrawGLInput::DrawGLInput() : frame_id(0), width(0), height(0) {} 13 DrawGLInput::DrawGLInput() : width(0), height(0) {
14 }
14 15
15 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {} 16 DrawGLInput::~DrawGLInput() {
17 }
18
19 DrawGLResult::DrawGLResult() : clip_contains_visible_rect(false) {
20 }
16 21
17 SharedRendererState::SharedRendererState( 22 SharedRendererState::SharedRendererState(
18 scoped_refptr<base::MessageLoopProxy> ui_loop, 23 scoped_refptr<base::MessageLoopProxy> ui_loop,
19 BrowserViewRendererClient* client) 24 BrowserViewRendererClient* client)
20 : ui_loop_(ui_loop), 25 : ui_loop_(ui_loop),
21 client_on_ui_(client), 26 client_on_ui_(client),
22 weak_factory_on_ui_thread_(this), 27 weak_factory_on_ui_thread_(this),
23 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), 28 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()),
24 compositor_(NULL), 29 compositor_(NULL),
25 memory_policy_dirty_(false), 30 memory_policy_dirty_(false),
26 hardware_initialized_(false) { 31 hardware_initialized_(false),
32 share_context_(NULL) {
27 DCHECK(ui_loop_->BelongsToCurrentThread()); 33 DCHECK(ui_loop_->BelongsToCurrentThread());
28 DCHECK(client_on_ui_); 34 DCHECK(client_on_ui_);
29 } 35 }
30 36
31 SharedRendererState::~SharedRendererState() {} 37 SharedRendererState::~SharedRendererState() {}
32 38
33 void SharedRendererState::ClientRequestDrawGL() { 39 void SharedRendererState::ClientRequestDrawGL() {
34 if (ui_loop_->BelongsToCurrentThread()) { 40 if (ui_loop_->BelongsToCurrentThread()) {
35 ClientRequestDrawGLOnUIThread(); 41 ClientRequestDrawGLOnUIThread();
36 } else { 42 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 memory_policy_dirty_ = true; 75 memory_policy_dirty_ = true;
70 } 76 }
71 } 77 }
72 78
73 content::SynchronousCompositorMemoryPolicy 79 content::SynchronousCompositorMemoryPolicy
74 SharedRendererState::GetMemoryPolicy() const { 80 SharedRendererState::GetMemoryPolicy() const {
75 base::AutoLock lock(lock_); 81 base::AutoLock lock(lock_);
76 return memory_policy_; 82 return memory_policy_;
77 } 83 }
78 84
79 void SharedRendererState::SetDrawGLInput(const DrawGLInput& input) { 85 void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) {
80 base::AutoLock lock(lock_); 86 base::AutoLock lock(lock_);
81 draw_gl_input_ = input; 87 DCHECK(!draw_gl_input_.get());
88 draw_gl_input_ = input.Pass();
82 } 89 }
83 90
84 DrawGLInput SharedRendererState::GetDrawGLInput() const { 91 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() {
85 base::AutoLock lock(lock_); 92 base::AutoLock lock(lock_);
86 return draw_gl_input_; 93 return draw_gl_input_.Pass();
87 } 94 }
88 95
89 void SharedRendererState::ClearClosureQueue() { 96 void SharedRendererState::ClearClosureQueue() {
90 base::AutoLock lock(lock_); 97 base::AutoLock lock(lock_);
91 std::queue<base::Closure> empty; 98 std::queue<base::Closure> empty;
92 std::swap(closure_queue_, empty); 99 std::swap(closure_queue_, empty);
93 } 100 }
94 101
95 void SharedRendererState::AppendClosure(const base::Closure& closure) { 102 void SharedRendererState::AppendClosure(const base::Closure& closure) {
96 base::AutoLock lock(lock_); 103 base::AutoLock lock(lock_);
(...skipping 15 matching lines...) Expand all
112 void SharedRendererState::SetHardwareInitialized(bool initialized) { 119 void SharedRendererState::SetHardwareInitialized(bool initialized) {
113 base::AutoLock lock(lock_); 120 base::AutoLock lock(lock_);
114 hardware_initialized_ = initialized; 121 hardware_initialized_ = initialized;
115 } 122 }
116 123
117 bool SharedRendererState::IsHardwareInitialized() const { 124 bool SharedRendererState::IsHardwareInitialized() const {
118 base::AutoLock lock(lock_); 125 base::AutoLock lock(lock_);
119 return hardware_initialized_; 126 return hardware_initialized_;
120 } 127 }
121 128
129 void SharedRendererState::SetSharedContext(gpu::GLInProcessContext* context) {
130 base::AutoLock lock(lock_);
131 DCHECK(!share_context_ || !context);
132 share_context_ = context;
133 }
134
135 gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const {
136 base::AutoLock lock(lock_);
137 DCHECK(share_context_);
138 return share_context_;
139 }
140
122 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) { 141 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) {
123 base::AutoLock lock(lock_); 142 base::AutoLock lock(lock_);
124 memory_policy_dirty_ = is_dirty; 143 memory_policy_dirty_ = is_dirty;
125 } 144 }
126 145
127 bool SharedRendererState::IsMemoryPolicyDirty() const { 146 bool SharedRendererState::IsMemoryPolicyDirty() const {
128 base::AutoLock lock(lock_); 147 base::AutoLock lock(lock_);
129 return memory_policy_dirty_; 148 return memory_policy_dirty_;
130 } 149 }
131 150
151 void SharedRendererState::ReturnResources(
152 const cc::TransferableResourceArray& input) {
153 base::AutoLock lock(lock_);
154 cc::TransferableResource::ReturnResources(input, &returned_resources_);
155 }
156
157 void SharedRendererState::InsertReturnedResources(
158 const cc::ReturnedResourceArray& resources) {
159 base::AutoLock lock(lock_);
160 returned_resources_.insert(
161 returned_resources_.end(), resources.begin(), resources.end());
162 }
163
164 void SharedRendererState::SwapReturnedResources(
165 cc::ReturnedResourceArray* resources) {
166 base::AutoLock lock(lock_);
167 resources->swap(returned_resources_);
168 }
169
170 bool SharedRendererState::ReturnedResourcesEmpty() const {
171 base::AutoLock lock(lock_);
172 return returned_resources_.empty();
173 }
174
132 } // namespace android_webview 175 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698