summaryrefslogtreecommitdiffstats
path: root/android_webview/browser
diff options
context:
space:
mode:
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/browser_view_renderer.cc33
-rw-r--r--android_webview/browser/browser_view_renderer.h7
-rw-r--r--android_webview/browser/browser_view_renderer_client.h3
-rw-r--r--android_webview/browser/hardware_renderer.cc18
-rw-r--r--android_webview/browser/hardware_renderer.h3
-rw-r--r--android_webview/browser/parent_compositor_draw_constraints.cc29
-rw-r--r--android_webview/browser/parent_compositor_draw_constraints.h27
-rw-r--r--android_webview/browser/parent_output_surface.cc3
-rw-r--r--android_webview/browser/shared_renderer_state.cc25
-rw-r--r--android_webview/browser/shared_renderer_state.h7
10 files changed, 146 insertions, 9 deletions
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index b958dae..489794c 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -259,14 +259,29 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) {
draw_gl_input->width = width_;
draw_gl_input->height = height_;
- gfx::Transform transform;
+ parent_draw_constraints_ = shared_renderer_state_->ParentDrawConstraints();
gfx::Size surface_size(width_, height_);
gfx::Rect viewport(surface_size);
- // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|.
- // See crbug.com/372073.
gfx::Rect clip = viewport;
- scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw(
- surface_size, transform, viewport, clip);
+ gfx::Transform transform_for_tile_priority =
+ parent_draw_constraints_.transform;
+
+ // If the WebView is on a layer, WebView does not know what transform is
+ // applied onto the layer so global visible rect does not make sense here.
+ // In this case, just use the surface rect for tiling.
+ gfx::Rect viewport_rect_for_tile_priority;
+ if (parent_draw_constraints_.is_layer)
+ viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect;
+ else
+ viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
+
+ scoped_ptr<cc::CompositorFrame> frame =
+ compositor_->DemandDrawHw(surface_size,
+ gfx::Transform(),
+ viewport,
+ clip,
+ viewport_rect_for_tile_priority,
+ transform_for_tile_priority);
if (!frame.get())
return false;
@@ -279,6 +294,14 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) {
return client_->RequestDrawGL(java_canvas, false);
}
+void BrowserViewRenderer::UpdateParentDrawConstraints() {
+ // Post an invalidate if the parent draw constraints are stale and there is
+ // no pending invalidate.
+ if (!parent_draw_constraints_.Equals(
+ shared_renderer_state_->ParentDrawConstraints()))
+ EnsureContinuousInvalidation(true);
+}
+
void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) {
if (!input.get())
return;
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h
index 338b31d..810fb81 100644
--- a/android_webview/browser/browser_view_renderer.h
+++ b/android_webview/browser/browser_view_renderer.h
@@ -7,6 +7,7 @@
#include "android_webview/browser/global_tile_manager.h"
#include "android_webview/browser/global_tile_manager_client.h"
+#include "android_webview/browser/parent_compositor_draw_constraints.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "base/android/scoped_java_ref.h"
#include "base/callback.h"
@@ -140,6 +141,8 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
virtual void SetNumTiles(size_t num_tiles,
bool effective_immediately) OVERRIDE;
+ void UpdateParentDrawConstraints();
+
private:
void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip);
// Checks the continuous invalidate and block invalidate state, and schedule
@@ -199,6 +202,10 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
gfx::Vector2d last_on_draw_scroll_offset_;
gfx::Rect last_on_draw_global_visible_rect_;
+ // The draw constraints from the parent compositor. These are only used for
+ // tiling priority.
+ ParentCompositorDrawConstraints parent_draw_constraints_;
+
// When true, we should continuously invalidate and keep drawing, for example
// to drive animation. This value is set by the compositor and should always
// reflect the expectation of the compositor and not be reused for other
diff --git a/android_webview/browser/browser_view_renderer_client.h b/android_webview/browser/browser_view_renderer_client.h
index 41fbf5a..2fba4d2 100644
--- a/android_webview/browser/browser_view_renderer_client.h
+++ b/android_webview/browser/browser_view_renderer_client.h
@@ -28,6 +28,9 @@ class BrowserViewRendererClient {
// Called to trigger view invalidations.
virtual void PostInvalidate() = 0;
+ // Called to update the parent draw constraints in browser view renderer.
+ virtual void UpdateParentDrawConstraints() = 0;
+
// Called to get view's absolute location on the screen.
virtual gfx::Point GetLocationOnScreen() = 0;
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc
index eaf34a9..818d3c5 100644
--- a/android_webview/browser/hardware_renderer.cc
+++ b/android_webview/browser/hardware_renderer.cc
@@ -191,6 +191,21 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
if (last_egl_context_ != current_context)
DLOG(WARNING) << "EGLContextChanged";
+ gfx::Transform transform(gfx::Transform::kSkipInitialization);
+ transform.matrix().setColMajorf(draw_info->transform);
+ transform.Translate(scroll_offset_.x(), scroll_offset_.y());
+
+ // Need to post the new transform matrix back to child compositor
+ // because there is no onDraw during a Render Thread animation, and child
+ // compositor might not have the tiles rasterized as the animation goes on.
+ ParentCompositorDrawConstraints draw_constraints(
+ draw_info->is_layer, transform, gfx::Rect(viewport_));
+ if (!draw_constraints_.Equals(draw_constraints)) {
+ draw_constraints_ = draw_constraints;
+ shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor(
+ draw_constraints);
+ }
+
viewport_.SetSize(draw_info->width, draw_info->height);
layer_tree_host_->SetViewportSize(viewport_);
clip_.SetRect(draw_info->clip_left,
@@ -199,9 +214,6 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
draw_info->clip_bottom - draw_info->clip_top);
stencil_enabled_ = stencil_enabled;
- gfx::Transform transform(gfx::Transform::kSkipInitialization);
- transform.matrix().setColMajorf(draw_info->transform);
- transform.Translate(scroll_offset_.x(), scroll_offset_.y());
delegated_layer_->SetTransform(transform);
gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext);
diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h
index f69d587..f87890b 100644
--- a/android_webview/browser/hardware_renderer.h
+++ b/android_webview/browser/hardware_renderer.h
@@ -5,6 +5,7 @@
#ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
#define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
+#include "android_webview/browser/parent_compositor_draw_constraints.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "base/memory/scoped_ptr.h"
#include "cc/layers/delegated_frame_resource_collection.h"
@@ -89,6 +90,8 @@ class HardwareRenderer : public cc::LayerTreeHostClient,
// This is owned indirectly by |layer_tree_host_|.
ParentOutputSurface* output_surface_;
+ ParentCompositorDrawConstraints draw_constraints_;
+
DISALLOW_COPY_AND_ASSIGN(HardwareRenderer);
};
diff --git a/android_webview/browser/parent_compositor_draw_constraints.cc b/android_webview/browser/parent_compositor_draw_constraints.cc
new file mode 100644
index 0000000..e507d43
--- /dev/null
+++ b/android_webview/browser/parent_compositor_draw_constraints.cc
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/browser/parent_compositor_draw_constraints.h"
+
+namespace android_webview {
+
+ParentCompositorDrawConstraints::ParentCompositorDrawConstraints()
+ : is_layer(false) {
+}
+
+ParentCompositorDrawConstraints::ParentCompositorDrawConstraints(
+ bool is_layer,
+ const gfx::Transform& transform,
+ const gfx::Rect& surface_rect)
+ : is_layer(is_layer), transform(transform), surface_rect(surface_rect) {
+}
+
+bool ParentCompositorDrawConstraints::Equals(
+ const ParentCompositorDrawConstraints& other) const {
+ if (is_layer != other.is_layer || transform != other.transform)
+ return false;
+
+ // Don't care about the surface size when neither is on a layer.
+ return !is_layer || surface_rect == other.surface_rect;
+}
+
+} // namespace webview
diff --git a/android_webview/browser/parent_compositor_draw_constraints.h b/android_webview/browser/parent_compositor_draw_constraints.h
new file mode 100644
index 0000000..4355aa9
--- /dev/null
+++ b/android_webview/browser/parent_compositor_draw_constraints.h
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_BROWSER_PARENT_COMPOSITOR_DRAW_CONSTRAINTS_H_
+#define ANDROID_WEBVIEW_BROWSER_PARENT_COMPOSITOR_DRAW_CONSTRAINTS_H_
+
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/transform.h"
+
+namespace android_webview {
+
+struct ParentCompositorDrawConstraints {
+ bool is_layer;
+ gfx::Transform transform;
+ gfx::Rect surface_rect;
+
+ ParentCompositorDrawConstraints();
+ ParentCompositorDrawConstraints(bool is_layer,
+ const gfx::Transform& transform,
+ const gfx::Rect& surface_rect);
+ bool Equals(const ParentCompositorDrawConstraints& other) const;
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_BROWSER_PARENT_COMPOSITOR_DRAW_CONSTRAINTS_H_
diff --git a/android_webview/browser/parent_output_surface.cc b/android_webview/browser/parent_output_surface.cc
index 54b7f97..0680bc7 100644
--- a/android_webview/browser/parent_output_surface.cc
+++ b/android_webview/browser/parent_output_surface.cc
@@ -30,7 +30,8 @@ void ParentOutputSurface::SetDrawConstraints(const gfx::Size& surface_size,
const gfx::Transform identity;
const gfx::Rect empty;
const bool resourceless_software_draw = false;
- SetExternalDrawConstraints(identity, empty, clip, resourceless_software_draw);
+ SetExternalDrawConstraints(
+ identity, empty, clip, clip, identity, resourceless_software_draw);
}
} // namespace android_webview
diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc
index 582908e..200e2ab 100644
--- a/android_webview/browser/shared_renderer_state.cc
+++ b/android_webview/browser/shared_renderer_state.cc
@@ -51,6 +51,11 @@ void SharedRendererState::ClientRequestDrawGLOnUIThread() {
}
}
+void SharedRendererState::UpdateParentDrawConstraintsOnUIThread() {
+ DCHECK(ui_loop_->BelongsToCurrentThread());
+ client_on_ui_->UpdateParentDrawConstraints();
+}
+
void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) {
base::AutoLock lock(lock_);
DCHECK(!draw_gl_input_.get());
@@ -62,6 +67,26 @@ scoped_ptr<DrawGLInput> SharedRendererState::PassDrawGLInput() {
return draw_gl_input_.Pass();
}
+void SharedRendererState::PostExternalDrawConstraintsToChildCompositor(
+ const ParentCompositorDrawConstraints& parent_draw_constraints) {
+ {
+ base::AutoLock lock(lock_);
+ parent_draw_constraints_ = parent_draw_constraints;
+ }
+
+ // No need to hold the lock_ during the post task.
+ ui_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&SharedRendererState::UpdateParentDrawConstraintsOnUIThread,
+ ui_thread_weak_ptr_));
+}
+
+const ParentCompositorDrawConstraints
+SharedRendererState::ParentDrawConstraints() const {
+ base::AutoLock lock(lock_);
+ return parent_draw_constraints_;
+}
+
void SharedRendererState::SetInsideHardwareRelease(bool inside) {
base::AutoLock lock(lock_);
inside_hardware_release_ = inside;
diff --git a/android_webview/browser/shared_renderer_state.h b/android_webview/browser/shared_renderer_state.h
index 01363f1..cf0c889 100644
--- a/android_webview/browser/shared_renderer_state.h
+++ b/android_webview/browser/shared_renderer_state.h
@@ -5,6 +5,7 @@
#ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
#define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
+#include "android_webview/browser/parent_compositor_draw_constraints.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/lock.h"
@@ -50,6 +51,10 @@ class SharedRendererState {
scoped_ptr<DrawGLInput> PassDrawGLInput();
bool IsInsideHardwareRelease() const;
+ void PostExternalDrawConstraintsToChildCompositor(
+ const ParentCompositorDrawConstraints& parent_draw_constraints);
+
+ const ParentCompositorDrawConstraints ParentDrawConstraints() const;
void SetSharedContext(gpu::GLInProcessContext* context);
gpu::GLInProcessContext* GetSharedContext() const;
@@ -62,6 +67,7 @@ class SharedRendererState {
friend class InsideHardwareReleaseReset;
void ClientRequestDrawGLOnUIThread();
+ void UpdateParentDrawConstraintsOnUIThread();
void SetInsideHardwareRelease(bool inside);
scoped_refptr<base::MessageLoopProxy> ui_loop_;
@@ -73,6 +79,7 @@ class SharedRendererState {
mutable base::Lock lock_;
scoped_ptr<DrawGLInput> draw_gl_input_;
bool inside_hardware_release_;
+ ParentCompositorDrawConstraints parent_draw_constraints_;
gpu::GLInProcessContext* share_context_;
cc::ReturnedResourceArray returned_resources_;