1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
cc / test / animation_test_common.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TEST_ANIMATION_TEST_COMMON_H_
#define CC_TEST_ANIMATION_TEST_COMMON_H_
#include <memory>
#include "base/time/time.h"
#include "cc/animation/animation_timeline.h"
#include "cc/animation/keyframe_model.h"
#include "cc/paint/element_id.h"
#include "cc/paint/filter_operations.h"
#include "ui/gfx/animation/keyframe/animation_curve.h"
#include "ui/gfx/geometry/transform_operations.h"
namespace gfx {
class PointF;
}
namespace cc {
class FakeFloatAnimationCurve : public gfx::FloatAnimationCurve {
public:
FakeFloatAnimationCurve();
explicit FakeFloatAnimationCurve(double duration);
~FakeFloatAnimationCurve() override;
base::TimeDelta Duration() const override;
float GetValue(base::TimeDelta now) const override;
float GetTransformedValue(
base::TimeDelta now,
gfx::TimingFunction::LimitDirection limit_direction) const override;
std::unique_ptr<gfx::AnimationCurve> Clone() const override;
private:
base::TimeDelta duration_;
};
class FakeTransformTransition : public gfx::TransformAnimationCurve {
public:
explicit FakeTransformTransition(double duration);
~FakeTransformTransition() override;
base::TimeDelta Duration() const override;
gfx::TransformOperations GetValue(base::TimeDelta time) const override;
gfx::TransformOperations GetTransformedValue(
base::TimeDelta time,
gfx::TimingFunction::LimitDirection limit_direction) const override;
bool PreservesAxisAlignment() const override;
bool MaximumScale(float* max_scale) const override;
std::unique_ptr<gfx::AnimationCurve> Clone() const override;
private:
base::TimeDelta duration_;
};
class FakeFloatTransition : public gfx::FloatAnimationCurve {
public:
FakeFloatTransition(double duration, float from, float to);
~FakeFloatTransition() override;
base::TimeDelta Duration() const override;
float GetValue(base::TimeDelta time) const override;
float GetTransformedValue(
base::TimeDelta time,
gfx::TimingFunction::LimitDirection limit_direction) const override;
std::unique_ptr<gfx::AnimationCurve> Clone() const override;
private:
base::TimeDelta duration_;
float from_;
float to_;
};
int AddScrollOffsetAnimationToAnimation(Animation* animation,
gfx::PointF initial_value,
gfx::PointF target_value);
int AddAnimatedTransformToAnimation(Animation* animation,
double duration,
int delta_x,
int delta_y);
int AddAnimatedCustomPropertyToAnimation(Animation* animation,
double duration,
int start_value,
int end_value);
int AddAnimatedTransformToAnimation(Animation* animation,
double duration,
gfx::TransformOperations start_operations,
gfx::TransformOperations operations);
int AddOpacityTransitionToAnimation(Animation* animation,
double duration,
float start_opacity,
float end_opacity,
bool use_timing_function,
std::optional<int> id = std::nullopt,
std::optional<int> group_id = std::nullopt);
int AddAnimatedFilterToAnimation(Animation* animation,
double duration,
float start_brightness,
float end_brightness);
int AddAnimatedBackdropFilterToAnimation(Animation* animation,
double duration,
float start_invert,
float end_invert);
int AddOpacityStepsToAnimation(Animation* animation,
double duration,
float start_opacity,
float end_opacity,
int num_steps);
void AddKeyframeModelToElementWithAnimation(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
std::unique_ptr<KeyframeModel> keyframe_model);
void AddKeyframeModelToElementWithExistingKeyframeEffect(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
std::unique_ptr<KeyframeModel> keyframe_model);
void RemoveKeyframeModelFromElementWithExistingKeyframeEffect(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
int keyframe_model_id);
KeyframeModel* GetKeyframeModelFromElementWithExistingKeyframeEffect(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
int keyframe_model_id);
int AddAnimatedFilterToElementWithAnimation(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
double duration,
float start_brightness,
float end_brightness);
int AddAnimatedTransformToElementWithAnimation(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
double duration,
int delta_x,
int delta_y);
int AddAnimatedTransformToElementWithAnimation(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
double duration,
gfx::TransformOperations start_operations,
gfx::TransformOperations operations);
int AddOpacityTransitionToElementWithAnimation(
ElementId element_id,
scoped_refptr<AnimationTimeline> timeline,
double duration,
float start_opacity,
float end_opacity,
bool use_timing_function);
scoped_refptr<Animation> CancelAndReplaceAnimation(Animation& animation);
} // namespace cc
#endif // CC_TEST_ANIMATION_TEST_COMMON_H_