diff options
author | trchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 06:43:20 +0000 |
---|---|---|
committer | trchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 06:43:20 +0000 |
commit | 06cbc31bffba14c3ded1dfedf98fff85a86fe6e5 (patch) | |
tree | fd58bda8747c8b544601c1ee06b9b98db632f884 /content/renderer | |
parent | 8eefe84004a9c199c0521bf353a88f37aba53e15 (diff) | |
download | chromium_src-06cbc31bffba14c3ded1dfedf98fff85a86fe6e5.zip chromium_src-06cbc31bffba14c3ded1dfedf98fff85a86fe6e5.tar.gz chromium_src-06cbc31bffba14c3ded1dfedf98fff85a86fe6e5.tar.bz2 |
Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate -- V2
[2/2] Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate
They basically do the same thing except that SetNeedsAnimate makes the next
commit non-cancellable. However there is really no reason why SetNeedsAnimate
need to enforce a commit even if no tiles are updated and no layer properties
changed.
SetNeedsAnimate is thus merged into SetNeedsUpdateLayers. The proper use of
it is when there are potential layout/tile changes, we can use it to defer
calculation until the next frame. A commit will be scheduled but can be
cancelled if no updates are needed after calculation.
This part of the patch changes code behavior slightly.
SingleThreadProxy::SetNeedsUpdateLayers was originally implemented as
RenderWidget::ScheduleComposite but now it is RenderWidget::ScheduleAnimation.
ThreadProxy::SetNeedsAnimate was non-cancellable but is now cancellable.
[1/2] Cleanup RenderWidget::scheduleComposite/scheduleAnimation
scheduleComposite has been renamed to ScheduleComposite as it is no longer
a part of WebWidgetClient API.
scheduleAnimation has been renamed to ScheduleAnimation. The semantics is to
schedule a composite and also (potentially) animating WebWidget.
A new WebWidgetClient API scheduleUpdate has been added, to replace the old
scheduleAnimation. The semantics is to notify the embedder that something in
the WebWidget may change in 0 seconds. (i.e. it is allowed to be called
during a redraw, in such case another redraw will be scheduled after frame
delay.
This part of the patch should not change code behavior.
BUG=316929
R=danakj,jamesr,jochen
Review URL: https://codereview.chromium.org/133263004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.cc | 22 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.h | 5 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 69 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 6 |
5 files changed, 64 insertions, 40 deletions
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 80f2fc1..a77a918 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -358,8 +358,8 @@ void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { } void RenderWidgetCompositor::SetNeedsForcedRedraw() { - layer_tree_host_->SetNextCommitForcesRedraw(); - setNeedsAnimate(); + layer_tree_host_->set_next_commit_forces_redraw(); + setNeedsUpdateLayers(); } scoped_ptr<cc::SwapPromiseMonitor> @@ -478,12 +478,19 @@ void RenderWidgetCompositor::startPageScaleAnimation( duration); } +// Renamed. Staged for removal. void RenderWidgetCompositor::setNeedsAnimate() { - layer_tree_host_->SetNeedsAnimate(); + setNeedsUpdateLayers(); } +void RenderWidgetCompositor::setNeedsUpdateLayers() { + layer_tree_host_->SetNeedsUpdateLayers(); +} + +// Unused. Staged for removal. bool RenderWidgetCompositor::commitRequested() const { - return layer_tree_host_->CommitRequested(); + NOTREACHED(); + return false; } void RenderWidgetCompositor::didStopFlinging() { @@ -621,11 +628,14 @@ RenderWidgetCompositor::OffscreenContextProvider() { void RenderWidgetCompositor::ScheduleComposite() { if (!suppress_schedule_composite_) - widget_->scheduleComposite(); + widget_->ScheduleComposite(); } void RenderWidgetCompositor::ScheduleAnimation() { - widget_->scheduleAnimation(); + widget_->ScheduleAnimation(); + // ScheduleAnimation alone doesn't trigger a redraw. + // ScheduleComposite here to send an artifical invalidation. + ScheduleComposite(); } void RenderWidgetCompositor::DidPostSwapBuffers() { diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index 5e4cadf..d384efd 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -98,8 +98,9 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView, bool use_anchor, float new_page_scale, double duration_sec); - virtual void setNeedsAnimate(); - virtual bool commitRequested() const; + virtual void setNeedsAnimate(); // Renamed. Staged for removal. + virtual void setNeedsUpdateLayers(); + virtual bool commitRequested() const; // Unused. Staged for removal. virtual void didStopFlinging(); virtual bool compositeAndReadback(void *pixels, const blink::WebRect& rect); virtual void finishAllRendering(); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index ecdd229..5485e88 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -5945,7 +5945,7 @@ void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, return; // Remove the content highlighting if any. - scheduleComposite(); + ScheduleComposite(); if (!intent.is_empty()) Send(new ViewHostMsg_StartContentIntent(routing_id_, intent)); diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 7d8700f..957b096 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -566,6 +566,34 @@ void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { screen_metrics_emulator_->OnShowContextMenu(params); } +void RenderWidget::ScheduleAnimation() { + if (animation_update_pending_) + return; + + TRACE_EVENT0("gpu", "RenderWidget::ScheduleAnimation"); + animation_update_pending_ = true; + if (!animation_timer_.IsRunning()) { + animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, + &RenderWidget::AnimationCallback); + } +} + +void RenderWidget::ScheduleComposite() { + if (is_accelerated_compositing_active_ && + RenderThreadImpl::current()->compositor_message_loop_proxy().get()) { + DCHECK(compositor_); + compositor_->setNeedsAnimate(); + } else { + // TODO(nduca): replace with something a little less hacky. The reason this + // hack is still used is because the Invalidate-DoDeferredUpdate loop + // contains a lot of host-renderer synchronization logic that is still + // important for the accelerated compositing case. The option of simply + // duplicating all that code is less desirable than "faking out" the + // invalidation path using a magical damage rect. + didInvalidateRect(WebRect(0, 0, 1, 1)); + } +} + void RenderWidget::ScheduleCompositeWithForcedRedraw() { if (compositor_) { // Regardless of whether threaded compositing is enabled, always @@ -574,7 +602,7 @@ void RenderWidget::ScheduleCompositeWithForcedRedraw() { // non-threaded case. compositor_->SetNeedsForcedRedraw(); } - scheduleComposite(); + ScheduleComposite(); } bool RenderWidget::OnMessageReceived(const IPC::Message& message) { @@ -811,9 +839,7 @@ void RenderWidget::OnWasShown(bool needs_repainting) { if (!is_accelerated_compositing_active_) { didInvalidateRect(gfx::Rect(size_.width(), size_.height())); } else { - if (compositor_) - compositor_->SetNeedsForcedRedraw(); - scheduleComposite(); + ScheduleCompositeWithForcedRedraw(); } } @@ -973,7 +999,7 @@ void RenderWidget::OnSwapBuffersAborted() { num_swapbuffers_complete_pending_ = 0; using_asynchronous_swapbuffers_ = false; // Schedule another frame so the compositor learns about it. - scheduleComposite(); + ScheduleComposite(); } void RenderWidget::OnSwapBuffersPosted() { @@ -1931,30 +1957,15 @@ void RenderWidget::didCompleteSwapBuffers() { need_update_rect_for_auto_resize_ = false; } -void RenderWidget::scheduleComposite() { - if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && - compositor_) { - compositor_->setNeedsAnimate(); - } else { - // TODO(nduca): replace with something a little less hacky. The reason this - // hack is still used is because the Invalidate-DoDeferredUpdate loop - // contains a lot of host-renderer synchronization logic that is still - // important for the accelerated compositing case. The option of simply - // duplicating all that code is less desirable than "faking out" the - // invalidation path using a magical damage rect. - didInvalidateRect(WebRect(0, 0, 1, 1)); - } -} - -void RenderWidget::scheduleAnimation() { - if (animation_update_pending_) - return; +// Renamed. Staged for removal. +void RenderWidget::scheduleAnimation() { scheduleUpdate(); } - TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); - animation_update_pending_ = true; - if (!animation_timer_.IsRunning()) { - animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, - &RenderWidget::AnimationCallback); +void RenderWidget::scheduleUpdate() { + if (is_accelerated_compositing_active_) { + DCHECK(compositor_); + compositor_->setNeedsUpdateLayers(); + } else { + ScheduleAnimation(); } } @@ -2360,7 +2371,7 @@ void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { if (!is_accelerated_compositing_active_) { didInvalidateRect(gfx::Rect(size_.width(), size_.height())); } else { - scheduleComposite(); + ScheduleComposite(); } } diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index c2d7431..0faa1ef 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -133,8 +133,8 @@ class CONTENT_EXPORT RenderWidget virtual void didBecomeReadyForAdditionalInput(); virtual void didCommitAndDrawCompositorFrame(); virtual void didCompleteSwapBuffers(); - virtual void scheduleComposite(); - virtual void scheduleAnimation(); + virtual void scheduleAnimation(); // Renamed. Staged for removal. + virtual void scheduleUpdate(); virtual void didFocus(); virtual void didBlur(); virtual void didChangeCursor(const blink::WebCursorInfo&); @@ -226,6 +226,8 @@ class CONTENT_EXPORT RenderWidget void DisableScreenMetricsEmulation(); void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); + virtual void ScheduleAnimation(); // virtual for testing + virtual void ScheduleComposite(); // virtual for testing void ScheduleCompositeWithForcedRedraw(); // Called by the compositor in single-threaded mode when a swap is posted, |