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

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

Issue 1801853002: Transfer LayerImpl ownership to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more asan. Created 4 years, 9 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_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 host_impl->BlockNotifyReadyToActivateForTesting(false); 827 host_impl->BlockNotifyReadyToActivateForTesting(false);
828 return; 828 return;
829 } 829 }
830 830
831 scoped_refptr<AnimationTimeline> timeline_impl = 831 scoped_refptr<AnimationTimeline> timeline_impl =
832 host_impl->animation_host()->GetTimelineById(timeline_id_); 832 host_impl->animation_host()->GetTimelineById(timeline_id_);
833 scoped_refptr<AnimationPlayer> player_impl = 833 scoped_refptr<AnimationPlayer> player_impl =
834 timeline_impl->GetPlayerById(player_child_id_); 834 timeline_impl->GetPlayerById(player_child_id_);
835 835
836 LayerImpl* scroll_layer_impl = 836 LayerImpl* scroll_layer_impl =
837 host_impl->active_tree()->root_layer()->children()[0].get(); 837 host_impl->active_tree()->root_layer()->children()[0];
838 Animation* animation = player_impl->element_animations() 838 Animation* animation = player_impl->element_animations()
839 ->layer_animation_controller() 839 ->layer_animation_controller()
840 ->GetAnimation(TargetProperty::SCROLL_OFFSET); 840 ->GetAnimation(TargetProperty::SCROLL_OFFSET);
841 841
842 if (!animation || animation->run_state() != Animation::RUNNING) { 842 if (!animation || animation->run_state() != Animation::RUNNING) {
843 host_impl->BlockNotifyReadyToActivateForTesting(false); 843 host_impl->BlockNotifyReadyToActivateForTesting(false);
844 return; 844 return;
845 } 845 }
846 846
847 // Block activation until the running animation has a chance to produce a 847 // Block activation until the running animation has a chance to produce a
848 // scroll delta. 848 // scroll delta.
849 gfx::Vector2dF scroll_delta = ScrollDelta(scroll_layer_impl); 849 gfx::Vector2dF scroll_delta = ScrollDelta(scroll_layer_impl);
850 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) 850 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f)
851 return; 851 return;
852 852
853 host_impl->BlockNotifyReadyToActivateForTesting(false); 853 host_impl->BlockNotifyReadyToActivateForTesting(false);
854 } 854 }
855 855
856 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 856 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
857 if (host_impl->pending_tree()->source_frame_number() != 1) 857 if (host_impl->pending_tree()->source_frame_number() != 1)
858 return; 858 return;
859 LayerImpl* scroll_layer_impl = 859 LayerImpl* scroll_layer_impl =
860 host_impl->pending_tree()->root_layer()->children()[0].get(); 860 host_impl->pending_tree()->root_layer()->children()[0];
861 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); 861 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset());
862 } 862 }
863 863
864 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 864 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
865 if (host_impl->active_tree()->source_frame_number() != 1) 865 if (host_impl->active_tree()->source_frame_number() != 1)
866 return; 866 return;
867 LayerImpl* scroll_layer_impl = 867 LayerImpl* scroll_layer_impl =
868 host_impl->active_tree()->root_layer()->children()[0].get(); 868 host_impl->active_tree()->root_layer()->children()[0];
869 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset()); 869 EXPECT_EQ(final_postion_, scroll_layer_impl->CurrentScrollOffset());
870 EndTest(); 870 EndTest();
871 } 871 }
872 872
873 void AfterTest() override { 873 void AfterTest() override {
874 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); 874 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset());
875 } 875 }
876 876
877 private: 877 private:
878 FakeContentLayerClient client_; 878 FakeContentLayerClient client_;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1023
1024 scoped_refptr<AnimationTimeline> timeline_impl = 1024 scoped_refptr<AnimationTimeline> timeline_impl =
1025 host_impl->animation_host()->GetTimelineById(timeline_id_); 1025 host_impl->animation_host()->GetTimelineById(timeline_id_);
1026 scoped_refptr<AnimationPlayer> player_impl = 1026 scoped_refptr<AnimationPlayer> player_impl =
1027 timeline_impl->GetPlayerById(player_id_); 1027 timeline_impl->GetPlayerById(player_id_);
1028 1028
1029 LayerAnimationController* controller_impl = 1029 LayerAnimationController* controller_impl =
1030 player_impl->element_animations()->layer_animation_controller(); 1030 player_impl->element_animations()->layer_animation_controller();
1031 1031
1032 LayerImpl* root = host_impl->sync_tree()->root_layer(); 1032 LayerImpl* root = host_impl->sync_tree()->root_layer();
1033 LayerImpl* child = root->children()[0].get(); 1033 LayerImpl* child = root->children()[0];
1034 Animation* animation = 1034 Animation* animation =
1035 controller_impl->GetAnimation(TargetProperty::TRANSFORM); 1035 controller_impl->GetAnimation(TargetProperty::TRANSFORM);
1036 1036
1037 // The animation should be starting for the first frame. 1037 // The animation should be starting for the first frame.
1038 EXPECT_EQ(Animation::STARTING, animation->run_state()); 1038 EXPECT_EQ(Animation::STARTING, animation->run_state());
1039 1039
1040 // And the transform should be propogated to the sync tree layer, at its 1040 // And the transform should be propogated to the sync tree layer, at its
1041 // starting state which is 6,7. 1041 // starting state which is 6,7.
1042 gfx::Transform expected_transform; 1042 gfx::Transform expected_transform;
1043 expected_transform.Translate(6.0, 7.0); 1043 expected_transform.Translate(6.0, 7.0);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 // added/deleted when something triggers a rebuild. Adding a layer 1262 // added/deleted when something triggers a rebuild. Adding a layer
1263 // triggers a rebuild, and since the layer that had an animation before 1263 // triggers a rebuild, and since the layer that had an animation before
1264 // no longer has one, it doesn't get a transform node in the rebuild. 1264 // no longer has one, it doesn't get a transform node in the rebuild.
1265 layer_->AddChild(Layer::Create()); 1265 layer_->AddChild(Layer::Create());
1266 break; 1266 break;
1267 } 1267 }
1268 } 1268 }
1269 1269
1270 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 1270 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1271 LayerImpl* root = host_impl->active_tree()->root_layer(); 1271 LayerImpl* root = host_impl->active_tree()->root_layer();
1272 LayerImpl* child = root->children()[0].get(); 1272 LayerImpl* child = root->children()[0];
1273 switch (host_impl->active_tree()->source_frame_number()) { 1273 switch (host_impl->active_tree()->source_frame_number()) {
1274 case 0: 1274 case 0:
1275 // No animation yet. 1275 // No animation yet.
1276 break; 1276 break;
1277 case 1: 1277 case 1:
1278 // Animation is started. 1278 // Animation is started.
1279 EXPECT_TRUE(child->screen_space_transform_is_animating()); 1279 EXPECT_TRUE(child->screen_space_transform_is_animating());
1280 break; 1280 break;
1281 case 2: { 1281 case 2: {
1282 // The animation is removed, the transform that was set afterward is 1282 // The animation is removed, the transform that was set afterward is
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 player_->element_animations()->layer_animation_controller(); 1328 player_->element_animations()->layer_animation_controller();
1329 Animation* animation = 1329 Animation* animation =
1330 controller->GetAnimation(TargetProperty::TRANSFORM); 1330 controller->GetAnimation(TargetProperty::TRANSFORM);
1331 player_->RemoveAnimation(animation->id()); 1331 player_->RemoveAnimation(animation->id());
1332 break; 1332 break;
1333 } 1333 }
1334 } 1334 }
1335 1335
1336 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1336 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1337 LayerImpl* root = host_impl->sync_tree()->root_layer(); 1337 LayerImpl* root = host_impl->sync_tree()->root_layer();
1338 LayerImpl* child = root->children()[0].get(); 1338 LayerImpl* child = root->children()[0];
1339 switch (host_impl->sync_tree()->source_frame_number()) { 1339 switch (host_impl->sync_tree()->source_frame_number()) {
1340 case 0: 1340 case 0:
1341 // No animation yet. 1341 // No animation yet.
1342 break; 1342 break;
1343 case 1: 1343 case 1:
1344 // Animation is started. 1344 // Animation is started.
1345 EXPECT_TRUE(child->screen_space_transform_is_animating()); 1345 EXPECT_TRUE(child->screen_space_transform_is_animating());
1346 break; 1346 break;
1347 case 2: 1347 case 2:
1348 // The animation is removed/stopped. 1348 // The animation is removed/stopped.
1349 EXPECT_FALSE(child->screen_space_transform_is_animating()); 1349 EXPECT_FALSE(child->screen_space_transform_is_animating());
1350 EndTest(); 1350 EndTest();
1351 break; 1351 break;
1352 default: 1352 default:
1353 NOTREACHED(); 1353 NOTREACHED();
1354 } 1354 }
1355 } 1355 }
1356 1356
1357 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 1357 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
1358 LayerImpl* root = host_impl->active_tree()->root_layer(); 1358 LayerImpl* root = host_impl->active_tree()->root_layer();
1359 LayerImpl* child = root->children()[0].get(); 1359 LayerImpl* child = root->children()[0];
1360 switch (host_impl->active_tree()->source_frame_number()) { 1360 switch (host_impl->active_tree()->source_frame_number()) {
1361 case 0: 1361 case 0:
1362 // No animation yet. 1362 // No animation yet.
1363 break; 1363 break;
1364 case 1: 1364 case 1:
1365 // Animation is started. 1365 // Animation is started.
1366 EXPECT_TRUE(child->screen_space_transform_is_animating()); 1366 EXPECT_TRUE(child->screen_space_transform_is_animating());
1367 break; 1367 break;
1368 case 2: 1368 case 2:
1369 // The animation is removed/stopped. 1369 // The animation is removed/stopped.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 1423
1424 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1424 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
1425 switch (host_impl->sync_tree()->source_frame_number()) { 1425 switch (host_impl->sync_tree()->source_frame_number()) {
1426 case 1: 1426 case 1:
1427 PostSetNeedsCommitToMainThread(); 1427 PostSetNeedsCommitToMainThread();
1428 break; 1428 break;
1429 case 2: 1429 case 2:
1430 gfx::Transform expected_transform; 1430 gfx::Transform expected_transform;
1431 expected_transform.Translate(5.f, 5.f); 1431 expected_transform.Translate(5.f, 5.f);
1432 LayerImpl* layer_impl = 1432 LayerImpl* layer_impl =
1433 host_impl->sync_tree()->root_layer()->children()[0].get(); 1433 host_impl->sync_tree()->root_layer()->children()[0];
1434 EXPECT_EQ(expected_transform, layer_impl->DrawTransform()); 1434 EXPECT_EQ(expected_transform, layer_impl->DrawTransform());
1435 EndTest(); 1435 EndTest();
1436 break; 1436 break;
1437 } 1437 }
1438 } 1438 }
1439 1439
1440 void UpdateAnimationState(LayerTreeHostImpl* host_impl, 1440 void UpdateAnimationState(LayerTreeHostImpl* host_impl,
1441 bool has_unfinished_animation) override { 1441 bool has_unfinished_animation) override {
1442 if (host_impl->active_tree()->source_frame_number() == 1 && 1442 if (host_impl->active_tree()->source_frame_number() == 1 &&
1443 !has_unfinished_animation && !signalled_) { 1443 !has_unfinished_animation && !signalled_) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 private: 1639 private:
1640 scoped_refptr<Layer> layer_; 1640 scoped_refptr<Layer> layer_;
1641 FakeContentLayerClient client_; 1641 FakeContentLayerClient client_;
1642 }; 1642 };
1643 1643
1644 MULTI_THREAD_TEST_F( 1644 MULTI_THREAD_TEST_F(
1645 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1645 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1646 1646
1647 } // namespace 1647 } // namespace
1648 } // namespace cc 1648 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698