2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef PlatformCAAnimation_h
27 #define PlatformCAAnimation_h
29 #if USE(ACCELERATED_COMPOSITING)
32 #include "FloatPoint3D.h"
33 #include "TransformationMatrix.h"
34 #include <wtf/RefCounted.h>
35 #include <wtf/RetainPtr.h>
36 #include <wtf/Vector.h>
40 @class CAPropertyAnimation;
42 class CAPropertyAnimation;
44 typedef CAPropertyAnimation* PlatformAnimationRef;
46 typedef struct _CACFAnimation* CACFAnimationRef;
47 typedef CACFAnimationRef PlatformAnimationRef;
53 class PlatformCAAnimation;
56 class PlatformCAAnimation : public RefCounted<PlatformCAAnimation> {
58 friend class PlatformCALayer;
60 enum AnimationType { Basic, Keyframe };
61 enum FillModeType { NoFillMode, Forwards, Backwards, Both };
62 enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate };
64 static PassRefPtr<PlatformCAAnimation> create(AnimationType, const String& keyPath);
65 static PassRefPtr<PlatformCAAnimation> create(PlatformAnimationRef);
67 ~PlatformCAAnimation();
69 static bool supportsValueFunction();
71 PassRefPtr<PlatformCAAnimation> copy() const;
73 PlatformAnimationRef platformAnimation() const;
75 AnimationType animationType() const { return m_type; }
76 String keyPath() const;
78 CFTimeInterval beginTime() const;
79 void setBeginTime(CFTimeInterval);
81 CFTimeInterval duration() const;
82 void setDuration(CFTimeInterval);
87 CFTimeInterval timeOffset() const;
88 void setTimeOffset(CFTimeInterval);
90 float repeatCount() const;
91 void setRepeatCount(float);
93 bool autoreverses() const;
94 void setAutoreverses(bool);
96 FillModeType fillMode() const;
97 void setFillMode(FillModeType);
99 void setTimingFunction(const TimingFunction*);
100 void copyTimingFunctionFrom(const PlatformCAAnimation*);
102 bool isRemovedOnCompletion() const;
103 void setRemovedOnCompletion(bool);
105 bool isAdditive() const;
106 void setAdditive(bool);
108 ValueFunctionType valueFunction() const;
109 void setValueFunction(ValueFunctionType);
111 // Basic-animation properties.
112 void setFromValue(float);
113 void setFromValue(const WebCore::TransformationMatrix&);
114 void setFromValue(const FloatPoint3D&);
115 void setFromValue(const WebCore::Color&);
116 void copyFromValueFrom(const PlatformCAAnimation*);
118 void setToValue(float);
119 void setToValue(const WebCore::TransformationMatrix&);
120 void setToValue(const FloatPoint3D&);
121 void setToValue(const WebCore::Color&);
122 void copyToValueFrom(const PlatformCAAnimation*);
124 // Keyframe-animation properties.
125 void setValues(const Vector<float>&);
126 void setValues(const Vector<WebCore::TransformationMatrix>&);
127 void setValues(const Vector<FloatPoint3D>&);
128 void setValues(const Vector<WebCore::Color>&);
129 void copyValuesFrom(const PlatformCAAnimation*);
131 void setKeyTimes(const Vector<float>&);
132 void copyKeyTimesFrom(const PlatformCAAnimation*);
134 void setTimingFunctions(const Vector<const TimingFunction*>&);
135 void copyTimingFunctionsFrom(const PlatformCAAnimation*);
138 PlatformCAAnimation(AnimationType, const String& keyPath);
139 PlatformCAAnimation(PlatformAnimationRef);
141 void setActualStartTimeIfNeeded(CFTimeInterval t)
143 if (beginTime() <= 0)
148 AnimationType m_type;
151 RetainPtr<CAPropertyAnimation> m_animation;
153 RetainPtr<CACFAnimationRef> m_animation;
159 #endif // USE(ACCELERATED_COMPOSITING)
161 #endif // PlatformCAAnimation_h