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

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

Issue 331103002: aw: Remove legacy rendering path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 6 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() : width(0), height(0) { 13 DrawGLInput::DrawGLInput() : width(0), height(0) {
14 } 14 }
15 15
16 DrawGLInput::~DrawGLInput() { 16 DrawGLInput::~DrawGLInput() {
17 } 17 }
18 18
19 DrawGLResult::DrawGLResult() : clip_contains_visible_rect(false) {
20 }
21
22 SharedRendererState::SharedRendererState( 19 SharedRendererState::SharedRendererState(
23 scoped_refptr<base::MessageLoopProxy> ui_loop, 20 scoped_refptr<base::MessageLoopProxy> ui_loop,
24 BrowserViewRendererClient* client) 21 BrowserViewRendererClient* client)
25 : ui_loop_(ui_loop), 22 : ui_loop_(ui_loop),
26 client_on_ui_(client), 23 client_on_ui_(client),
27 weak_factory_on_ui_thread_(this), 24 weak_factory_on_ui_thread_(this),
28 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), 25 ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()),
29 compositor_(NULL),
30 memory_policy_dirty_(false),
31 hardware_allowed_(false), 26 hardware_allowed_(false),
32 hardware_initialized_(false), 27 hardware_initialized_(false),
33 share_context_(NULL) { 28 share_context_(NULL) {
34 DCHECK(ui_loop_->BelongsToCurrentThread()); 29 DCHECK(ui_loop_->BelongsToCurrentThread());
35 DCHECK(client_on_ui_); 30 DCHECK(client_on_ui_);
36 } 31 }
37 32
38 SharedRendererState::~SharedRendererState() {} 33 SharedRendererState::~SharedRendererState() {}
39 34
40 void SharedRendererState::ClientRequestDrawGL() { 35 void SharedRendererState::ClientRequestDrawGL() {
41 if (ui_loop_->BelongsToCurrentThread()) { 36 if (ui_loop_->BelongsToCurrentThread()) {
42 ClientRequestDrawGLOnUIThread(); 37 ClientRequestDrawGLOnUIThread();
43 } else { 38 } else {
44 ui_loop_->PostTask( 39 ui_loop_->PostTask(
45 FROM_HERE, 40 FROM_HERE,
46 base::Bind(&SharedRendererState::ClientRequestDrawGLOnUIThread, 41 base::Bind(&SharedRendererState::ClientRequestDrawGLOnUIThread,
47 ui_thread_weak_ptr_)); 42 ui_thread_weak_ptr_));
48 } 43 }
49 } 44 }
50 45
51 void SharedRendererState::ClientRequestDrawGLOnUIThread() { 46 void SharedRendererState::ClientRequestDrawGLOnUIThread() {
52 DCHECK(ui_loop_->BelongsToCurrentThread()); 47 DCHECK(ui_loop_->BelongsToCurrentThread());
53 if (!client_on_ui_->RequestDrawGL(NULL, false)) { 48 if (!client_on_ui_->RequestDrawGL(NULL, false)) {
54 LOG(ERROR) << "Failed to request GL process. Deadlock likely"; 49 LOG(ERROR) << "Failed to request GL process. Deadlock likely";
55 } 50 }
56 } 51 }
57 52
58 void SharedRendererState::SetCompositorOnUiThread(
59 content::SynchronousCompositor* compositor) {
60 base::AutoLock lock(lock_);
61 DCHECK(ui_loop_->BelongsToCurrentThread());
62 compositor_ = compositor;
63 }
64
65 content::SynchronousCompositor* SharedRendererState::GetCompositor() {
66 base::AutoLock lock(lock_);
67 DCHECK(compositor_);
68 return compositor_;
69 }
70
71 void SharedRendererState::SetMemoryPolicy(
72 const content::SynchronousCompositorMemoryPolicy new_policy) {
73 base::AutoLock lock(lock_);
74 if (memory_policy_ != new_policy) {
75 memory_policy_ = new_policy;
76 memory_policy_dirty_ = true;
77 }
78 }
79
80 content::SynchronousCompositorMemoryPolicy
81 SharedRendererState::GetMemoryPolicy() const {
82 base::AutoLock lock(lock_);
83 return memory_policy_;
84 }
85
86 void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) { 53 void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) {
87 base::AutoLock lock(lock_); 54 base::AutoLock lock(lock_);
88 DCHECK(!draw_gl_input_.get()); 55 DCHECK(!draw_gl_input_.get());
89 draw_gl_input_ = input.Pass(); 56 draw_gl_input_ = input.Pass();
90 } 57 }
91 58
92 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() { 59 scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() {
93 base::AutoLock lock(lock_); 60 base::AutoLock lock(lock_);
94 return draw_gl_input_.Pass(); 61 return draw_gl_input_.Pass();
95 } 62 }
(...skipping 23 matching lines...) Expand all
119 DCHECK(!share_context_ || !context); 86 DCHECK(!share_context_ || !context);
120 share_context_ = context; 87 share_context_ = context;
121 } 88 }
122 89
123 gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const { 90 gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const {
124 base::AutoLock lock(lock_); 91 base::AutoLock lock(lock_);
125 DCHECK(share_context_); 92 DCHECK(share_context_);
126 return share_context_; 93 return share_context_;
127 } 94 }
128 95
129 void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) {
130 base::AutoLock lock(lock_);
131 memory_policy_dirty_ = is_dirty;
132 }
133
134 bool SharedRendererState::IsMemoryPolicyDirty() const {
135 base::AutoLock lock(lock_);
136 return memory_policy_dirty_;
137 }
138
139 void SharedRendererState::ReturnResources( 96 void SharedRendererState::ReturnResources(
140 const cc::TransferableResourceArray& input) { 97 const cc::TransferableResourceArray& input) {
141 base::AutoLock lock(lock_); 98 base::AutoLock lock(lock_);
142 cc::TransferableResource::ReturnResources(input, &returned_resources_); 99 cc::TransferableResource::ReturnResources(input, &returned_resources_);
143 } 100 }
144 101
145 void SharedRendererState::InsertReturnedResources( 102 void SharedRendererState::InsertReturnedResources(
146 const cc::ReturnedResourceArray& resources) { 103 const cc::ReturnedResourceArray& resources) {
147 base::AutoLock lock(lock_); 104 base::AutoLock lock(lock_);
148 returned_resources_.insert( 105 returned_resources_.insert(
149 returned_resources_.end(), resources.begin(), resources.end()); 106 returned_resources_.end(), resources.begin(), resources.end());
150 } 107 }
151 108
152 void SharedRendererState::SwapReturnedResources( 109 void SharedRendererState::SwapReturnedResources(
153 cc::ReturnedResourceArray* resources) { 110 cc::ReturnedResourceArray* resources) {
154 base::AutoLock lock(lock_); 111 base::AutoLock lock(lock_);
155 resources->swap(returned_resources_); 112 resources->swap(returned_resources_);
156 } 113 }
157 114
158 bool SharedRendererState::ReturnedResourcesEmpty() const { 115 bool SharedRendererState::ReturnedResourcesEmpty() const {
159 base::AutoLock lock(lock_); 116 base::AutoLock lock(lock_);
160 return returned_resources_.empty(); 117 return returned_resources_.empty();
161 } 118 }
162 119
163 } // namespace android_webview 120 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698