diff options
author | trchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 04:11:29 +0000 |
---|---|---|
committer | trchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 04:11:29 +0000 |
commit | 807f55ecb7ece39b25866405125d7e58b4bad9f2 (patch) | |
tree | b87e4511156b3da88943957dc91282eff426e47b | |
parent | c8af3918820921a280bbe9dbaacadeb63d5c65b9 (diff) | |
download | chromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.zip chromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.tar.gz chromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.tar.bz2 |
Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate
[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,piman
Review URL: https://codereview.chromium.org/68893031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/test/fake_proxy.h | 1 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 6 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 9 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_perftest.cc | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_animation.cc | 43 | ||||
-rw-r--r-- | cc/trees/proxy.h | 1 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 7 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 46 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 7 | ||||
-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 | ||||
-rw-r--r-- | content/test/web_layer_tree_view_impl_for_testing.cc | 11 | ||||
-rw-r--r-- | content/test/web_layer_tree_view_impl_for_testing.h | 5 |
20 files changed, 134 insertions, 125 deletions
diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index bcde11e..4ddf4cf 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -28,7 +28,6 @@ class FakeProxy : public Proxy { virtual void SetVisible(bool visible) OVERRIDE {} virtual void CreateAndInitializeOutputSurface() OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; - virtual void SetNeedsAnimate() OVERRIDE {} virtual void SetNeedsUpdateLayers() OVERRIDE {} virtual void SetNeedsCommit() OVERRIDE {} virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE {} diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index b723c56..f595458 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -515,6 +515,10 @@ void LayerTreeTest::ScheduleComposite() { base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_)); } +void LayerTreeTest::ScheduleAnimation() { + ScheduleComposite(); +} + void LayerTreeTest::RealEndTest() { if (layer_tree_host_ && proxy()->CommitPendingForTesting()) { main_task_runner_->PostTask( @@ -601,7 +605,7 @@ void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { DCHECK(!proxy() || proxy()->IsMainThread()); if (layer_tree_host_) - layer_tree_host_->SetNextCommitForcesRedraw(); + layer_tree_host_->set_next_commit_forces_redraw(); } void LayerTreeTest::DispatchComposite() { diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index dd5a8d5..08e4514 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -137,6 +137,7 @@ class LayerTreeTest : public testing::Test, public TestHooks { virtual void InitializeSettings(LayerTreeSettings* settings) {} virtual void ScheduleComposite() OVERRIDE; + virtual void ScheduleAnimation() OVERRIDE; void RealEndTest(); diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 7432197..b49f9957 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -519,11 +519,6 @@ const RendererCapabilities& LayerTreeHost::GetRendererCapabilities() const { return proxy_->GetRendererCapabilities(); } -void LayerTreeHost::SetNeedsAnimate() { - proxy_->SetNeedsAnimate(); - NotifySwapPromiseMonitorsOfSetNeedsCommit(); -} - void LayerTreeHost::SetNeedsUpdateLayers() { proxy_->SetNeedsUpdateLayers(); NotifySwapPromiseMonitorsOfSetNeedsCommit(); @@ -566,10 +561,6 @@ void LayerTreeHost::SetNextCommitWaitsForActivation() { proxy_->SetNextCommitWaitsForActivation(); } -void LayerTreeHost::SetNextCommitForcesRedraw() { - next_commit_forces_redraw_ = true; -} - void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events, base::Time wall_clock_time) { DCHECK(proxy_->IsMainThread()); diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 8b9c1cf..8d0fd14 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -167,7 +167,6 @@ class CC_EXPORT LayerTreeHost { const RendererCapabilities& GetRendererCapabilities() const; - void SetNeedsAnimate(); virtual void SetNeedsUpdateLayers(); virtual void SetNeedsCommit(); virtual void SetNeedsFullTreeSync(); @@ -178,7 +177,8 @@ class CC_EXPORT LayerTreeHost { void SetNextCommitWaitsForActivation(); - void SetNextCommitForcesRedraw(); + void set_next_commit_forces_redraw() { next_commit_forces_redraw_ = true; } + bool next_commit_forces_redraw() { return next_commit_forces_redraw_; } void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events, base::Time wall_clock_time); diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index 1bfe1c4..b93755a 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc @@ -55,7 +55,7 @@ class LayerTreeHostPerfTest : public LayerTreeTest { virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { if (animation_driven_drawing_ && !TestEnded()) - layer_tree_host()->SetNeedsAnimate(); + layer_tree_host()->SetNeedsUpdateLayers(); } virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 2d1357f..697d145 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -4744,17 +4744,6 @@ class LayerTreeHostTestSimpleSwapPromiseMonitor EXPECT_EQ(0, set_needs_redraw_count); } - { - scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( - new SimpleSwapPromiseMonitor(layer_tree_host(), - NULL, - &set_needs_commit_count, - &set_needs_redraw_count)); - layer_tree_host()->SetNeedsAnimate(); - EXPECT_EQ(3, set_needs_commit_count); - EXPECT_EQ(0, set_needs_redraw_count); - } - EndTest(); } diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc index 22c8965..a835213 100644 --- a/cc/trees/layer_tree_host_unittest_animation.cc +++ b/cc/trees/layer_tree_host_unittest_animation.cc @@ -27,12 +27,12 @@ class LayerTreeHostAnimationTest : public LayerTreeTest { } }; -// Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to -// be set. -class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested +// Makes sure that SetNeedsUpdateLayers does not cause the CommitRequested() +// state to be set. +class LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested : public LayerTreeHostAnimationTest { public: - LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested() + LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested() : num_commits_(0) {} virtual void BeginTest() OVERRIDE { @@ -45,7 +45,7 @@ class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested if (num_commits_ != 1) return; - layer_tree_host()->SetNeedsAnimate(); + layer_tree_host()->SetNeedsUpdateLayers(); // Right now, CommitRequested is going to be true, because during // BeginFrame, we force CommitRequested to true to prevent requests from // hitting the impl thread. But, when the next DidCommit happens, we should @@ -55,11 +55,11 @@ class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested virtual void DidCommit() OVERRIDE { if (!num_commits_) { EXPECT_FALSE(layer_tree_host()->CommitRequested()); - layer_tree_host()->SetNeedsAnimate(); + layer_tree_host()->SetNeedsUpdateLayers(); EXPECT_FALSE(layer_tree_host()->CommitRequested()); } - // Verifies that the SetNeedsAnimate we made in ::Animate did not + // Verifies that the SetNeedsUpdateLayers we made in ::Animate did not // trigger CommitRequested. EXPECT_FALSE(layer_tree_host()->CommitRequested()); EndTest(); @@ -73,17 +73,17 @@ class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested }; MULTI_THREAD_TEST_F( - LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested); + LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested); // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate -// callback, request another frame using SetNeedsAnimate. End the test when +// callback, request another frame using SetNeedsUpdateLayers. End the test when // animate gets called yet-again, indicating that the proxy is correctly -// handling the case where SetNeedsAnimate() is called inside the BeginFrame -// flow. -class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback +// handling the case where SetNeedsUpdateLayers() is called inside the +// BeginFrame flow. +class LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback : public LayerTreeHostAnimationTest { public: - LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() + LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback() : num_animates_(0) {} virtual void BeginTest() OVERRIDE { @@ -92,7 +92,7 @@ class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback virtual void Animate(base::TimeTicks) OVERRIDE { if (!num_animates_) { - layer_tree_host()->SetNeedsAnimate(); + layer_tree_host()->SetNeedsUpdateLayers(); num_animates_++; return; } @@ -106,7 +106,7 @@ class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback }; MULTI_THREAD_TEST_F( - LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback); + LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback); // Add a layer animation and confirm that // LayerTreeHostImpl::updateAnimationState does get called and continues to @@ -732,14 +732,21 @@ class LayerTreeHostAnimationTestContinuousAnimate PostSetNeedsCommitToMainThread(); } + virtual void SetupTree() OVERRIDE { + LayerTreeHostAnimationTest::SetupTree(); + content_ = FakeContentLayer::Create(&client_); + content_->set_always_update_resources(true); + layer_tree_host()->root_layer()->AddChild(content_); + } + virtual void Animate(base::TimeTicks) OVERRIDE { if (num_draw_layers_ == 2) return; - layer_tree_host()->SetNeedsAnimate(); + layer_tree_host()->SetNeedsUpdateLayers(); } virtual void Layout() OVERRIDE { - layer_tree_host()->root_layer()->SetNeedsDisplay(); + content_->SetNeedsDisplay(); } virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { @@ -761,6 +768,8 @@ class LayerTreeHostAnimationTestContinuousAnimate private: int num_commit_complete_; int num_draw_layers_; + FakeContentLayerClient client_; + scoped_refptr<FakeContentLayer> content_; }; MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index 69975a6..773f29d 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -65,7 +65,6 @@ class CC_EXPORT Proxy { virtual const RendererCapabilities& GetRendererCapabilities() const = 0; - virtual void SetNeedsAnimate() = 0; virtual void SetNeedsUpdateLayers() = 0; virtual void SetNeedsCommit() = 0; virtual void SetNeedsRedraw(gfx::Rect damage_rect) = 0; diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index f1f8a4f..ddccb50 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -176,14 +176,9 @@ const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { return renderer_capabilities_for_main_thread_; } -void SingleThreadProxy::SetNeedsAnimate() { - DCHECK(Proxy::IsMainThread()); - client_->ScheduleAnimation(); -} - void SingleThreadProxy::SetNeedsUpdateLayers() { DCHECK(Proxy::IsMainThread()); - client_->ScheduleComposite(); + client_->ScheduleAnimation(); } void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 463141c..71b92d6 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -34,7 +34,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { virtual void SetVisible(bool visible) OVERRIDE; virtual void CreateAndInitializeOutputSurface() OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; - virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsUpdateLayers() OVERRIDE; virtual void SetNeedsCommit() OVERRIDE; virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 6149522..fe84650 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -80,7 +80,7 @@ ThreadProxy::ThreadProxy( LayerTreeHost* layer_tree_host, scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) : Proxy(impl_task_runner), - animate_requested_(false), + update_requested_(false), commit_requested_(false), commit_request_sent_to_impl_thread_(false), created_offscreen_context_provider_(false), @@ -350,24 +350,14 @@ const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { return renderer_capabilities_main_thread_copy_; } -void ThreadProxy::SetNeedsAnimate() { - DCHECK(IsMainThread()); - if (animate_requested_) - return; - - TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate"); - animate_requested_ = true; - can_cancel_commit_ = false; - SendCommitRequestToImplThreadIfNeeded(); -} - void ThreadProxy::SetNeedsUpdateLayers() { DCHECK(IsMainThread()); - if (commit_request_sent_to_impl_thread_) + if (update_requested_) return; TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers"); + update_requested_ = true; SendCommitRequestToImplThreadIfNeeded(); } @@ -786,10 +776,10 @@ void ThreadProxy::BeginMainFrame( commit_requested_ = true; commit_request_sent_to_impl_thread_ = true; - // On the other hand, the AnimationRequested flag needs to be cleared - // here so that any animation requests generated by the apply or animate + // On the other hand, the update_requested_ flag needs to be cleared + // here so that any update requests generated by the apply or animate // callbacks will trigger another frame. - animate_requested_ = false; + update_requested_ = false; if (!in_composite_and_readback_ && !layer_tree_host()->visible()) { commit_requested_ = false; @@ -851,7 +841,8 @@ void ThreadProxy::BeginMainFrame( bool can_cancel_this_commit = can_cancel_commit_ && !in_composite_and_readback_ && - !evicted_ui_resources; + !evicted_ui_resources && + !layer_tree_host()->next_commit_forces_redraw(); can_cancel_commit_ = true; scoped_ptr<ResourceUpdateQueue> queue = @@ -865,6 +856,17 @@ void ThreadProxy::BeginMainFrame( layer_tree_host()->WillCommit(); + // Before calling animate, we set update_requested_ to false. If it is true + // now, it means SetNeedsUpdateLayers was called again. Depending on during + // which phase of the commit SetNeedsUpdateLayers was called, + // commit_request_sent_to_impl_thread_ may be already cleared or not. + // We call SetNeedsUpdateLayers here to make sure a commit always gets posted. + if (update_requested_) { + // Forces SetNeedsUpdateLayers to consider posting a commit task. + update_requested_ = false; + SetNeedsUpdateLayers(); + } + if (!updated && can_cancel_this_commit) { TRACE_EVENT0("cc", "EarlyOut_NoUpdates"); bool did_handle = true; @@ -882,16 +884,6 @@ void ThreadProxy::BeginMainFrame( return; } - // Before calling animate, we set animate_requested_ to false. If it is true - // now, it means SetNeedAnimate was called again, but during a state when - // commit_request_sent_to_impl_thread_ = true. We need to force that call to - // happen again now so that the commit request is sent to the impl thread. - if (animate_requested_) { - // Forces SetNeedsAnimate to consider posting a commit task. - animate_requested_ = false; - SetNeedsAnimate(); - } - scoped_refptr<ContextProvider> offscreen_context_provider; if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && layer_tree_host()->needs_offscreen_context()) { diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index cf041ed..ed7c4bc 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -48,7 +48,6 @@ class ThreadProxy : public Proxy, virtual void SetVisible(bool visible) OVERRIDE; virtual void CreateAndInitializeOutputSurface() OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; - virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsUpdateLayers() OVERRIDE; virtual void SetNeedsCommit() OVERRIDE; virtual void SetNeedsRedraw(gfx::Rect damage_rect) OVERRIDE; @@ -202,11 +201,11 @@ class ThreadProxy : public Proxy, // Accessed on main thread only. - // Set only when SetNeedsAnimate is called. - bool animate_requested_; + // Set only when SetNeedsUpdateLayers is called. + bool update_requested_; // Set only when SetNeedsCommit is called. bool commit_requested_; - // Set by SetNeedsAnimate, SetNeedsUpdateLayers, and SetNeedsCommit. + // Set by both SetNeedsUpdateLayers and SetNeedsCommit. bool commit_request_sent_to_impl_thread_; // Set by BeginMainFrame bool created_offscreen_context_provider_; diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index b4c147f..71cbe11 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -359,8 +359,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> @@ -479,12 +479,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() { @@ -622,11 +629,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 941fe31..2ffc5a4 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 8d18f95..a1f9280 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -6127,7 +6127,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 b44c0f7..47fa6c9 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -562,6 +562,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 @@ -570,7 +598,7 @@ void RenderWidget::ScheduleCompositeWithForcedRedraw() { // non-threaded case. compositor_->SetNeedsForcedRedraw(); } - scheduleComposite(); + ScheduleComposite(); } bool RenderWidget::OnMessageReceived(const IPC::Message& message) { @@ -805,9 +833,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(); } } @@ -967,7 +993,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() { @@ -1923,30 +1949,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)); - } -} +// Renamed. Staged for removal. +void RenderWidget::scheduleAnimation() { scheduleUpdate(); } -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::scheduleUpdate() { + if (is_accelerated_compositing_active_) { + DCHECK(compositor_); + compositor_->setNeedsUpdateLayers(); + } else { + ScheduleAnimation(); } } @@ -2352,7 +2363,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 043d3aa..4b521fb 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); + void ScheduleAnimation(); + void ScheduleComposite(); void ScheduleCompositeWithForcedRedraw(); // Called by the compositor in single-threaded mode when a swap is posted, diff --git a/content/test/web_layer_tree_view_impl_for_testing.cc b/content/test/web_layer_tree_view_impl_for_testing.cc index 1470e03..3a96c25 100644 --- a/content/test/web_layer_tree_view_impl_for_testing.cc +++ b/content/test/web_layer_tree_view_impl_for_testing.cc @@ -116,12 +116,19 @@ void WebLayerTreeViewImplForTesting::startPageScaleAnimation( float new_page_scale, double duration_sec) {} +// Renamed. Staged for removal. void WebLayerTreeViewImplForTesting::setNeedsAnimate() { - layer_tree_host_->SetNeedsAnimate(); + setNeedsUpdateLayers(); } +void WebLayerTreeViewImplForTesting::setNeedsUpdateLayers() { + layer_tree_host_->SetNeedsUpdateLayers(); +} + +// Unused. Staged for removal. bool WebLayerTreeViewImplForTesting::commitRequested() const { - return layer_tree_host_->CommitRequested(); + NOTREACHED(); + return false; } void WebLayerTreeViewImplForTesting::composite() { diff --git a/content/test/web_layer_tree_view_impl_for_testing.h b/content/test/web_layer_tree_view_impl_for_testing.h index 6fec0e3..47fa8e2 100644 --- a/content/test/web_layer_tree_view_impl_for_testing.h +++ b/content/test/web_layer_tree_view_impl_for_testing.h @@ -48,8 +48,9 @@ class WebLayerTreeViewImplForTesting 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 composite(); virtual void didStopFlinging(); virtual bool compositeAndReadback(void* pixels, const blink::WebRect& rect); |