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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
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 26fdb2d74e1a6cb19da9d0d5c70ee2ba04e98d07..38523ec103f21ff7c6ac2060400ad39779d0fafb 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);
}
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();
if (!bounds.IsEmpty())
return gfx::Rect(bounds);
@@ -201,6 +207,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.
@@ -261,9 +270,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));
}
@@ -292,7 +304,7 @@ void RenderWidgetHostViewAndroid::StartContentIntent(
gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() {
gfx::GLSurfaceHandle handle =
klobag.chromium 2012/08/22 07:01:19 We don't care about the return any more as it is s
no sievers 2012/08/22 21:17:40 This is actually not the browser-side compositor,
- DrawDelegateImpl::GetInstance()->GetDrawSurface();
+ CompositorImpl::GetInstance()->GetCompositorSurface();
if (!handle.is_null())
return handle;

Powered by Google App Engine
This is Rietveld 408576698