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

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

Issue 948243003: cc: Misc animation refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address danakj's comment. Created 5 years, 10 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_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('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 "cc/animation/animation_curve.h" 7 #include "cc/animation/animation_curve.h"
8 #include "cc/animation/layer_animation_controller.h" 8 #include "cc/animation/layer_animation_controller.h"
9 #include "cc/animation/scroll_offset_animation_curve.h" 9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 public: 188 public:
189 LayerTreeHostAnimationTestAnimationsGetDeleted() 189 LayerTreeHostAnimationTestAnimationsGetDeleted()
190 : started_animating_(false) {} 190 : started_animating_(false) {}
191 191
192 void BeginTest() override { 192 void BeginTest() override {
193 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 193 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
194 } 194 }
195 195
196 void AnimateLayers(LayerTreeHostImpl* host_impl, 196 void AnimateLayers(LayerTreeHostImpl* host_impl,
197 base::TimeTicks monotonic_time) override { 197 base::TimeTicks monotonic_time) override {
198 bool have_animations = !host_impl->animation_registrar()-> 198 bool have_animations = !host_impl->animation_registrar()
199 active_animation_controllers().empty(); 199 ->active_animation_controllers()
200 .empty();
200 if (!started_animating_ && have_animations) { 201 if (!started_animating_ && have_animations) {
201 started_animating_ = true; 202 started_animating_ = true;
202 return; 203 return;
203 } 204 }
204 205
205 if (started_animating_ && !have_animations) 206 if (started_animating_ && !have_animations)
206 EndTest(); 207 EndTest();
207 } 208 }
208 209
209 void NotifyAnimationFinished(base::TimeTicks monotonic_time, 210 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 // animation has caused us to animate already during this frame. 1235 // animation has caused us to animate already during this frame.
1235 AddOpacityTransitionToLayer(content_.get(), 0.1, 5, 5, false); 1236 AddOpacityTransitionToLayer(content_.get(), 0.1, 5, 5, false);
1236 break; 1237 break;
1237 } 1238 }
1238 } 1239 }
1239 1240
1240 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { 1241 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
1241 // After both animations have started, verify that they have valid 1242 // After both animations have started, verify that they have valid
1242 // start times. 1243 // start times.
1243 num_swap_buffers_++; 1244 num_swap_buffers_++;
1244 AnimationRegistrar::AnimationControllerMap copy = 1245 AnimationRegistrar::AnimationControllerMap controllers_copy =
1245 host_impl->animation_registrar()->active_animation_controllers(); 1246 host_impl->animation_registrar()->active_animation_controllers();
1246 if (copy.size() == 2u) { 1247 if (controllers_copy.size() == 2u) {
1247 EndTest(); 1248 EndTest();
1248 EXPECT_GE(num_swap_buffers_, 3); 1249 EXPECT_GE(num_swap_buffers_, 3);
1249 for (AnimationRegistrar::AnimationControllerMap::iterator iter = 1250 for (auto& it : controllers_copy) {
1250 copy.begin(); 1251 int id = it.first;
1251 iter != copy.end();
1252 ++iter) {
1253 int id = ((*iter).second->id());
1254 if (id == host_impl->RootLayer()->id()) { 1252 if (id == host_impl->RootLayer()->id()) {
1255 Animation* anim = (*iter).second->GetAnimation(Animation::TRANSFORM); 1253 Animation* anim = it.second->GetAnimation(Animation::TRANSFORM);
1256 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1254 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1257 } else if (id == host_impl->RootLayer()->children()[0]->id()) { 1255 } else if (id == host_impl->RootLayer()->children()[0]->id()) {
1258 Animation* anim = (*iter).second->GetAnimation(Animation::OPACITY); 1256 Animation* anim = it.second->GetAnimation(Animation::OPACITY);
1259 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); 1257 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0);
1260 } 1258 }
1261 } 1259 }
1262 } 1260 }
1263 } 1261 }
1264 1262
1265 void AfterTest() override {} 1263 void AfterTest() override {}
1266 1264
1267 private: 1265 private:
1268 scoped_refptr<Layer> content_; 1266 scoped_refptr<Layer> content_;
1269 int num_swap_buffers_; 1267 int num_swap_buffers_;
1270 }; 1268 };
1271 1269
1272 SINGLE_AND_MULTI_THREAD_TEST_F( 1270 SINGLE_AND_MULTI_THREAD_TEST_F(
1273 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1271 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1274 1272
1275 } // namespace 1273 } // namespace
1276 } // namespace cc 1274 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698