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

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: ifdef Attach/RemoveLayer API 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 "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( 22 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
22 RenderWidgetHostImpl* widget_host, 23 RenderWidgetHostImpl* widget_host,
23 ContentViewCoreImpl* content_view_core) 24 ContentViewCoreImpl* content_view_core)
24 : host_(widget_host), 25 : host_(widget_host),
25 // ContentViewCoreImpl represents the native side of the Java 26 // ContentViewCoreImpl represents the native side of the Java
26 // ContentViewCore. It being NULL means that it is not attached to the 27 // ContentViewCore. It being NULL means that it is not attached to the
27 // View system yet, so we treat it as hidden. 28 // View system yet, so we treat it as hidden.
28 is_hidden_(!content_view_core), 29 is_hidden_(!content_view_core),
29 content_view_core_(content_view_core) { 30 content_view_core_(content_view_core),
31 texture_layer_(WebKit::WebExternalTextureLayer::create()) {
30 host_->SetView(this); 32 host_->SetView(this);
31 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell 33 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
32 // RenderWidgetHost to hide. 34 // RenderWidgetHost to hide.
33 if (is_hidden_) 35 if (is_hidden_)
34 host_->WasHidden(); 36 host_->WasHidden();
37 texture_layer_->layer()->setDrawsContent(!is_hidden_);
38 host_->AttachLayer(texture_layer_->layer());
35 } 39 }
36 40
37 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 41 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
38 } 42 }
39 43
40 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { 44 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) {
41 NOTIMPLEMENTED(); 45 NOTIMPLEMENTED();
42 } 46 }
43 47
44 void RenderWidgetHostViewAndroid::InitAsPopup( 48 void RenderWidgetHostViewAndroid::InitAsPopup(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 host_->WasHidden(); 82 host_->WasHidden();
79 } 83 }
80 84
81 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { 85 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
82 // Update the size of the RWH. 86 // Update the size of the RWH.
83 if (requested_size_.width() != size.width() || 87 if (requested_size_.width() != size.width() ||
84 requested_size_.height() != size.height()) { 88 requested_size_.height() != size.height()) {
85 requested_size_ = gfx::Size(size.width(), size.height()); 89 requested_size_ = gfx::Size(size.width(), size.height());
86 host_->WasResized(); 90 host_->WasResized();
87 } 91 }
92 texture_layer_->layer()->setBounds(size);
88 } 93 }
89 94
90 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { 95 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
91 if (rect.origin().x() || rect.origin().y()) { 96 if (rect.origin().x() || rect.origin().y()) {
92 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)"; 97 VLOG(0) << "SetBounds not implemented for (x,y)!=(0,0)";
93 } 98 }
94 SetSize(rect.size()); 99 SetSize(rect.size());
95 } 100 }
96 101
97 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { 102 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 139
135 return content_view_core_->HasFocus(); 140 return content_view_core_->HasFocus();
136 } 141 }
137 142
138 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const { 143 bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const {
139 NOTIMPLEMENTED(); 144 NOTIMPLEMENTED();
140 return false; 145 return false;
141 } 146 }
142 147
143 void RenderWidgetHostViewAndroid::Show() { 148 void RenderWidgetHostViewAndroid::Show() {
144 // nothing to do 149 texture_layer_->layer()->setDrawsContent(true);
145 } 150 }
146 151
147 void RenderWidgetHostViewAndroid::Hide() { 152 void RenderWidgetHostViewAndroid::Hide() {
148 // nothing to do 153 texture_layer_->layer()->setDrawsContent(false);
149 } 154 }
150 155
151 bool RenderWidgetHostViewAndroid::IsShowing() { 156 bool RenderWidgetHostViewAndroid::IsShowing() {
152 return !is_hidden_; 157 return !is_hidden_;
153 } 158 }
154 159
155 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { 160 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
156 gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds(); 161 gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds();
157 if (!bounds.IsEmpty()) 162 if (!bounds.IsEmpty())
158 return gfx::Rect(bounds); 163 return gfx::Rect(bounds);
(...skipping 30 matching lines...) Expand all
189 const std::vector<gfx::Rect>& copy_rects) { 194 const std::vector<gfx::Rect>& copy_rects) {
190 NOTIMPLEMENTED(); 195 NOTIMPLEMENTED();
191 } 196 }
192 197
193 void RenderWidgetHostViewAndroid::RenderViewGone( 198 void RenderWidgetHostViewAndroid::RenderViewGone(
194 base::TerminationStatus status, int error_code) { 199 base::TerminationStatus status, int error_code) {
195 Destroy(); 200 Destroy();
196 } 201 }
197 202
198 void RenderWidgetHostViewAndroid::Destroy() { 203 void RenderWidgetHostViewAndroid::Destroy() {
204 host_->RemoveLayer(texture_layer_->layer());
205
199 content_view_core_ = NULL; 206 content_view_core_ = NULL;
200 207
201 // The RenderWidgetHost's destruction led here, so don't call it. 208 // The RenderWidgetHost's destruction led here, so don't call it.
202 host_ = NULL; 209 host_ = NULL;
203 210
204 delete this; 211 delete this;
205 } 212 }
206 213
207 void RenderWidgetHostViewAndroid::SetTooltipText( 214 void RenderWidgetHostViewAndroid::SetTooltipText(
208 const string16& tooltip_text) { 215 const string16& tooltip_text) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 NOTIMPLEMENTED(); 256 NOTIMPLEMENTED();
250 callback.Run(false); 257 callback.Run(false);
251 } 258 }
252 259
253 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { 260 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
254 } 261 }
255 262
256 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( 263 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
257 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 264 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
258 int gpu_host_id) { 265 int gpu_host_id) {
266 texture_layer_->setTextureId(params.surface_handle);
267 texture_layer_->layer()->invalidate();
268 // TODO(sievers): The view and layer should get sized proactively.
269 if (((gfx::Size)texture_layer_->layer()->bounds()).IsEmpty())
270 texture_layer_->layer()->setBounds(
271 DrawDelegateImpl::GetInstance()->GetBounds());
259 DrawDelegateImpl::GetInstance()->OnSurfaceUpdated( 272 DrawDelegateImpl::GetInstance()->OnSurfaceUpdated(
260 params.surface_handle, 273 params.surface_handle,
261 this, 274 this,
262 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent, 275 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent,
263 params.route_id, gpu_host_id)); 276 params.route_id, gpu_host_id));
264 } 277 }
265 278
266 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( 279 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
267 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 280 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
268 int gpu_host_id) { 281 int gpu_host_id) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // RenderWidgetHostView, public: 398 // RenderWidgetHostView, public:
386 399
387 // static 400 // static
388 RenderWidgetHostView* 401 RenderWidgetHostView*
389 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 402 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
390 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 403 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
391 return new RenderWidgetHostViewAndroid(rwhi, NULL); 404 return new RenderWidgetHostViewAndroid(rwhi, NULL);
392 } 405 }
393 406
394 } // namespace content 407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698