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

Unified Diff: cc/test/animation_test_common.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/animation_test_common.h ('k') | cc/test/geometry_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/animation_test_common.cc
diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
index fba316669fdde60797c2f3d81d3858cf89f4f5df..602374f00071275f0e8c8f61cc9e4b62c430e492 100644
--- a/cc/test/animation_test_common.cc
+++ b/cc/test/animation_test_common.cc
@@ -8,6 +8,7 @@
#include "cc/animation/keyframed_animation_curve.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/animation/transform_operations.h"
+#include "cc/base/time_util.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
@@ -35,8 +36,10 @@ int AddOpacityTransition(Target* target,
if (!use_timing_function)
func = EaseTimingFunction::Create();
if (duration > 0.0)
- curve->AddKeyframe(FloatKeyframe::Create(0.0, start_opacity, func.Pass()));
- curve->AddKeyframe(FloatKeyframe::Create(duration, end_opacity, nullptr));
+ curve->AddKeyframe(
+ FloatKeyframe::Create(base::TimeDelta(), start_opacity, func.Pass()));
+ curve->AddKeyframe(FloatKeyframe::Create(
+ base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr));
int id = AnimationIdProvider::NextAnimationId();
@@ -60,11 +63,12 @@ int AddAnimatedTransform(Target* target,
curve(KeyframedTransformAnimationCurve::Create());
if (duration > 0.0) {
- curve->AddKeyframe(
- TransformKeyframe::Create(0.0, start_operations, nullptr));
+ curve->AddKeyframe(TransformKeyframe::Create(base::TimeDelta(),
+ start_operations, nullptr));
}
- curve->AddKeyframe(TransformKeyframe::Create(duration, operations, nullptr));
+ curve->AddKeyframe(TransformKeyframe::Create(
+ base::TimeDelta::FromSecondsD(duration), operations, nullptr));
int id = AnimationIdProvider::NextAnimationId();
@@ -106,12 +110,14 @@ int AddAnimatedFilter(Target* target,
FilterOperations start_filters;
start_filters.Append(
FilterOperation::CreateBrightnessFilter(start_brightness));
- curve->AddKeyframe(FilterKeyframe::Create(0.0, start_filters, nullptr));
+ curve->AddKeyframe(
+ FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr));
}
FilterOperations filters;
filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness));
- curve->AddKeyframe(FilterKeyframe::Create(duration, filters, nullptr));
+ curve->AddKeyframe(FilterKeyframe::Create(
+ base::TimeDelta::FromSecondsD(duration), filters, nullptr));
int id = AnimationIdProvider::NextAnimationId();
@@ -137,7 +143,7 @@ base::TimeDelta FakeFloatAnimationCurve::Duration() const {
return duration_;
}
-float FakeFloatAnimationCurve::GetValue(double now) const {
+float FakeFloatAnimationCurve::GetValue(base::TimeDelta now) const {
return 0.0f;
}
@@ -155,7 +161,7 @@ base::TimeDelta FakeTransformTransition::Duration() const {
return duration_;
}
-gfx::Transform FakeTransformTransition::GetValue(double time) const {
+gfx::Transform FakeTransformTransition::GetValue(base::TimeDelta time) const {
return gfx::Transform();
}
@@ -188,11 +194,11 @@ base::TimeDelta FakeFloatTransition::Duration() const {
return duration_;
}
-float FakeFloatTransition::GetValue(double time) const {
- time /= duration_.InSecondsF();
- if (time >= 1.0)
- time = 1.0;
- return (1.0 - time) * from_ + time * to_;
+float FakeFloatTransition::GetValue(base::TimeDelta time) const {
+ double progress = TimeUtil::Divide(time, duration_);
+ if (progress >= 1.0)
+ progress = 1.0;
+ return (1.0 - progress) * from_ + progress * to_;
}
FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
« no previous file with comments | « cc/test/animation_test_common.h ('k') | cc/test/geometry_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698