diff options
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 4 | ||||
-rw-r--r-- | cc/scheduler/scheduler.cc | 2 | ||||
-rw-r--r-- | cc/scheduler/scheduler.h | 3 | ||||
-rw-r--r-- | cc/scheduler/scheduler_unittest.cc | 4 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 31 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 25 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 3 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 58 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 18 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 4 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 4 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 2 |
14 files changed, 122 insertions, 45 deletions
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 0913666..ae95212 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -390,7 +390,7 @@ class TileManagerPerfTest : public testing::Test { do { BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); - host_impl_.UpdateCurrentBeginFrameArgs(args); + host_impl_.WillBeginImplFrame(args); for (const auto& layer : layers) layer->UpdateTiles(resourceless_software_draw); @@ -398,7 +398,7 @@ class TileManagerPerfTest : public testing::Test { tile_manager()->PrepareTiles(global_state); tile_manager()->UpdateVisibleTiles(global_state); timer_.NextLap(); - host_impl_.ResetCurrentBeginFrameArgsForNextFrame(); + host_impl_.DidFinishImplFrame(); } while (!timer_.HasTimeLimitExpired()); perf_test::PrintResult("prepare_tiles", "", test_name, diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index afc908d..d252033 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -523,7 +523,7 @@ void Scheduler::FinishImplFrame() { state_machine_.OnBeginImplFrameIdle(); ProcessScheduledActions(); - client_->DidBeginImplFrameDeadline(); + client_->DidFinishImplFrame(); frame_source_->DidFinishFrame(begin_retro_frame_args_.size()); } diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h index 0076b4a..13daf00 100644 --- a/cc/scheduler/scheduler.h +++ b/cc/scheduler/scheduler.h @@ -46,8 +46,7 @@ class SchedulerClient { virtual base::TimeDelta DrawDurationEstimate() = 0; virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() = 0; virtual base::TimeDelta CommitToActivateDurationEstimate() = 0; - // TODO(sunnyps): Rename DidBeginImplFrameDeadline to DidFinishImplFrame. - virtual void DidBeginImplFrameDeadline() = 0; + virtual void DidFinishImplFrame() = 0; virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) = 0; virtual void SendBeginMainFrameNotExpectedSoon() = 0; diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index d17f0ba..2f878fd 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -105,6 +105,8 @@ class FakeSchedulerClient : public SchedulerClient { void WillBeginImplFrame(const BeginFrameArgs& args) override { PushAction("WillBeginImplFrame"); } + void DidFinishImplFrame() override {} + void ScheduledActionSendBeginMainFrame() override { PushAction("ScheduledActionSendBeginMainFrame"); } @@ -156,8 +158,6 @@ class FakeSchedulerClient : public SchedulerClient { return base::TimeDelta(); } - void DidBeginImplFrameDeadline() override {} - void SendBeginFramesToChildren(const BeginFrameArgs& args) override { begin_frame_args_sent_to_children_ = args; } diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 055d081..e782f08 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -81,11 +81,6 @@ class ThreadProxyForTest : public ThreadProxy { private: TestHooks* test_hooks_; - void WillBeginImplFrame(const BeginFrameArgs& args) override { - ThreadProxy::WillBeginImplFrame(args); - test_hooks_->WillBeginImplFrame(args); - } - void ScheduledActionSendBeginMainFrame() override { test_hooks_->ScheduledActionWillSendBeginMainFrame(); ThreadProxy::ScheduledActionSendBeginMainFrame(); @@ -123,6 +118,11 @@ class ThreadProxyForTest : public ThreadProxy { test_hooks_->ScheduledActionInvalidateOutputSurface(); } + void SendBeginMainFrameNotExpectedSoon() override { + ThreadProxy::SendBeginMainFrameNotExpectedSoon(); + test_hooks_->SendBeginMainFrameNotExpectedSoon(); + } + ThreadProxyForTest( TestHooks* test_hooks, LayerTreeHost* host, @@ -154,11 +154,6 @@ class SingleThreadProxyForTest : public SingleThreadProxy { private: TestHooks* test_hooks_; - void WillBeginImplFrame(const BeginFrameArgs& args) override { - SingleThreadProxy::WillBeginImplFrame(args); - test_hooks_->WillBeginImplFrame(args); - } - void ScheduledActionSendBeginMainFrame() override { test_hooks_->ScheduledActionWillSendBeginMainFrame(); SingleThreadProxy::ScheduledActionSendBeginMainFrame(); @@ -192,6 +187,16 @@ class SingleThreadProxyForTest : public SingleThreadProxy { test_hooks_->ScheduledActionPrepareTiles(); } + void ScheduledActionInvalidateOutputSurface() override { + SingleThreadProxy::ScheduledActionInvalidateOutputSurface(); + test_hooks_->ScheduledActionInvalidateOutputSurface(); + } + + void SendBeginMainFrameNotExpectedSoon() override { + SingleThreadProxy::SendBeginMainFrameNotExpectedSoon(); + test_hooks_->SendBeginMainFrameNotExpectedSoon(); + } + SingleThreadProxyForTest( TestHooks* test_hooks, LayerTreeHost* host, @@ -255,6 +260,11 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { test_hooks_->WillBeginImplFrameOnThread(this, args); } + void DidFinishImplFrame() override { + LayerTreeHostImpl::DidFinishImplFrame(); + test_hooks_->DidFinishImplFrameOnThread(this); + } + void BeginMainFrameAborted(CommitEarlyOutReason reason) override { LayerTreeHostImpl::BeginMainFrameAborted(reason); test_hooks_->BeginMainFrameAbortedOnThread(this, reason); @@ -712,6 +722,7 @@ void LayerTreeTest::Timeout() { } void LayerTreeTest::RealEndTest() { + // TODO(mithro): Make this method only end when not inside an impl frame. if (layer_tree_host_ && !timed_out_ && proxy()->MainFrameWillHappenForTesting()) { main_task_runner_->PostTask( diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 15ec215..7b48f3f 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -39,6 +39,7 @@ class TestHooks : public AnimationDelegate { scoped_ptr<ResourcePool>* staging_resource_pool); virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, const BeginFrameArgs& args) {} + virtual void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) {} virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, CommitEarlyOutReason reason) {} virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) {} @@ -87,10 +88,8 @@ class TestHooks : public AnimationDelegate { virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, bool visible) {} virtual void ScheduleComposite() {} - virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) {} // Hooks for SchedulerClient. - virtual void WillBeginImplFrame(const BeginFrameArgs& args) {} virtual void ScheduledActionWillSendBeginMainFrame() {} virtual void ScheduledActionSendBeginMainFrame() {} virtual void ScheduledActionDrawAndSwapIfPossible() {} @@ -99,6 +98,8 @@ class TestHooks : public AnimationDelegate { virtual void ScheduledActionBeginOutputSurfaceCreation() {} virtual void ScheduledActionPrepareTiles() {} virtual void ScheduledActionInvalidateOutputSurface() {} + virtual void SendBeginFramesToChildren(const BeginFrameArgs& args) {} + virtual void SendBeginMainFrameNotExpectedSoon() {} // Implementation of AnimationDelegate: void NotifyAnimationStarted(base::TimeTicks monotonic_time, diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 1c602b9..eea6236 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1671,7 +1671,12 @@ bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { // Sample the frame time now. This time will be used for updating animations // when we draw. - UpdateCurrentBeginFrameArgs(args); + DCHECK(!current_begin_frame_args_.IsValid()); + current_begin_frame_args_ = args; + // TODO(mithro): Stop overriding the frame time once the usage of frame + // timing is unified. + current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); + // Cache the begin impl frame interval begin_impl_frame_interval_ = args.interval; @@ -1686,6 +1691,11 @@ void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { it->OnBeginFrame(args); } +void LayerTreeHostImpl::DidFinishImplFrame() { + DCHECK(current_begin_frame_args_.IsValid()); + current_begin_frame_args_ = BeginFrameArgs(); +} + void LayerTreeHostImpl::UpdateViewportContainerSizes() { LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); @@ -3133,19 +3143,6 @@ TreePriority LayerTreeHostImpl::GetTreePriority() const { return global_tile_state_.tree_priority; } -void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs( - const BeginFrameArgs& args) { - DCHECK(!current_begin_frame_args_.IsValid()); - current_begin_frame_args_ = args; - // TODO(skyostil): Stop overriding the frame time once the usage of frame - // timing is unified. - current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); -} - -void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { - current_begin_frame_args_ = BeginFrameArgs(); -} - BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { // Try to use the current frame time to keep animations non-jittery. But if // we're not in a frame (because this is during an input event or a delayed diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index cec3f60..c09a2ab 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -342,6 +342,7 @@ class CC_EXPORT LayerTreeHostImpl virtual bool SwapBuffers(const FrameData& frame); virtual void WillBeginImplFrame(const BeginFrameArgs& args); + virtual void DidFinishImplFrame(); void DidModifyTilePriorities(); LayerTreeImpl* active_tree() { return active_tree_.get(); } @@ -445,8 +446,6 @@ class CC_EXPORT LayerTreeHostImpl void SetTreePriority(TreePriority priority); TreePriority GetTreePriority() const; - void UpdateCurrentBeginFrameArgs(const BeginFrameArgs& args); - void ResetCurrentBeginFrameArgsForNextFrame(); virtual BeginFrameArgs CurrentBeginFrameArgs() const; // Expected time between two begin impl frame calls. diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 5fcadfc..c4fd648 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -7664,7 +7664,7 @@ TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { EXPECT_FALSE(controller.begin_frame_args().IsValid()); host_impl_->AddVideoFrameController(&controller); EXPECT_TRUE(controller.begin_frame_args().IsValid()); - host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); + host_impl_->DidFinishImplFrame(); } TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { @@ -7673,7 +7673,7 @@ TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { FakeVideoFrameController controller; host_impl_->WillBeginImplFrame(begin_frame_args); - host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); + host_impl_->DidFinishImplFrame(); EXPECT_FALSE(controller.begin_frame_args().IsValid()); host_impl_->AddVideoFrameController(&controller); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index f2ed38e..ab40684 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2308,7 +2308,8 @@ class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { void BeginTest() override { PostSetNeedsCommitToMainThread(); } - void WillBeginImplFrame(const BeginFrameArgs& args) override { + void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, + const BeginFrameArgs& args) override { num_will_begin_impl_frame_++; switch (num_will_begin_impl_frame_) { case 1: @@ -5512,6 +5513,61 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); +class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame + : public LayerTreeHostTest { + public: + enum { kExpectedNumImplFrames = 10 }; + + LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() + : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} + + void BeginTest() override { + // Kick off the test with a commit. + PostSetNeedsCommitToMainThread(); + } + + void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, + const BeginFrameArgs& args) override { + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + EXPECT_FALSE(TestEnded()); + will_begin_impl_frame_count_++; + } + + void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { + did_finish_impl_frame_count_++; + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + + // Request a number of commits to cause multiple impl frames. We expect to + // get one more impl frames than the number of commits requested because + // after a commit it takes one frame to become idle. + if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1) + PostSetNeedsCommitToMainThread(); + } + + void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } + + void AfterTest() override { + EXPECT_GT(will_begin_impl_frame_count_, 0); + EXPECT_GT(did_finish_impl_frame_count_, 0); + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + + // TODO(mithro): Figure out why the multithread version of this test + // sometimes has one more frame then expected. Possibly related to + // http://crbug.com/443185 + if (!HasImplThread()) { + EXPECT_EQ(will_begin_impl_frame_count_, kExpectedNumImplFrames); + EXPECT_EQ(did_finish_impl_frame_count_, kExpectedNumImplFrames); + } + } + + private: + int will_begin_impl_frame_count_; + int did_finish_impl_frame_count_; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F( + LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); + class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { public: LayerTreeHostTestSendBeginFramesToChildren() diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 855d980..117af5d 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -45,7 +45,9 @@ SingleThreadProxy::SingleThreadProxy( client_(client), timing_history_(layer_tree_host->rendering_stats_instrumentation()), next_frame_is_newly_committed_frame_(false), +#if DCHECK_IS_ON() inside_impl_frame_(false), +#endif inside_draw_(false), defer_commits_(false), animate_requested_(false), @@ -587,7 +589,9 @@ void SingleThreadProxy::OnDrawForOutputSurface() { void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); DCHECK(Proxy::IsMainThread()); +#if DCHECK_IS_ON() DCHECK(!inside_impl_frame_); +#endif base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); if (layer_tree_host_->output_surface_lost()) { @@ -610,7 +614,9 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { // Run the "main thread" and get it to commit. { +#if DCHECK_IS_ON() DCHECK(inside_impl_frame_); +#endif DoBeginMainFrame(begin_frame_args); DoCommit(); @@ -639,7 +645,7 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { layer_tree_host_impl_->active_tree()->BreakSwapPromises( SwapPromise::SWAP_FAILS); - DidBeginImplFrameDeadline(); + DidFinishImplFrame(); } } @@ -798,9 +804,11 @@ void SingleThreadProxy::SetAuthoritativeVSyncInterval( } void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { +#if DCHECK_IS_ON() DCHECK(!inside_impl_frame_) << "WillBeginImplFrame called while already inside an impl frame!"; inside_impl_frame_ = true; +#endif layer_tree_host_impl_->WillBeginImplFrame(args); } @@ -813,8 +821,10 @@ void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { // fall on the next. Doing it asynchronously instead matches the semantics of // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a // synchronous commit. +#if DCHECK_IS_ON() DCHECK(inside_impl_frame_) << "BeginMainFrame should only be sent inside a BeginImplFrame"; +#endif const BeginFrameArgs& begin_frame_args = layer_tree_host_impl_->CurrentBeginFrameArgs(); @@ -978,11 +988,13 @@ base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { return timing_history_.CommitToActivateDurationEstimate(); } -void SingleThreadProxy::DidBeginImplFrameDeadline() { - layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); +void SingleThreadProxy::DidFinishImplFrame() { + layer_tree_host_impl_->DidFinishImplFrame(); +#if DCHECK_IS_ON() DCHECK(inside_impl_frame_) << "DidBeginImplFrameDeadline called while not inside an impl frame!"; inside_impl_frame_ = false; +#endif } void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index a148fef..98ac5e5 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -66,6 +66,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy, // SchedulerClient implementation void WillBeginImplFrame(const BeginFrameArgs& args) override; + void DidFinishImplFrame() override; void ScheduledActionSendBeginMainFrame() override; DrawResult ScheduledActionDrawAndSwapIfPossible() override; DrawResult ScheduledActionDrawAndSwapForced() override; @@ -79,7 +80,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy, base::TimeDelta DrawDurationEstimate() override; base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; base::TimeDelta CommitToActivateDurationEstimate() override; - void DidBeginImplFrameDeadline() override; void SendBeginFramesToChildren(const BeginFrameArgs& args) override; void SendBeginMainFrameNotExpectedSoon() override; @@ -159,7 +159,9 @@ class CC_EXPORT SingleThreadProxy : public Proxy, scoped_ptr<ResourceUpdateQueue> queue_for_commit_; bool next_frame_is_newly_committed_frame_; +#if DCHECK_IS_ON() bool inside_impl_frame_; +#endif bool inside_draw_; bool defer_commits_; bool animate_requested_; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index bd1d235..3010fba 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -1162,8 +1162,8 @@ base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() { return impl().timing_history.CommitToActivateDurationEstimate(); } -void ThreadProxy::DidBeginImplFrameDeadline() { - impl().layer_tree_host_impl->ResetCurrentBeginFrameArgsForNextFrame(); +void ThreadProxy::DidFinishImplFrame() { + impl().layer_tree_host_impl->DidFinishImplFrame(); } void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index fae18b1..f4f1f28 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -220,6 +220,7 @@ class CC_EXPORT ThreadProxy : public Proxy, // SchedulerClient implementation void WillBeginImplFrame(const BeginFrameArgs& args) override; + void DidFinishImplFrame() override; void ScheduledActionSendBeginMainFrame() override; DrawResult ScheduledActionDrawAndSwapIfPossible() override; DrawResult ScheduledActionDrawAndSwapForced() override; @@ -233,7 +234,6 @@ class CC_EXPORT ThreadProxy : public Proxy, base::TimeDelta DrawDurationEstimate() override; base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; base::TimeDelta CommitToActivateDurationEstimate() override; - void DidBeginImplFrameDeadline() override; void SendBeginFramesToChildren(const BeginFrameArgs& args) override; void SendBeginMainFrameNotExpectedSoon() override; |