OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | |
3 * Copyright (C) 2013 Collabora Ltd. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 */ | |
26 | |
27 #ifndef PlatformClutterAnimation_h | |
28 #define PlatformClutterAnimation_h | |
29 | |
30 #if USE(ACCELERATED_COMPOSITING) | |
31 | |
32 #include "Color.h" | |
33 #include "FilterOperation.h" | |
34 #include "FloatPoint3D.h" | |
35 #include "TransformationMatrix.h" | |
36 #include <glib-object.h> | |
37 #include <glib.h> | |
38 #include <wtf/RefCounted.h> | |
39 #include <wtf/RetainPtr.h> | |
40 #include <wtf/Vector.h> | |
41 #include <wtf/gobject/GRefPtr.h> | |
42 | |
43 typedef struct _ClutterActor ClutterActor; | |
44 typedef struct _ClutterTimeline ClutterTimeline; | |
45 typedef struct _GraphicsLayerActor GraphicsLayerActor; | |
46 | |
47 namespace WebCore { | |
48 | |
49 class FloatRect; | |
50 class PlatformClutterAnimation; | |
51 class TimingFunction; | |
52 | |
53 class PlatformClutterAnimation : public RefCounted<PlatformClutterAnimation> { | |
54 public: | |
55 enum AnimationType { Basic, Keyframe }; | |
56 enum AnimatedPropertyType { NoAnimatedPropertyType, Transform, Opacity, Back
groundColor }; | |
57 enum FillModeType { NoFillMode, Forwards, Backwards, Both }; | |
58 enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX,
ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate, Matrix }; | |
59 | |
60 static PassRefPtr<PlatformClutterAnimation> create(AnimationType, const Stri
ng& keyPath); | |
61 static PassRefPtr<PlatformClutterAnimation> create(PlatformClutterAnimation*
); | |
62 | |
63 ~PlatformClutterAnimation(); | |
64 | |
65 static bool supportsValueFunction(); | |
66 static bool supportsAdditiveValueFunction(); | |
67 | |
68 AnimationType animationType() const { return m_type; } | |
69 | |
70 double beginTime() const; | |
71 void setBeginTime(double); | |
72 | |
73 double duration() const; | |
74 void setDuration(double); | |
75 | |
76 float speed() const; | |
77 void setSpeed(float); | |
78 | |
79 double timeOffset() const; | |
80 void setTimeOffset(double); | |
81 | |
82 float repeatCount() const; | |
83 void setRepeatCount(float); | |
84 | |
85 bool autoreverses() const; | |
86 void setAutoreverses(bool); | |
87 | |
88 FillModeType fillMode() const; | |
89 void setFillMode(FillModeType); | |
90 | |
91 void setTimingFunction(const TimingFunction*, bool reverse = false); | |
92 void copyTimingFunctionFrom(const PlatformClutterAnimation*); | |
93 | |
94 bool isRemovedOnCompletion() const; | |
95 void setRemovedOnCompletion(bool); | |
96 | |
97 bool isAdditive() const; | |
98 void setAdditive(bool); | |
99 | |
100 ValueFunctionType valueFunction() const; | |
101 void setValueFunction(ValueFunctionType); | |
102 | |
103 // Basic-animation properties. | |
104 void setFromValue(float); | |
105 void setFromValue(const WebCore::TransformationMatrix&); | |
106 void setFromValue(const FloatPoint3D&); | |
107 void setFromValue(const WebCore::Color&); | |
108 void copyFromValueFrom(const PlatformClutterAnimation*); | |
109 | |
110 void setToValue(float); | |
111 void setToValue(const WebCore::TransformationMatrix&); | |
112 void setToValue(const FloatPoint3D&); | |
113 void setToValue(const WebCore::Color&); | |
114 void copyToValueFrom(const PlatformClutterAnimation*); | |
115 | |
116 // Keyframe-animation properties. | |
117 void setValues(const Vector<float>&); | |
118 void setValues(const Vector<WebCore::TransformationMatrix>&); | |
119 void setValues(const Vector<FloatPoint3D>&); | |
120 void setValues(const Vector<WebCore::Color>&); | |
121 void copyValuesFrom(const PlatformClutterAnimation*); | |
122 | |
123 void setKeyTimes(const Vector<float>&); | |
124 void copyKeyTimesFrom(const PlatformClutterAnimation*); | |
125 | |
126 void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse =
false); | |
127 void copyTimingFunctionsFrom(const PlatformClutterAnimation*); | |
128 | |
129 void addAnimationForKey(GraphicsLayerActor*, const String&); | |
130 void removeAnimationForKey(GraphicsLayerActor*, const String&); | |
131 | |
132 void animationDidStart(); | |
133 | |
134 protected: | |
135 PlatformClutterAnimation(AnimationType, const String& keyPath); | |
136 PlatformClutterAnimation(const PlatformClutterAnimation*); | |
137 | |
138 private: | |
139 ClutterTimeline* timeline() const; | |
140 AnimatedPropertyType stringToAnimatedPropertyType(const String& keyPath) con
st; | |
141 | |
142 void addClutterTransitionForProperty(const String& property, const float fro
mValue, const float toValue); | |
143 void addClutterTransitionForProperty(const String& property, const WebCore::
TransformationMatrix&, const WebCore::TransformationMatrix&); | |
144 void addClutterTransitionForProperty(const String& property, const FloatPoin
t3D& fromValue, const FloatPoint3D& toValue); | |
145 | |
146 void addClutterKeyframeTransitionForProperty(const String& property, const V
ector<float>& values); | |
147 void addClutterKeyframeTransitionForProperty(const String& property, const V
ector<FloatPoint3D>& values); | |
148 | |
149 void addOpacityTransition(); | |
150 void addTransformTransition(); | |
151 | |
152 AnimationType m_type; | |
153 AnimatedPropertyType m_animatedPropertyType; | |
154 | |
155 GRefPtr<GObject> m_animation; | |
156 GRefPtr<ClutterActor> m_layer; | |
157 | |
158 bool m_additive; | |
159 | |
160 float m_fromValue; | |
161 float m_toValue; | |
162 | |
163 FloatPoint3D m_fromValue3D; | |
164 FloatPoint3D m_toValue3D; | |
165 | |
166 WebCore::TransformationMatrix m_fromValueMatrix; | |
167 WebCore::TransformationMatrix m_toValueMatrix; | |
168 | |
169 float m_repeatCount; | |
170 | |
171 const TimingFunction* m_timingFunction; | |
172 ValueFunctionType m_valueFunctionType; | |
173 | |
174 Vector<float> m_keyTimes; | |
175 Vector<const TimingFunction*> m_timingFunctions; | |
176 | |
177 Vector<float> m_values; | |
178 Vector<FloatPoint3D> m_values3D; | |
179 }; | |
180 | |
181 } | |
182 | |
183 #endif // USE(ACCELERATED_COMPOSITING) | |
184 | |
185 #endif // PlatformClutterAnimation_h | |
OLD | NEW |