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
176
177
178
179
180
181
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// 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 "cc/animation/animation.h"
#include "cc/animation/animation_curve.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/animation/layer_animation_value_observer.h"
#include "cc/animation/layer_animation_value_provider.h"
#include "cc/output/filter_operations.h"
#include "cc/test/geometry_test_utils.h"
namespace cc {
class LayerImpl;
class Layer;
}
namespace cc {
class FakeFloatAnimationCurve : public FloatAnimationCurve {
public:
FakeFloatAnimationCurve();
explicit FakeFloatAnimationCurve(double duration);
virtual ~FakeFloatAnimationCurve();
virtual double Duration() const OVERRIDE;
virtual float GetValue(double now) const OVERRIDE;
virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
private:
double duration_;
};
class FakeTransformTransition : public TransformAnimationCurve {
public:
explicit FakeTransformTransition(double duration);
virtual ~FakeTransformTransition();
virtual double Duration() const OVERRIDE;
virtual gfx::Transform GetValue(double time) const OVERRIDE;
virtual bool AnimatedBoundsForBox(const gfx::BoxF& box,
gfx::BoxF* bounds) const OVERRIDE;
virtual bool AffectsScale() const OVERRIDE;
virtual bool IsTranslation() const OVERRIDE;
virtual bool MaximumScale(float* max_scale) const OVERRIDE;
virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
private:
double duration_;
};
class FakeFloatTransition : public FloatAnimationCurve {
public:
FakeFloatTransition(double duration, float from, float to);
virtual ~FakeFloatTransition();
virtual double Duration() const OVERRIDE;
virtual float GetValue(double time) const OVERRIDE;
virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
private:
double duration_;
float from_;
float to_;
};
class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver {
public:
FakeLayerAnimationValueObserver();
virtual ~FakeLayerAnimationValueObserver();
// LayerAnimationValueObserver implementation
virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
virtual void OnOpacityAnimated(float opacity) OVERRIDE;
virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
virtual void OnScrollOffsetAnimated(
const gfx::Vector2dF& scroll_offset) OVERRIDE;
virtual void OnAnimationWaitingForDeletion() OVERRIDE;
virtual bool IsActive() const OVERRIDE;
const FilterOperations& filters() const { return filters_; }
float opacity() const { return opacity_; }
const gfx::Transform& transform() const { return transform_; }
gfx::Vector2dF scroll_offset() { return scroll_offset_; }
bool animation_waiting_for_deletion() {
return animation_waiting_for_deletion_;
}
private:
FilterOperations filters_;
float opacity_;
gfx::Transform transform_;
gfx::Vector2dF scroll_offset_;
bool animation_waiting_for_deletion_;
};
class FakeInactiveLayerAnimationValueObserver
: public FakeLayerAnimationValueObserver {
public:
virtual bool IsActive() const OVERRIDE;
};
class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider {
public:
virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
void set_scroll_offset(const gfx::Vector2dF& scroll_offset) {
scroll_offset_ = scroll_offset;
}
private:
gfx::Vector2dF scroll_offset_;
};
int AddOpacityTransitionToController(LayerAnimationController* controller,
double duration,
float start_opacity,
float end_opacity,
bool use_timing_function);
int AddAnimatedTransformToController(LayerAnimationController* controller,
double duration,
int delta_x,
int delta_y);
int AddAnimatedFilterToController(LayerAnimationController* controller,
double duration,
float start_brightness,
float end_brightness);
int AddOpacityTransitionToLayer(Layer* layer,
double duration,
float start_opacity,
float end_opacity,
bool use_timing_function);
int AddOpacityTransitionToLayer(LayerImpl* layer,
double duration,
float start_opacity,
float end_opacity,
bool use_timing_function);
int AddAnimatedTransformToLayer(Layer* layer,
double duration,
int delta_x,
int delta_y);
int AddAnimatedTransformToLayer(LayerImpl* layer,
double duration,
int delta_x,
int delta_y);
int AddAnimatedTransformToLayer(Layer* layer,
double duration,
TransformOperations start_operations,
TransformOperations operations);
int AddAnimatedTransformToLayer(LayerImpl* layer,
double duration,
TransformOperations start_operations,
TransformOperations operations);
int AddAnimatedFilterToLayer(Layer* layer,
double duration,
float start_brightness,
float end_brightness);
int AddAnimatedFilterToLayer(LayerImpl* layer,
double duration,
float start_brightness,
float end_brightness);
} // namespace cc
#endif // CC_TEST_ANIMATION_TEST_COMMON_H_
|