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

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

Issue 1904653002: CC Animation: Merge LayerAnimationController into ElementAnimations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor optimization: Don't init value observations if same host. Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.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"
11 #include "cc/animation/animation_id_provider.h" 11 #include "cc/animation/animation_id_provider.h"
12 #include "cc/animation/animation_player.h" 12 #include "cc/animation/animation_player.h"
13 #include "cc/animation/animation_timeline.h" 13 #include "cc/animation/animation_timeline.h"
14 #include "cc/animation/element_animations.h" 14 #include "cc/animation/element_animations.h"
15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/scroll_offset_animation_curve.h" 15 #include "cc/animation/scroll_offset_animation_curve.h"
17 #include "cc/animation/timing_function.h" 16 #include "cc/animation/timing_function.h"
18 #include "cc/animation/transform_operations.h" 17 #include "cc/animation/transform_operations.h"
19 #include "cc/base/completion_event.h" 18 #include "cc/base/completion_event.h"
20 #include "cc/base/time_util.h" 19 #include "cc/base/time_util.h"
21 #include "cc/layers/layer.h" 20 #include "cc/layers/layer.h"
22 #include "cc/layers/layer_impl.h" 21 #include "cc/layers/layer_impl.h"
23 #include "cc/test/animation_test_common.h" 22 #include "cc/test/animation_test_common.h"
24 #include "cc/test/fake_content_layer_client.h" 23 #include "cc/test/fake_content_layer_client.h"
25 #include "cc/test/fake_picture_layer.h" 24 #include "cc/test/fake_picture_layer.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 void BeginTest() override { 224 void BeginTest() override {
226 AttachPlayersToTimeline(); 225 AttachPlayersToTimeline();
227 player_->AttachLayer(layer_tree_host()->root_layer()->id()); 226 player_->AttachLayer(layer_tree_host()->root_layer()->id());
228 PostAddAnimationToMainThreadPlayer(player_.get()); 227 PostAddAnimationToMainThreadPlayer(player_.get());
229 } 228 }
230 229
231 void AnimateLayers(LayerTreeHostImpl* host_impl, 230 void AnimateLayers(LayerTreeHostImpl* host_impl,
232 base::TimeTicks monotonic_time) override { 231 base::TimeTicks monotonic_time) override {
233 bool have_animations = !host_impl->animation_host() 232 bool have_animations = !host_impl->animation_host()
234 ->active_animation_controllers_for_testing() 233 ->active_element_animations_for_testing()
235 .empty(); 234 .empty();
236 if (!started_animating_ && have_animations) { 235 if (!started_animating_ && have_animations) {
237 started_animating_ = true; 236 started_animating_ = true;
238 return; 237 return;
239 } 238 }
240 239
241 if (started_animating_ && !have_animations) 240 if (started_animating_ && !have_animations)
242 EndTest(); 241 EndTest();
243 } 242 }
244 243
245 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 244 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
246 TargetProperty::Type target_property, 245 TargetProperty::Type target_property,
247 int group) override { 246 int group) override {
248 // Animations on the impl-side controller only get deleted during a commit, 247 // Animations on the impl-side ElementAnimations only get deleted during
249 // so we need to schedule a commit. 248 // a commit, so we need to schedule a commit.
250 layer_tree_host()->SetNeedsCommit(); 249 layer_tree_host()->SetNeedsCommit();
251 } 250 }
252 251
253 void AfterTest() override {} 252 void AfterTest() override {}
254 253
255 private: 254 private:
256 bool started_animating_; 255 bool started_animating_;
257 }; 256 };
258 257
259 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted); 258 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAnimationsGetDeleted);
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false); 1157 AddOpacityTransitionToPlayer(player_child_.get(), 0.1, 5, 5, false);
1159 break; 1158 break;
1160 } 1159 }
1161 } 1160 }
1162 1161
1163 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1162 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1164 // After both animations have started, verify that they have valid 1163 // After both animations have started, verify that they have valid
1165 // start times. 1164 // start times.
1166 if (host_impl->active_tree()->source_frame_number() < 2) 1165 if (host_impl->active_tree()->source_frame_number() < 2)
1167 return; 1166 return;
1168 AnimationHost::AnimationControllerMap controllers_copy = 1167 AnimationHost::LayerToElementAnimationsMap element_animations_copy =
1169 host_impl->animation_host()->active_animation_controllers_for_testing(); 1168 host_impl->animation_host()->active_element_animations_for_testing();
1170 EXPECT_EQ(2u, controllers_copy.size()); 1169 EXPECT_EQ(2u, element_animations_copy.size());
1171 for (auto& it : controllers_copy) { 1170 for (auto& it : element_animations_copy) {
1172 int id = it.first; 1171 int id = it.first;
1173 if (id == host_impl->RootLayer()->id()) { 1172 if (id == host_impl->RootLayer()->id()) {
1174 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); 1173 Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM);
1175 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1174 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1176 } else if (id == host_impl->RootLayer()->children()[0]->id()) { 1175 } else if (id == host_impl->RootLayer()->children()[0]->id()) {
1177 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); 1176 Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY);
1178 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1177 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1179 } 1178 }
1180 EndTest(); 1179 EndTest();
1181 } 1180 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 bool called_animation_started_; 1473 bool called_animation_started_;
1475 bool called_animation_finished_; 1474 bool called_animation_finished_;
1476 FakeContentLayerClient client_; 1475 FakeContentLayerClient client_;
1477 scoped_refptr<FakePictureLayer> picture_; 1476 scoped_refptr<FakePictureLayer> picture_;
1478 }; 1477 };
1479 1478
1480 SINGLE_AND_MULTI_THREAD_TEST_F( 1479 SINGLE_AND_MULTI_THREAD_TEST_F(
1481 LayerTreeHostAnimationTestNotifyAnimationFinished); 1480 LayerTreeHostAnimationTestNotifyAnimationFinished);
1482 1481
1483 // Check that SetTransformIsPotentiallyAnimatingChanged is called 1482 // Check that SetTransformIsPotentiallyAnimatingChanged is called
1484 // if we destroy LayerAnimationController and ElementAnimations. 1483 // if we destroy ElementAnimations.
1485 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction 1484 class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction
1486 : public LayerTreeHostAnimationTest { 1485 : public LayerTreeHostAnimationTest {
1487 public: 1486 public:
1488 void SetupTree() override { 1487 void SetupTree() override {
1489 prev_screen_space_transform_is_animating_ = true; 1488 prev_screen_space_transform_is_animating_ = true;
1490 screen_space_transform_animation_stopped_ = false; 1489 screen_space_transform_animation_stopped_ = false;
1491 1490
1492 LayerTreeHostAnimationTest::SetupTree(); 1491 LayerTreeHostAnimationTest::SetupTree();
1493 AttachPlayersToTimeline(); 1492 AttachPlayersToTimeline();
1494 player_->AttachLayer(layer_tree_host()->root_layer()->id()); 1493 player_->AttachLayer(layer_tree_host()->root_layer()->id());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 private: 1605 private:
1607 scoped_refptr<Layer> layer_; 1606 scoped_refptr<Layer> layer_;
1608 FakeContentLayerClient client_; 1607 FakeContentLayerClient client_;
1609 }; 1608 };
1610 1609
1611 MULTI_THREAD_TEST_F( 1610 MULTI_THREAD_TEST_F(
1612 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit); 1611 LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit);
1613 1612
1614 } // namespace 1613 } // namespace
1615 } // namespace cc 1614 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698