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

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

Issue 719453007: Make Keyframe use TimeTicks/TimeDelta to represent time instead of double. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/test/layer_tree_test.cc ('k') | ui/compositor/float_animation_curve_adapter.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"
11 #include "cc/base/time_util.h"
11 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
12 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
13 #include "cc/test/animation_test_common.h" 14 #include "cc/test/animation_test_common.h"
14 #include "cc/test/fake_content_layer.h" 15 #include "cc/test/fake_content_layer.h"
15 #include "cc/test/fake_content_layer_client.h" 16 #include "cc/test/fake_content_layer_client.h"
16 #include "cc/test/layer_tree_test.h" 17 #include "cc/test/layer_tree_test.h"
17 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
18 19
19 namespace cc { 20 namespace cc {
20 namespace { 21 namespace {
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 LayerAnimationController* controller_impl = 497 LayerAnimationController* controller_impl =
497 host_impl->active_tree()->root_layer()->children()[0]-> 498 host_impl->active_tree()->root_layer()->children()[0]->
498 layer_animation_controller(); 499 layer_animation_controller();
499 Animation* animation = 500 Animation* animation =
500 controller_impl->GetAnimation(Animation::Opacity); 501 controller_impl->GetAnimation(Animation::Opacity);
501 if (!animation) 502 if (!animation)
502 return; 503 return;
503 504
504 const FloatAnimationCurve* curve = 505 const FloatAnimationCurve* curve =
505 animation->curve()->ToFloatAnimationCurve(); 506 animation->curve()->ToFloatAnimationCurve();
506 float start_opacity = curve->GetValue(0.0); 507 float start_opacity = curve->GetValue(base::TimeDelta());
507 float end_opacity = curve->GetValue(curve->Duration().InSecondsF()); 508 float end_opacity = curve->GetValue(curve->Duration());
508 float linearly_interpolated_opacity = 509 float linearly_interpolated_opacity =
509 0.25f * end_opacity + 0.75f * start_opacity; 510 0.25f * end_opacity + 0.75f * start_opacity;
510 double time = curve->Duration().InSecondsF() * 0.25; 511 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f);
511 // If the linear timing function associated with this animation was not 512 // If the linear timing function associated with this animation was not
512 // picked up, then the linearly interpolated opacity would be different 513 // picked up, then the linearly interpolated opacity would be different
513 // because of the default ease timing function. 514 // because of the default ease timing function.
515
ajuma 2014/11/18 14:58:14 Please remove this blank line.
patro 2014/11/18 15:04:52 Done.
514 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); 516 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time));
515 517
516 EndTest(); 518 EndTest();
517 } 519 }
518 520
519 void AfterTest() override {} 521 void AfterTest() override {}
520 522
521 FakeContentLayerClient client_; 523 FakeContentLayerClient client_;
522 scoped_refptr<FakeContentLayer> content_; 524 scoped_refptr<FakeContentLayer> content_;
523 }; 525 };
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 private: 1194 private:
1193 scoped_refptr<Layer> content_; 1195 scoped_refptr<Layer> content_;
1194 int num_swap_buffers_; 1196 int num_swap_buffers_;
1195 }; 1197 };
1196 1198
1197 SINGLE_AND_MULTI_THREAD_TEST_F( 1199 SINGLE_AND_MULTI_THREAD_TEST_F(
1198 LayerTreeHostAnimationTestAddAnimationAfterAnimating); 1200 LayerTreeHostAnimationTestAddAnimationAfterAnimating);
1199 1201
1200 } // namespace 1202 } // namespace
1201 } // namespace cc 1203 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | ui/compositor/float_animation_curve_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698