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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 10828356: Very basic Android browser-side compositing support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/browser/android/content_view_core_impl.h" 11 #include "content/browser/android/content_view_core_impl.h"
12 #include "content/browser/android/draw_delegate_impl.h" 12 #include "content/browser/android/draw_delegate_impl.h"
13 #include "content/browser/gpu/gpu_surface_tracker.h" 13 #include "content/browser/gpu/gpu_surface_tracker.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 14 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/common/android/device_info.h" 15 #include "content/common/android/device_info.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 #include "content/public/browser/render_view_host.h"
jam 2012/08/30 18:51:54 it's a layering violation of RenderWidgetHost talk
no sievers 2012/08/31 01:31:11 Done.
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
18 20
19 namespace content { 21 namespace content {
20 22
21 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 23 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
22 RenderWidgetHostImpl* widget_host, 24 RenderWidgetHostImpl* widget_host,
23 ContentViewCoreImpl* content_view_core) 25 ContentViewCoreImpl* content_view_core)
24 : host_(widget_host), 26 : host_(widget_host),
25 // ContentViewCoreImpl represents the native side of the Java 27 // ContentViewCoreImpl represents the native side of the Java
26 // ContentViewCore. It being NULL means that it is not attached to the 28 // ContentViewCore. It being NULL means that it is not attached to the
27 // View system yet, so we treat it as hidden. 29 // View system yet, so we treat it as hidden.
28 is_hidden_(!content_view_core), 30 is_hidden_(!content_view_core),
29 content_view_core_(content_view_core) { 31 content_view_core_(content_view_core),
32 texture_layer_(WebKit::WebExternalTextureLayer::create()) {
30 host_->SetView(this); 33 host_->SetView(this);
31 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell 34 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
32 // RenderWidgetHost to hide. 35 // RenderWidgetHost to hide.
33 if (is_hidden_) 36 if (is_hidden_)
34 host_->WasHidden(); 37 host_->WasHidden();
38 texture_layer_->layer()->setDrawsContent(!is_hidden_);
39 RenderViewHost* view_host = RenderViewHost::From(host_);
40 view_host->GetDelegate()->AttachLayer(texture_layer_->layer());
35 } 41 }
36 42
37 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 43 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
38 } 44 }
39 45
40 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { 46 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) {
41 NOTIMPLEMENTED(); 47 NOTIMPLEMENTED();
42 } 48 }
43 49
44 void RenderWidgetHostViewAndroid::InitAsPopup( 50 void RenderWidgetHostViewAndroid::InitAsPopup(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 host_->WasHidden(); 84 host_->WasHidden();
79 } 85 }
80 86
81 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { 87 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
82 // Update the size of the RWH. 88 // Update the size of the RWH.
83 if (requested_size_.width() != size.width() || 89 if (requested_size_.width() != size.width() ||
84 requested_size_.height() != size.height()) { 90 requested_size_.height() != size.height()) {
85 requested_size_ = gfx::Size(size.width(), size.height()); 91 requested_size_ = gfx::Size(size.width(), size.height());
86 host_->WasResized(); 92 host_->WasResized();
87 } 93 }
94 texture_layer_->layer()->setBounds(size);
88 } 95 }
89 96
90 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 97 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
91 if (rect.origin().x() || rect.origin().y()) { 98 if (rect.origin().x() || rect.origin().y()) {
92 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)"; 99 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)";
93 } 100 }
94 SetSize(rect.size()); 101 SetSize(rect.size());
95 } 102 }
96 103
97 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { 104 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 141
135 return content_view_core_->HasFocus(); 142 return content_view_core_->HasFocus();
136 } 143 }
137 144
138 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const { 145 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const {
139 NOTIMPLEMENTED(); 146 NOTIMPLEMENTED();
140 return false; 147 return false;
141 } 148 }
142 149
143 void RenderWidgetHostViewAndroid::Show() { 150 void RenderWidgetHostViewAndroid::Show() {
144 // nothing to do 151 texture_layer_->layer()->setDrawsContent(true);
145 } 152 }
146 153
147 void RenderWidgetHostViewAndroid::Hide() { 154 void RenderWidgetHostViewAndroid::Hide() {
148 // nothing to do 155 texture_layer_->layer()->setDrawsContent(false);
149 } 156 }
150 157
151 bool RenderWidgetHostViewAndroid::IsShowing() { 158 bool RenderWidgetHostViewAndroid::IsShowing() {
152 return !is_hidden_; 159 return !is_hidden_;
153 } 160 }
154 161
155 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { 162 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
156 gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds(); 163 gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds();
157 if (!bounds.IsEmpty()) 164 if (!bounds.IsEmpty())
158 return gfx::Rect(bounds); 165 return gfx::Rect(bounds);
(...skipping 30 matching lines...) Expand all
189 const std::vector<gfx::Rect>& copy_rects) { 196 const std::vector<gfx::Rect>& copy_rects) {
190 NOTIMPLEMENTED(); 197 NOTIMPLEMENTED();
191 } 198 }
192 199
193 void RenderWidgetHostViewAndroid::RenderViewGone( 200 void RenderWidgetHostViewAndroid::RenderViewGone(
194 base::TerminationStatus status, int error_code) { 201 base::TerminationStatus status, int error_code) {
195 Destroy(); 202 Destroy();
196 } 203 }
197 204
198 void RenderWidgetHostViewAndroid::Destroy() { 205 void RenderWidgetHostViewAndroid::Destroy() {
206 RenderViewHost* view_host = RenderViewHost::From(host_);
207 view_host->GetDelegate()->RemoveLayer(texture_layer_->layer());
208
199 content_view_core_ = NULL; 209 content_view_core_ = NULL;
200 210
201 // The RenderWidgetHost's destruction led here, so don't call it. 211 // The RenderWidgetHost's destruction led here, so don't call it.
202 host_ = NULL; 212 host_ = NULL;
203 213
204 delete this; 214 delete this;
205 } 215 }
206 216
207 void RenderWidgetHostViewAndroid::SetTooltipText( 217 void RenderWidgetHostViewAndroid::SetTooltipText(
208 const string16& tooltip_text) { 218 const string16& tooltip_text) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 NOTIMPLEMENTED(); 259 NOTIMPLEMENTED();
250 callback.Run(false); 260 callback.Run(false);
251 } 261 }
252 262
253 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { 263 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
254 } 264 }
255 265
256 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( 266 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
257 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 267 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
258 int gpu_host_id) { 268 int gpu_host_id) {
269 texture_layer_->setTextureId(params.surface_handle);
270 texture_layer_->layer()->invalidate();
271 // TODO(sievers): The view and layer should get sized proactively.
272 if (((gfx::Size)texture_layer_->layer()->bounds()).IsEmpty())
273 texture_layer_->layer()->setBounds(
274 DrawDelegateImpl::GetInstance()->GetBounds());
259 DrawDelegateImpl::GetInstance()->OnSurfaceUpdated( 275 DrawDelegateImpl::GetInstance()->OnSurfaceUpdated(
260 params.surface_handle, 276 params.surface_handle,
261 this, 277 this,
262 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent, 278 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent,
263 params.route_id, gpu_host_id)); 279 params.route_id, gpu_host_id));
264 } 280 }
265 281
266 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( 282 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
267 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 283 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
268 int gpu_host_id) { 284 int gpu_host_id) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // RenderWidgetHostView, public: 401 // RenderWidgetHostView, public:
386 402
387 // static 403 // static
388 RenderWidgetHostView* 404 RenderWidgetHostView*
389 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 405 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
390 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 406 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
391 return new RenderWidgetHostViewAndroid(rwhi, NULL); 407 return new RenderWidgetHostViewAndroid(rwhi, NULL);
392 } 408 }
393 409
394 } // namespace content 410 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698