summaryrefslogtreecommitdiffstats
path: root/android_webview/browser
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2015-03-18 17:29:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-19 00:32:56 +0000
commitb887d327fde64c810e34ef78e6bf4006adee441b (patch)
tree3f46e7c6eec9febc9be784344a5565e1dc679a10 /android_webview/browser
parentcd1401c2d863a44ea405a313e94d8fcbfbfb7ada (diff)
downloadchromium_src-b887d327fde64c810e34ef78e6bf4006adee441b.zip
chromium_src-b887d327fde64c810e34ef78e6bf4006adee441b.tar.gz
chromium_src-b887d327fde64c810e34ef78e6bf4006adee441b.tar.bz2
Remove android webview rendering cruft
Remove pipelining and blocking the pipeline in different stages. The underlying issue it was trying to workaround is fixed in Android, and it involves a lot of complexity and was a source of bugs. Also remove special handling when viewport is empty, as this is handled correctly now. Add back the IsEmpty corner case workaround by passing some frame metadata with ChildFrame. BUG= Review URL: https://codereview.chromium.org/1001643004 Cr-Commit-Position: refs/heads/master@{#321250}
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/browser_view_renderer.cc111
-rw-r--r--android_webview/browser/browser_view_renderer.h21
-rw-r--r--android_webview/browser/child_frame.cc26
-rw-r--r--android_webview/browser/child_frame.h40
-rw-r--r--android_webview/browser/hardware_renderer.cc51
-rw-r--r--android_webview/browser/hardware_renderer.h10
-rw-r--r--android_webview/browser/parent_compositor_draw_constraints.cc23
-rw-r--r--android_webview/browser/parent_compositor_draw_constraints.h4
-rw-r--r--android_webview/browser/shared_renderer_state.cc79
-rw-r--r--android_webview/browser/shared_renderer_state.h23
10 files changed, 173 insertions, 215 deletions
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index ea9d603..1f43527 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -5,6 +5,7 @@
#include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/browser_view_renderer_client.h"
+#include "android_webview/browser/child_frame.h"
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/logging.h"
@@ -98,7 +99,6 @@ BrowserViewRenderer::BrowserViewRenderer(
clear_view_(false),
offscreen_pre_raster_(false),
compositor_needs_continuous_invalidate_(false),
- invalidate_after_composite_(false),
block_invalidates_(false),
fallback_tick_pending_(false) {
}
@@ -216,36 +216,20 @@ bool BrowserViewRenderer::OnDrawHardware() {
return false;
}
- ReturnResourceFromParent();
- if (shared_renderer_state_.HasCompositorFrameOnUI()) {
- TRACE_EVENT_INSTANT0("android_webview",
- "EarlyOut_PreviousFrameUnconsumed",
- TRACE_EVENT_SCOPE_THREAD);
- DidSkipCompositeInDraw();
- return true;
- }
-
- scoped_ptr<cc::CompositorFrame> frame = CompositeHw();
- if (!frame.get()) {
- TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
- TRACE_EVENT_SCOPE_THREAD);
- return false;
- }
-
- shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), false);
- return true;
+ return CompositeHw();
}
-scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() {
+bool BrowserViewRenderer::CompositeHw() {
+ ReturnResourceFromParent();
compositor_->SetMemoryPolicy(CalculateDesiredMemoryPolicy());
- parent_draw_constraints_ =
+ ParentCompositorDrawConstraints parent_draw_constraints =
shared_renderer_state_.GetParentDrawConstraintsOnUI();
gfx::Size surface_size(size_);
gfx::Rect viewport(surface_size);
gfx::Rect clip = viewport;
gfx::Transform transform_for_tile_priority =
- parent_draw_constraints_.transform;
+ 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.
@@ -254,9 +238,8 @@ scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() {
// Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on.
if (!offscreen_pre_raster_) {
- if (parent_draw_constraints_.is_layer ||
- last_on_draw_global_visible_rect_.IsEmpty()) {
- viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect;
+ 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_;
}
@@ -269,32 +252,37 @@ scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() {
clip,
viewport_rect_for_tile_priority,
transform_for_tile_priority);
- if (frame.get())
- DidComposite();
- return frame.Pass();
+ if (!frame.get()) {
+ TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
+ TRACE_EVENT_SCOPE_THREAD);
+ return false;
+ }
+
+ scoped_ptr<ChildFrame> child_frame = make_scoped_ptr(
+ new ChildFrame(frame.Pass(), viewport_rect_for_tile_priority,
+ transform_for_tile_priority, offscreen_pre_raster_,
+ parent_draw_constraints.is_layer));
+
+ DidComposite();
+ // Uncommitted frame can happen with consecutive fallback ticks.
+ ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI());
+ shared_renderer_state_.SetCompositorFrameOnUI(child_frame.Pass());
+ return true;
}
void BrowserViewRenderer::UpdateParentDrawConstraints() {
- // Post an invalidate if the parent draw constraints are stale and there is
- // no pending invalidate.
- bool needs_force_invalidate =
- shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI();
- if (needs_force_invalidate ||
- !parent_draw_constraints_.Equals(
- shared_renderer_state_.GetParentDrawConstraintsOnUI())) {
- shared_renderer_state_.SetForceInvalidateOnNextDrawGLOnUI(false);
- EnsureContinuousInvalidation(true, needs_force_invalidate);
- }
+ EnsureContinuousInvalidation(true);
}
void BrowserViewRenderer::ReturnUnusedResource(
- scoped_ptr<cc::CompositorFrame> frame) {
- if (!frame.get())
+ scoped_ptr<ChildFrame> child_frame) {
+ if (!child_frame.get() || !child_frame->frame.get())
return;
cc::CompositorFrameAck frame_ack;
cc::TransferableResource::ReturnResources(
- frame->delegated_frame_data->resource_list, &frame_ack.resources);
+ child_frame->frame->delegated_frame_data->resource_list,
+ &frame_ack.resources);
if (compositor_ && !frame_ack.resources.empty())
compositor_->ReturnResources(frame_ack);
}
@@ -307,11 +295,6 @@ void BrowserViewRenderer::ReturnResourceFromParent() {
}
}
-void BrowserViewRenderer::DidSkipCommitFrame() {
- // Treat it the same way as skipping onDraw.
- DidSkipCompositeInDraw();
-}
-
void BrowserViewRenderer::DetachFunctorFromView() {
client_->DetachFunctorFromView();
}
@@ -356,7 +339,7 @@ void BrowserViewRenderer::ClearView() {
clear_view_ = true;
// Always invalidate ignoring the compositor to actually clear the webview.
- EnsureContinuousInvalidation(true, false);
+ EnsureContinuousInvalidation(true);
}
void BrowserViewRenderer::SetOffscreenPreRaster(bool enable) {
@@ -371,7 +354,7 @@ void BrowserViewRenderer::SetIsPaused(bool paused) {
"paused",
paused);
is_paused_ = paused;
- EnsureContinuousInvalidation(false, false);
+ EnsureContinuousInvalidation(false);
}
void BrowserViewRenderer::SetViewVisibility(bool view_visible) {
@@ -390,7 +373,7 @@ void BrowserViewRenderer::SetWindowVisibility(bool window_visible) {
"window_visible",
window_visible);
window_visible_ = window_visible;
- EnsureContinuousInvalidation(false, false);
+ EnsureContinuousInvalidation(false);
}
void BrowserViewRenderer::OnSizeChanged(int width, int height) {
@@ -471,7 +454,7 @@ void BrowserViewRenderer::SetContinuousInvalidate(bool invalidate) {
invalidate);
compositor_needs_continuous_invalidate_ = invalidate;
- EnsureContinuousInvalidation(false, false);
+ EnsureContinuousInvalidation(false);
}
void BrowserViewRenderer::SetDipScale(float dip_scale) {
@@ -641,21 +624,13 @@ void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
client_->DidOverscroll(rounded_overscroll_delta);
}
-void BrowserViewRenderer::EnsureContinuousInvalidation(
- bool force_invalidate,
- bool skip_reschedule_tick) {
- if (force_invalidate)
- invalidate_after_composite_ = true;
-
+void BrowserViewRenderer::EnsureContinuousInvalidation(bool force_invalidate) {
// This method should be called again when any of these conditions change.
bool need_invalidate =
- compositor_needs_continuous_invalidate_ || invalidate_after_composite_;
+ compositor_needs_continuous_invalidate_ || force_invalidate;
if (!need_invalidate || block_invalidates_)
return;
- if (!compositor_needs_continuous_invalidate_ && invalidate_after_composite_)
- invalidate_after_composite_ = false;
-
// Always call view invalidate. We rely the Android framework to ignore the
// invalidate when it's not needed such as when view is not visible.
client_->PostInvalidate();
@@ -672,7 +647,7 @@ void BrowserViewRenderer::EnsureContinuousInvalidation(
return;
block_invalidates_ = compositor_needs_continuous_invalidate_;
- if (skip_reschedule_tick && fallback_tick_pending_)
+ if (fallback_tick_pending_)
return;
// Unretained here is safe because the callbacks are cancelled when
@@ -718,12 +693,7 @@ void BrowserViewRenderer::FallbackTickFired() {
fallback_tick_pending_ = false;
if (compositor_needs_continuous_invalidate_ && compositor_) {
if (hardware_enabled_) {
- ReturnResourceFromParent();
- ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI());
- scoped_ptr<cc::CompositorFrame> frame = CompositeHw();
- if (frame.get()) {
- shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), true);
- }
+ CompositeHw();
} else {
ForceFakeCompositeSW();
}
@@ -755,12 +725,7 @@ void BrowserViewRenderer::DidComposite() {
post_fallback_tick_.Cancel();
fallback_tick_fired_.Cancel();
fallback_tick_pending_ = false;
- EnsureContinuousInvalidation(false, false);
-}
-
-void BrowserViewRenderer::DidSkipCompositeInDraw() {
- block_invalidates_ = false;
- EnsureContinuousInvalidation(true, true);
+ EnsureContinuousInvalidation(false);
}
std::string BrowserViewRenderer::ToString() const {
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h
index ee6aa29..843529b 100644
--- a/android_webview/browser/browser_view_renderer.h
+++ b/android_webview/browser/browser_view_renderer.h
@@ -12,6 +12,7 @@
#include "base/trace_event/trace_event.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/android/synchronous_compositor_client.h"
+#include "skia/ext/refptr.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d_f.h"
@@ -25,6 +26,7 @@ class WebContents;
namespace android_webview {
class BrowserViewRendererClient;
+class ChildFrame;
// Interface for all the WebView-specific content rendering operations.
// Provides software and hardware rendering and the Capture Picture API.
@@ -109,7 +111,6 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
gfx::Vector2dF current_fling_velocity) override;
void UpdateParentDrawConstraints();
- void DidSkipCommitFrame();
void DetachFunctorFromView();
private:
@@ -117,20 +118,16 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
bool CanOnDraw();
// Checks the continuous invalidate and block invalidate state, and schedule
// invalidates appropriately. If |force_invalidate| is true, then send a view
- // invalidate regardless of compositor expectation. If |skip_reschedule_tick|
- // is true and if there is already a pending fallback tick, don't reschedule
- // them.
- void EnsureContinuousInvalidation(bool force_invalidate,
- bool skip_reschedule_tick);
+ // invalidate regardless of compositor expectation.
+ void EnsureContinuousInvalidation(bool force_invalidate);
bool CompositeSW(SkCanvas* canvas);
void DidComposite();
- void DidSkipCompositeInDraw();
scoped_refptr<base::trace_event::ConvertableToTraceFormat>
RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip,
const gfx::SizeF& scrollable_size_dip);
- scoped_ptr<cc::CompositorFrame> CompositeHw();
- void ReturnUnusedResource(scoped_ptr<cc::CompositorFrame> frame);
+ bool CompositeHw();
+ void ReturnUnusedResource(scoped_ptr<ChildFrame> frame);
void ReturnResourceFromParent();
// If we call up view invalidate and OnDraw is not called before a deadline,
@@ -173,18 +170,12 @@ 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
// states.
bool compositor_needs_continuous_invalidate_;
- bool invalidate_after_composite_;
-
// Used to block additional invalidates while one is already pending.
bool block_invalidates_;
diff --git a/android_webview/browser/child_frame.cc b/android_webview/browser/child_frame.cc
new file mode 100644
index 0000000..f516edc
--- /dev/null
+++ b/android_webview/browser/child_frame.cc
@@ -0,0 +1,26 @@
+// Copyright 2015 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/child_frame.h"
+
+#include "cc/output/compositor_frame.h"
+
+namespace android_webview {
+
+ChildFrame::ChildFrame(scoped_ptr<cc::CompositorFrame> frame,
+ const gfx::Rect& viewport_rect_for_tile_priority,
+ const gfx::Transform& transform_for_tile_priority,
+ bool offscreen_pre_raster,
+ bool is_layer)
+ : frame(frame.Pass()),
+ viewport_rect_for_tile_priority(viewport_rect_for_tile_priority),
+ transform_for_tile_priority(transform_for_tile_priority),
+ offscreen_pre_raster(offscreen_pre_raster),
+ is_layer(is_layer) {
+}
+
+ChildFrame::~ChildFrame() {
+}
+
+} // namespace webview
diff --git a/android_webview/browser/child_frame.h b/android_webview/browser/child_frame.h
new file mode 100644
index 0000000..cb4f7d4
--- /dev/null
+++ b/android_webview/browser/child_frame.h
@@ -0,0 +1,40 @@
+// Copyright 2015 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_CHILD_FRAME_H_
+#define ANDROID_WEBVIEW_BROWSER_CHILD_FRAME_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/transform.h"
+
+namespace cc {
+class CompositorFrame;
+}
+
+namespace android_webview {
+
+class ChildFrame {
+ public:
+ ChildFrame(scoped_ptr<cc::CompositorFrame> frame,
+ const gfx::Rect& viewport_rect_for_tile_priority,
+ const gfx::Transform& transform_for_tile_priority,
+ bool offscreen_pre_raster,
+ bool is_layer);
+ ~ChildFrame();
+
+ scoped_ptr<cc::CompositorFrame> frame;
+ const gfx::Rect viewport_rect_for_tile_priority;
+ const gfx::Transform transform_for_tile_priority;
+ const bool offscreen_pre_raster;
+ const bool is_layer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChildFrame);
+};
+
+} // namespace webview
+
+#endif // ANDROID_WEBVIEW_BROWSER_CHILD_FRAME_H_
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc
index dc83b1b..3c12a44 100644
--- a/android_webview/browser/hardware_renderer.cc
+++ b/android_webview/browser/hardware_renderer.cc
@@ -5,7 +5,9 @@
#include "android_webview/browser/hardware_renderer.h"
#include "android_webview/browser/aw_gl_surface.h"
+#include "android_webview/browser/child_frame.h"
#include "android_webview/browser/deferred_gpu_command_service.h"
+#include "android_webview/browser/parent_compositor_draw_constraints.h"
#include "android_webview/browser/parent_output_surface.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "android_webview/public/browser/draw_gl.h"
@@ -109,8 +111,6 @@ HardwareRenderer::HardwareRenderer(SharedRendererState* state)
}
HardwareRenderer::~HardwareRenderer() {
- SetFrameData();
-
// Must reset everything before |resource_collection_| to ensure all
// resources are returned before resetting |resource_collection_| client.
layer_tree_host_.reset();
@@ -128,7 +128,7 @@ HardwareRenderer::~HardwareRenderer() {
resource_collection_->SetClient(NULL);
// Reset draw constraints.
- shared_renderer_state_->UpdateDrawConstraintsOnRT(
+ shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT(
ParentCompositorDrawConstraints());
}
@@ -144,35 +144,26 @@ void HardwareRenderer::DidBeginMainFrame() {
void HardwareRenderer::CommitFrame() {
TRACE_EVENT0("android_webview", "CommitFrame");
scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT();
- if (committed_frame_.get()) {
- TRACE_EVENT_INSTANT0("android_webview",
- "EarlyOut_PreviousFrameUnconsumed",
- TRACE_EVENT_SCOPE_THREAD);
- shared_renderer_state_->DidSkipCommitFrameOnRT();
- return;
+ {
+ scoped_ptr<ChildFrame> child_frame =
+ shared_renderer_state_->PassCompositorFrameOnRT();
+ if (!child_frame.get())
+ return;
+ child_frame_ = child_frame.Pass();
}
- committed_frame_ = shared_renderer_state_->PassCompositorFrameOnRT();
- // Happens with empty global visible rect.
- if (!committed_frame_.get())
- return;
-
- DCHECK(!committed_frame_->gl_frame_data);
- DCHECK(!committed_frame_->software_frame_data);
+ scoped_ptr<cc::CompositorFrame> frame = child_frame_->frame.Pass();
+ DCHECK(frame.get());
+ DCHECK(!frame->gl_frame_data);
+ DCHECK(!frame->software_frame_data);
// DelegatedRendererLayerImpl applies the inverse device_scale_factor of the
// renderer frame, assuming that the browser compositor will scale
// it back up to device scale. But on Android we put our browser layers in
// physical pixels and set our browser CC device_scale_factor to 1, so this
// suppresses the transform.
- committed_frame_->delegated_frame_data->device_scale_factor = 1.0f;
-}
+ frame->delegated_frame_data->device_scale_factor = 1.0f;
-void HardwareRenderer::SetFrameData() {
- if (!committed_frame_.get())
- return;
-
- scoped_ptr<cc::CompositorFrame> frame = committed_frame_.Pass();
gfx::Size frame_size =
frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
bool size_changed = frame_size != frame_size_;
@@ -210,12 +201,6 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
if (last_egl_context_ != current_context)
DLOG(WARNING) << "EGLContextChanged";
- SetFrameData();
- if (shared_renderer_state_->ForceCommitOnRT()) {
- CommitFrame();
- SetFrameData();
- }
-
gfx::Transform transform(gfx::Transform::kSkipInitialization);
transform.matrix().setColMajorf(draw_info->transform);
transform.Translate(scroll_offset_.x(), scroll_offset_.y());
@@ -225,10 +210,10 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
// compositor might not have the tiles rasterized as the animation goes on.
ParentCompositorDrawConstraints draw_constraints(
draw_info->is_layer, transform, gfx::Rect(viewport_));
-
- draw_constraints_ = draw_constraints;
- shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT(
- draw_constraints);
+ if (!child_frame_.get() || draw_constraints.NeedUpdate(*child_frame_)) {
+ shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT(
+ draw_constraints);
+ }
if (!delegated_layer_.get())
return;
diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h
index eff1b5c..963b30b 100644
--- a/android_webview/browser/hardware_renderer.h
+++ b/android_webview/browser/hardware_renderer.h
@@ -5,7 +5,6 @@
#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"
@@ -24,6 +23,7 @@ class LayerTreeHost;
namespace android_webview {
class AwGLSurface;
+class ChildFrame;
class ParentOutputSurface;
class HardwareRenderer : public cc::LayerTreeHostClient,
@@ -69,15 +69,11 @@ class HardwareRenderer : public cc::LayerTreeHostClient,
void UnusedResourcesAreAvailable() override;
private:
- void SetFrameData();
-
SharedRendererState* shared_renderer_state_;
typedef void* EGLContext;
EGLContext last_egl_context_;
- scoped_ptr<cc::CompositorFrame> committed_frame_;
-
// Information about last delegated frame.
gfx::Size frame_size_;
@@ -90,6 +86,8 @@ class HardwareRenderer : public cc::LayerTreeHostClient,
bool stencil_enabled_;
bool viewport_clip_valid_for_dcheck_;
+ scoped_ptr<ChildFrame> child_frame_;
+
scoped_refptr<AwGLSurface> gl_surface_;
scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
@@ -102,8 +100,6 @@ 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
index e507d43..8bd0ccd 100644
--- a/android_webview/browser/parent_compositor_draw_constraints.cc
+++ b/android_webview/browser/parent_compositor_draw_constraints.cc
@@ -4,6 +4,8 @@
#include "android_webview/browser/parent_compositor_draw_constraints.h"
+#include "android_webview/browser/child_frame.h"
+
namespace android_webview {
ParentCompositorDrawConstraints::ParentCompositorDrawConstraints()
@@ -17,13 +19,24 @@ ParentCompositorDrawConstraints::ParentCompositorDrawConstraints(
: 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)
+bool ParentCompositorDrawConstraints::NeedUpdate(
+ const ChildFrame& frame) const {
+ if (is_layer != frame.is_layer ||
+ transform != frame.transform_for_tile_priority) {
+ return true;
+ }
+
+ // Viewport for tile priority does not depend on surface rect in this case.
+ if (frame.offscreen_pre_raster)
return false;
- // Don't care about the surface size when neither is on a layer.
- return !is_layer || surface_rect == other.surface_rect;
+ if (is_layer) {
+ return surface_rect != frame.viewport_rect_for_tile_priority;
+ } else {
+ // Workaround for corner case. See crbug.com/417479.
+ return frame.viewport_rect_for_tile_priority.IsEmpty() &&
+ !surface_rect.IsEmpty();
+ }
}
} // namespace webview
diff --git a/android_webview/browser/parent_compositor_draw_constraints.h b/android_webview/browser/parent_compositor_draw_constraints.h
index 4355aa9..c8e535c 100644
--- a/android_webview/browser/parent_compositor_draw_constraints.h
+++ b/android_webview/browser/parent_compositor_draw_constraints.h
@@ -10,6 +10,8 @@
namespace android_webview {
+class ChildFrame;
+
struct ParentCompositorDrawConstraints {
bool is_layer;
gfx::Transform transform;
@@ -19,7 +21,7 @@ struct ParentCompositorDrawConstraints {
ParentCompositorDrawConstraints(bool is_layer,
const gfx::Transform& transform,
const gfx::Rect& surface_rect);
- bool Equals(const ParentCompositorDrawConstraints& other) const;
+ bool NeedUpdate(const ChildFrame& frame) const;
};
} // namespace android_webview
diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc
index 119b7fd..1d9874e 100644
--- a/android_webview/browser/shared_renderer_state.cc
+++ b/android_webview/browser/shared_renderer_state.cc
@@ -5,6 +5,7 @@
#include "android_webview/browser/shared_renderer_state.h"
#include "android_webview/browser/browser_view_renderer.h"
+#include "android_webview/browser/child_frame.h"
#include "android_webview/browser/deferred_gpu_command_service.h"
#include "android_webview/browser/hardware_renderer.h"
#include "android_webview/browser/scoped_app_gl_state_restore.h"
@@ -88,9 +89,7 @@ SharedRendererState::SharedRendererState(
: ui_loop_(ui_loop),
browser_view_renderer_(browser_view_renderer),
renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()),
- force_commit_(false),
inside_hardware_release_(false),
- needs_force_invalidate_on_next_draw_gl_(false),
weak_factory_on_ui_thread_(this) {
DCHECK(ui_loop_->BelongsToCurrentThread());
DCHECK(browser_view_renderer_);
@@ -157,68 +156,34 @@ gfx::Vector2d SharedRendererState::GetScrollOffsetOnRT() {
return scroll_offset_;
}
-bool SharedRendererState::HasCompositorFrameOnUI() const {
+void SharedRendererState::SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame) {
base::AutoLock lock(lock_);
- return compositor_frame_.get();
+ DCHECK(!child_frame_.get());
+ child_frame_ = frame.Pass();
}
-void SharedRendererState::SetCompositorFrameOnUI(
- scoped_ptr<cc::CompositorFrame> frame,
- bool force_commit) {
+scoped_ptr<ChildFrame> SharedRendererState::PassCompositorFrameOnRT() {
base::AutoLock lock(lock_);
- DCHECK(!compositor_frame_.get());
- compositor_frame_ = frame.Pass();
- force_commit_ = force_commit;
+ return child_frame_.Pass();
}
-scoped_ptr<cc::CompositorFrame> SharedRendererState::PassCompositorFrameOnRT() {
+scoped_ptr<ChildFrame> SharedRendererState::PassUncommittedFrameOnUI() {
base::AutoLock lock(lock_);
- return compositor_frame_.Pass();
-}
-
-scoped_ptr<cc::CompositorFrame>
-SharedRendererState::PassUncommittedFrameOnUI() {
- base::AutoLock lock(lock_);
- return compositor_frame_.Pass();
-}
-
-bool SharedRendererState::ForceCommitOnRT() const {
- base::AutoLock lock(lock_);
- return force_commit_;
-}
-
-bool SharedRendererState::UpdateDrawConstraintsOnRT(
- const ParentCompositorDrawConstraints& parent_draw_constraints) {
- base::AutoLock lock(lock_);
- if (needs_force_invalidate_on_next_draw_gl_ ||
- !parent_draw_constraints_.Equals(parent_draw_constraints)) {
- parent_draw_constraints_ = parent_draw_constraints;
- return true;
- }
-
- return false;
+ return child_frame_.Pass();
}
void SharedRendererState::PostExternalDrawConstraintsToChildCompositorOnRT(
const ParentCompositorDrawConstraints& parent_draw_constraints) {
- if (UpdateDrawConstraintsOnRT(parent_draw_constraints)) {
- // No need to hold the lock_ during the post task.
- ui_loop_->PostTask(
- FROM_HERE,
- base::Bind(&SharedRendererState::UpdateParentDrawConstraintsOnUI,
- ui_thread_weak_ptr_));
+ {
+ base::AutoLock lock(lock_);
+ parent_draw_constraints_ = parent_draw_constraints;
}
-}
-void SharedRendererState::DidSkipCommitFrameOnRT() {
- ui_loop_->PostTask(FROM_HERE,
- base::Bind(&SharedRendererState::DidSkipCommitFrameOnUI,
- ui_thread_weak_ptr_));
-}
-
-void SharedRendererState::DidSkipCommitFrameOnUI() {
- DCHECK(ui_loop_->BelongsToCurrentThread());
- browser_view_renderer_->DidSkipCommitFrame();
+ // No need to hold the lock_ during the post task.
+ ui_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&SharedRendererState::UpdateParentDrawConstraintsOnUI,
+ ui_thread_weak_ptr_));
}
ParentCompositorDrawConstraints
@@ -227,18 +192,6 @@ SharedRendererState::GetParentDrawConstraintsOnUI() const {
return parent_draw_constraints_;
}
-void SharedRendererState::SetForceInvalidateOnNextDrawGLOnUI(
- bool needs_force_invalidate_on_next_draw_gl) {
- base::AutoLock lock(lock_);
- needs_force_invalidate_on_next_draw_gl_ =
- needs_force_invalidate_on_next_draw_gl;
-}
-
-bool SharedRendererState::NeedsForceInvalidateOnNextDrawGLOnUI() const {
- base::AutoLock lock(lock_);
- return needs_force_invalidate_on_next_draw_gl_;
-}
-
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 d0555b72..3db14b7 100644
--- a/android_webview/browser/shared_renderer_state.h
+++ b/android_webview/browser/shared_renderer_state.h
@@ -11,7 +11,6 @@
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
-#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
@@ -25,6 +24,7 @@ class RequestDrawGLTracker;
}
class BrowserViewRenderer;
+class ChildFrame;
class HardwareRenderer;
class InsideHardwareReleaseReset;
@@ -41,30 +41,20 @@ class SharedRendererState {
// UI thread methods.
void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset);
- bool HasCompositorFrameOnUI() const;
- void SetCompositorFrameOnUI(scoped_ptr<cc::CompositorFrame> frame,
- bool force_commit);
+ void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame);
void InitializeHardwareDrawIfNeededOnUI();
void ReleaseHardwareDrawIfNeededOnUI();
ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const;
- void SetForceInvalidateOnNextDrawGLOnUI(
- bool needs_force_invalidate_on_next_draw_gl);
- bool NeedsForceInvalidateOnNextDrawGLOnUI() const;
void SwapReturnedResourcesOnUI(cc::ReturnedResourceArray* resources);
bool ReturnedResourcesEmptyOnUI() const;
- scoped_ptr<cc::CompositorFrame> PassUncommittedFrameOnUI();
+ scoped_ptr<ChildFrame> PassUncommittedFrameOnUI();
// RT thread methods.
gfx::Vector2d GetScrollOffsetOnRT();
- scoped_ptr<cc::CompositorFrame> PassCompositorFrameOnRT();
- bool ForceCommitOnRT() const;
+ scoped_ptr<ChildFrame> PassCompositorFrameOnRT();
void DrawGL(AwDrawGLInfo* draw_info);
- // Returns true if the draw constraints are updated.
- bool UpdateDrawConstraintsOnRT(
- const ParentCompositorDrawConstraints& parent_draw_constraints);
void PostExternalDrawConstraintsToChildCompositorOnRT(
const ParentCompositorDrawConstraints& parent_draw_constraints);
- void DidSkipCommitFrameOnRT();
void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources);
private:
@@ -86,7 +76,6 @@ class SharedRendererState {
void ResetRequestDrawGLCallback();
void ClientRequestDrawGLOnUI();
void UpdateParentDrawConstraintsOnUI();
- void DidSkipCommitFrameOnUI();
bool IsInsideHardwareRelease() const;
void SetInsideHardwareRelease(bool inside);
@@ -105,10 +94,8 @@ class SharedRendererState {
// Accessed by both UI and RT thread.
mutable base::Lock lock_;
gfx::Vector2d scroll_offset_;
- scoped_ptr<cc::CompositorFrame> compositor_frame_;
- bool force_commit_;
+ scoped_ptr<ChildFrame> child_frame_;
bool inside_hardware_release_;
- bool needs_force_invalidate_on_next_draw_gl_;
ParentCompositorDrawConstraints parent_draw_constraints_;
cc::ReturnedResourceArray returned_resources_;
base::Closure request_draw_gl_closure_;