Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_android.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
| index d16141b25ff6c3ad5a005f1253f50968229dae01..bf765cec642c029b5fdd6627d6feccbf8805e39c 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
| @@ -9,12 +9,13 @@ |
| #include "base/message_loop.h" |
| #include "base/utf_string_conversions.h" |
| #include "content/browser/android/content_view_core_impl.h" |
| -#include "content/browser/android/draw_delegate_impl.h" |
| #include "content/browser/gpu/gpu_surface_tracker.h" |
| +#include "content/browser/renderer_host/compositor_impl_android.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| #include "content/common/android/device_info.h" |
| #include "content/common/gpu/gpu_messages.h" |
| #include "content/common/view_messages.h" |
| +#include "content/public/browser/render_view_host.h" |
| namespace content { |
| @@ -26,12 +27,16 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| // ContentViewCore. It being NULL means that it is not attached to the |
| // View system yet, so we treat it as hidden. |
| is_hidden_(!content_view_core), |
| - content_view_core_(content_view_core) { |
| + content_view_core_(content_view_core), |
| + texture_layer_(WebKit::WebExternalTextureLayer::create()) { |
| host_->SetView(this); |
| // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell |
| // RenderWidgetHost to hide. |
| if (is_hidden_) |
| host_->WasHidden(); |
| + texture_layer_.setDrawsContent(!is_hidden_); |
| + RenderViewHost* view_host = RenderViewHost::From(host_); |
| + view_host->GetDelegate()->AttachLayer(texture_layer_); |
| } |
| RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| @@ -85,6 +90,7 @@ void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { |
| requested_size_ = gfx::Size(size.width(), size.height()); |
| host_->WasResized(); |
| } |
| + texture_layer_.setBounds(size); |
| } |
| void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
| @@ -141,11 +147,11 @@ bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const { |
| } |
| void RenderWidgetHostViewAndroid::Show() { |
| - // nothing to do |
| + texture_layer_.setDrawsContent(true); |
|
klobag.chromium
2012/08/23 02:08:12
If we always call Show after the constructor, shou
no sievers
2012/08/27 18:07:02
Eventually we should do that. But it would break C
klobag.chromium
2012/08/27 23:44:55
Hmm, this can break instance where it doesn't have
|
| } |
| void RenderWidgetHostViewAndroid::Hide() { |
| - // nothing to do |
| + texture_layer_.setDrawsContent(false); |
| } |
| bool RenderWidgetHostViewAndroid::IsShowing() { |
| @@ -153,7 +159,7 @@ bool RenderWidgetHostViewAndroid::IsShowing() { |
| } |
| gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
| - gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds(); |
| + gfx::Size bounds = CompositorImpl::GetInstance()->GetWindowBounds(); |
|
klobag.chromium
2012/08/23 02:08:12
I am not convinced that compositor should provides
no sievers
2012/08/27 18:07:02
Done.
|
| if (!bounds.IsEmpty()) |
| return gfx::Rect(bounds); |
| @@ -196,6 +202,9 @@ void RenderWidgetHostViewAndroid::RenderViewGone( |
| } |
| void RenderWidgetHostViewAndroid::Destroy() { |
| + RenderViewHost* view_host = RenderViewHost::From(host_); |
| + view_host->GetDelegate()->RemoveLayer(texture_layer_); |
| + |
| content_view_core_ = NULL; |
| // The RenderWidgetHost's destruction led here, so don't call it. |
| @@ -256,9 +265,12 @@ void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { |
| void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( |
| const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| int gpu_host_id) { |
| - DrawDelegateImpl::GetInstance()->OnSurfaceUpdated( |
| - params.surface_handle, |
| - this, |
| + texture_layer_.setTextureId(params.surface_handle); |
| + texture_layer_.invalidate(); |
| + // TODO(sievers): The view and layer should get sized proactively. |
| + if (((gfx::Size)texture_layer_.bounds()).IsEmpty()) |
| + texture_layer_.setBounds(CompositorImpl::GetInstance()->GetWindowBounds()); |
| + CompositorImpl::GetInstance()->SurfaceUpdated( |
| base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent, |
| params.route_id, gpu_host_id)); |
| } |
| @@ -287,7 +299,7 @@ void RenderWidgetHostViewAndroid::StartContentIntent( |
| gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { |
| gfx::GLSurfaceHandle handle = |
|
klobag.chromium
2012/08/23 02:08:12
Still not clear for this. You are using the browse
no sievers
2012/08/27 18:07:02
The handle is for the renderer-side compositor. Bu
klobag.chromium
2012/08/27 23:44:55
I think this deserves a comment.
On 2012/08/27 18
|
| - DrawDelegateImpl::GetInstance()->GetDrawSurface(); |
| + CompositorImpl::GetInstance()->GetCompositorSurface(); |
| if (!handle.is_null()) |
| return handle; |