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

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 2090793002: cc: Fix property tree animation sync bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "TransformOperations" Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "cc/animation/animation_curve.h" 9 #include "cc/animation/animation_curve.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 private: 1638 private:
1639 bool called_animation_started_; 1639 bool called_animation_started_;
1640 bool called_animation_finished_; 1640 bool called_animation_finished_;
1641 FakeContentLayerClient client_; 1641 FakeContentLayerClient client_;
1642 scoped_refptr<FakePictureLayer> picture_; 1642 scoped_refptr<FakePictureLayer> picture_;
1643 }; 1643 };
1644 1644
1645 SINGLE_AND_MULTI_THREAD_TEST_F( 1645 SINGLE_AND_MULTI_THREAD_TEST_F(
1646 LayerTreeHostAnimationTestNotifyAnimationFinished); 1646 LayerTreeHostAnimationTestNotifyAnimationFinished);
1647 1647
1648 // Check that transform sync happens correctly at commit when we remove and add
1649 // a different animation player to an element.
1650 class LayerTreeHostAnimationTestChangeAnimationPlayer
1651 : public LayerTreeHostAnimationTest {
1652 public:
1653 void SetupTree() override {
1654 LayerTreeHostAnimationTest::SetupTree();
1655 AttachPlayersToTimeline();
1656 timeline_->DetachPlayer(player_child_.get());
1657 player_->AttachElement(layer_tree_host()->root_layer()->id());
1658
1659 TransformOperations start;
1660 start.AppendTranslate(5.f, 5.f, 0.f);
1661 TransformOperations end;
1662 end.AppendTranslate(5.f, 5.f, 0.f);
1663 AddAnimatedTransformToPlayer(player_.get(), 1.0, start, end);
1664 }
1665
1666 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1667
1668 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1669 PropertyTrees* property_trees = host_impl->sync_tree()->property_trees();
1670 TransformNode* node = property_trees->transform_tree.Node(
1671 host_impl->sync_tree()->root_layer()->transform_tree_index());
1672 gfx::Transform translate;
1673 translate.Translate(5, 5);
1674 switch (host_impl->sync_tree()->source_frame_number()) {
1675 case 2:
1676 EXPECT_EQ(node->data.local, translate);
1677 EndTest();
1678 break;
1679 default:
1680 break;
1681 }
1682 }
1683
1684 void DidCommit() override { PostSetNeedsCommitToMainThread(); }
1685
1686 void WillBeginMainFrame() override {
1687 if (layer_tree_host()->source_frame_number() == 2) {
1688 // Destroy player.
1689 timeline_->DetachPlayer(player_.get());
1690 player_ = nullptr;
1691 timeline_->AttachPlayer(player_child_.get());
1692 player_child_->AttachElement(layer_tree_host()->root_layer()->id());
1693 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10);
1694 Animation* animation = player_child_->element_animations()->GetAnimation(
1695 TargetProperty::TRANSFORM);
1696 animation->set_start_time(base::TimeTicks::Now() +
1697 base::TimeDelta::FromSecondsD(1000));
1698 animation->set_fill_mode(Animation::FillMode::NONE);
1699 }
1700 }
1701
1702 void AfterTest() override {}
1703 };
1704
1705 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestChangeAnimationPlayer);
1706
1648 // Check that SetTransformIsPotentiallyAnimatingChanged is called 1707 // Check that SetTransformIsPotentiallyAnimatingChanged is called
1649 // if we destroy ElementAnimations. 1708 // if we destroy ElementAnimations.
1650 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1709 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1651 : public LayerTreeHostAnimationTest { 1710 : public LayerTreeHostAnimationTest {
1652 public: 1711 public:
1653 void SetupTree() override { 1712 void SetupTree() override {
1654 prev_screen_space_transform_is_animating_ = true; 1713 prev_screen_space_transform_is_animating_ = true;
1655 screen_space_transform_animation_stopped_ = false; 1714 screen_space_transform_animation_stopped_ = false;
1656 1715
1657 LayerTreeHostAnimationTest::SetupTree(); 1716 LayerTreeHostAnimationTest::SetupTree();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 private: 1830 private:
1772 scoped_refptr<Layer> layer_; 1831 scoped_refptr<Layer> layer_;
1773 FakeContentLayerClient client_; 1832 FakeContentLayerClient client_;
1774 }; 1833 };
1775 1834
1776 MULTI_THREAD_TEST_F( 1835 MULTI_THREAD_TEST_F(
1777 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1836 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1778 1837
1779 } // namespace 1838 } // namespace
1780 } // namespace cc 1839 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698