Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1623)

Unified Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 1050833002: cc: Remove background ticking from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/scheduler_test_common.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_animation.cc
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index e9b877d0ba6b154e6c41aaf029d78519d0132b6a..93202a0a57fdf7536e3f43f76ad98a48e5dc8add 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -223,235 +223,6 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted);
-// Ensures that animations continue to be ticked when we are backgrounded.
-class LayerTreeHostAnimationTestTickAnimationWhileBackgrounded
- : public LayerTreeHostAnimationTest {
- public:
- LayerTreeHostAnimationTestTickAnimationWhileBackgrounded()
- : num_begin_frames_(0) {}
-
- void BeginTest() override {
- PostAddLongAnimationToMainThread(layer_tree_host()->root_layer());
- }
-
- // Use WillAnimateLayers to set visible false before the animation runs and
- // causes a commit, so we block the second visible animate in single-thread
- // mode.
- void WillAnimateLayers(LayerTreeHostImpl* host_impl,
- base::TimeTicks monotonic_time) override {
- // Verify that the host can draw, it's just not visible.
- EXPECT_TRUE(host_impl->CanDraw());
- if (num_begin_frames_ < 2) {
- if (!num_begin_frames_) {
- // We have a long animation running. It should continue to tick even
- // if we are not visible.
- PostSetVisibleToMainThread(false);
- }
- num_begin_frames_++;
- return;
- }
- EndTest();
- }
-
- void AfterTest() override {}
-
- private:
- int num_begin_frames_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostAnimationTestTickAnimationWhileBackgrounded);
-
-// Ensures that animation time remains monotonic when we switch from foreground
-// to background ticking and back, even if we're skipping draws due to
-// checkerboarding when in the foreground.
-class LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic
- : public LayerTreeHostAnimationTest {
- public:
- LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic()
- : has_background_ticked_(false), num_foreground_animates_(0) {}
-
- void InitializeSettings(LayerTreeSettings* settings) override {
- // Make sure that drawing many times doesn't cause a checkerboarded
- // animation to start so we avoid flake in this test.
- settings->timeout_and_draw_when_animation_checkerboards = false;
- }
-
- void BeginTest() override {
- PostAddLongAnimationToMainThread(layer_tree_host()->root_layer());
- }
-
- void AnimateLayers(LayerTreeHostImpl* host_impl,
- base::TimeTicks monotonic_time) override {
- EXPECT_GE(monotonic_time, last_tick_time_);
- last_tick_time_ = monotonic_time;
- if (host_impl->visible()) {
- num_foreground_animates_++;
- if (num_foreground_animates_ > 1 && !has_background_ticked_)
- PostSetVisibleToMainThread(false);
- else if (has_background_ticked_)
- EndTest();
- } else {
- has_background_ticked_ = true;
- PostSetVisibleToMainThread(true);
- }
- }
-
- DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
- LayerTreeHostImpl::FrameData* frame,
- DrawResult draw_result) override {
- if (TestEnded())
- return draw_result;
- return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
- }
-
- void AfterTest() override {}
-
- private:
- bool has_background_ticked_;
- int num_foreground_animates_;
- base::TimeTicks last_tick_time_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostAnimationTestAnimationTickTimeIsMonotonic);
-
-// Ensures that animations do not tick when we are backgrounded and
-// and we have an empty active tree.
-class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree
- : public LayerTreeHostAnimationTest {
- protected:
- LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree()
- : active_tree_was_animated_(false) {}
-
- base::TimeDelta BackgroundAnimationInterval(LayerTreeHostImpl* host_impl) {
- return base::TimeDelta::FromSecondsD(
- 1.0 / host_impl->settings().background_animation_rate);
- }
-
- void BeginTest() override {
- PostAddAnimationToMainThread(layer_tree_host()->root_layer());
- }
-
- void NotifyAnimationFinished(base::TimeTicks monotonic_time,
- Animation::TargetProperty target_property,
- int group) override {
- // Replace animated commits with an empty tree.
- layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL));
- }
-
- void DidCommit() override {
- // This alternates setting an empty tree and a non-empty tree with an
- // animation.
- switch (layer_tree_host()->source_frame_number()) {
- case 1:
- // Wait for NotifyAnimationFinished to commit an empty tree.
- break;
- case 2:
- SetupTree();
- AddOpacityTransitionToLayer(
- layer_tree_host()->root_layer(), 0.000001, 0, 0.5, true);
- break;
- case 3:
- // Wait for NotifyAnimationFinished to commit an empty tree.
- break;
- case 4:
- EndTest();
- break;
- }
- }
-
- void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
- // At the start of every commit, block activations and make sure
- // we are backgrounded.
- if (host_impl->settings().impl_side_painting)
- host_impl->BlockNotifyReadyToActivateForTesting(true);
- PostSetVisibleToMainThread(false);
- }
-
- void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
- if (!host_impl->settings().impl_side_painting) {
- // There are no activations to block if we're not impl-side-painting,
- // so just advance the test immediately.
- if (host_impl->active_tree()->source_frame_number() < 3)
- UnblockActivations(host_impl);
- return;
- }
-
- // We block activation for several ticks to make sure that, even though
- // there is a pending tree with animations, we still do not background
- // tick if the active tree is empty.
- if (host_impl->pending_tree()->source_frame_number() < 3) {
- base::MessageLoopProxy::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(
- &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
- UnblockActivations,
- base::Unretained(this), host_impl),
- 4 * BackgroundAnimationInterval(host_impl));
- }
- }
-
- virtual void UnblockActivations(LayerTreeHostImpl* host_impl) {
- if (host_impl->settings().impl_side_painting)
- host_impl->BlockNotifyReadyToActivateForTesting(false);
- }
-
- void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
- active_tree_was_animated_ = false;
-
- // Verify that commits are actually alternating with empty / non-empty
- // trees.
- int frame_number = host_impl->active_tree()->source_frame_number();
- switch (frame_number) {
- case 0:
- case 2:
- EXPECT_TRUE(host_impl->active_tree()->root_layer())
- << "frame: " << frame_number;
- break;
- case 1:
- case 3:
- EXPECT_FALSE(host_impl->active_tree()->root_layer())
- << "frame: " << frame_number;
- break;
- }
-
- if (host_impl->active_tree()->source_frame_number() < 3) {
- // Initiate the next commit after a delay to give us a chance to
- // background tick if the active tree isn't empty.
- base::MessageLoopProxy::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(
- &LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree::
- InitiateNextCommit,
- base::Unretained(this), host_impl),
- 4 * BackgroundAnimationInterval(host_impl));
- }
- }
-
- void WillAnimateLayers(LayerTreeHostImpl* host_impl,
- base::TimeTicks monotonic_time) override {
- EXPECT_TRUE(host_impl->active_tree()->root_layer());
- active_tree_was_animated_ = true;
- }
-
- void InitiateNextCommit(LayerTreeHostImpl* host_impl) {
- // Verify that we actually animated when we should have.
- bool has_active_tree = host_impl->active_tree()->root_layer();
- EXPECT_EQ(has_active_tree, active_tree_was_animated_);
-
- // The next commit is blocked until we become visible again.
- PostSetVisibleToMainThread(true);
- }
-
- void AfterTest() override {}
-
- bool active_tree_was_animated_;
-};
-
-SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F(
- LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree);
-
// Ensure that an animation's timing function is respected.
class LayerTreeHostAnimationTestAddAnimationWithTimingFunction
: public LayerTreeHostAnimationTest {
@@ -821,58 +592,6 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw);
-// Make sure the main thread can still execute animations when the renderer is
-// backgrounded.
-class LayerTreeHostAnimationTestRunAnimationWhenNotVisible
- : public LayerTreeHostAnimationTest {
- public:
- LayerTreeHostAnimationTestRunAnimationWhenNotVisible() : started_times_(0) {}
-
- void SetupTree() override {
- LayerTreeHostAnimationTest::SetupTree();
- content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(4, 4));
- content_->set_layer_animation_delegate(this);
- layer_tree_host()->root_layer()->AddChild(content_);
- }
-
- void BeginTest() override {
- visible_ = true;
- PostAddAnimationToMainThread(content_.get());
- }
-
- void DidCommit() override {
- visible_ = false;
- layer_tree_host()->SetVisible(false);
- }
-
- void NotifyAnimationStarted(base::TimeTicks monotonic_time,
- Animation::TargetProperty target_property,
- int group) override {
- EXPECT_FALSE(visible_);
- started_times_++;
- }
-
- void NotifyAnimationFinished(base::TimeTicks monotonic_time,
- Animation::TargetProperty target_property,
- int group) override {
- EXPECT_FALSE(visible_);
- EXPECT_EQ(1, started_times_);
- EndTest();
- }
-
- void AfterTest() override {}
-
- private:
- bool visible_;
- int started_times_;
- FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostAnimationTestRunAnimationWhenNotVisible);
-
// Animations should not be started when frames are being skipped due to
// checkerboard.
class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
« no previous file with comments | « cc/test/scheduler_test_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698