OSDN Git Service

merge in ics-mr1-release history after reset to ics-mr1
[android-x86/external-webkit.git] / Source / WebCore / platform / graphics / android / AndroidAnimation.h
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef AndroidAnimation_h
18 #define AndroidAnimation_h
19
20 #if USE(ACCELERATED_COMPOSITING)
21
22 #include "FloatPoint.h"
23 #include "FloatPoint3D.h"
24 #include "GraphicsLayer.h"
25 #include "HashMap.h"
26 #include "LayerAndroid.h"
27 #include "RefPtr.h"
28 #include "Timer.h"
29 #include "TransformOperation.h"
30 #include "Vector.h"
31
32 namespace WebCore {
33
34 class TimingFunction;
35
36 class AndroidAnimation : public ThreadSafeRefCounted<AndroidAnimation> {
37 public:
38     AndroidAnimation(AnimatedPropertyID type,
39                      const Animation* animation,
40                      KeyframeValueList* operations,
41                      double beginTime);
42
43     virtual ~AndroidAnimation();
44     void suggestBeginTime(double time);
45     double elapsedTime(double time);
46     void pickValues(double progress, int* start, int* end);
47     bool checkIterationsAndProgress(double time, float* finalProgress);
48     double applyTimingFunction(float from, float to, double progress,
49                                const TimingFunction* timingFunction);
50     bool evaluate(LayerAndroid* layer, double time);
51     virtual void applyForProgress(LayerAndroid* layer, float progress) = 0;
52     static long instancesCount();
53     void setName(const String& name) { m_name = name; }
54     String name() { return m_name; }
55     AnimatedPropertyID type() { return m_type; }
56     bool fillsBackwards() { return m_fillsBackwards; }
57     bool fillsForwards() { return m_fillsForwards; }
58     int uniqueId() { return m_uniqueId; }
59
60 protected:
61     double m_beginTime;
62     double m_duration;
63     bool m_fillsBackwards;
64     bool m_fillsForwards;
65     int m_iterationCount;
66     int m_direction;
67     RefPtr<TimingFunction> m_timingFunction;
68     String m_name;
69     AnimatedPropertyID m_type;
70     KeyframeValueList* m_operations;
71     int m_uniqueId;
72     bool m_hasFinished;
73 };
74
75 class AndroidOpacityAnimation : public AndroidAnimation {
76 public:
77     static PassRefPtr<AndroidOpacityAnimation> create(const Animation* animation,
78                                                       KeyframeValueList* operations,
79                                                       double beginTime);
80     AndroidOpacityAnimation(const Animation* animation,
81                             KeyframeValueList* operations,
82                             double beginTime);
83
84     virtual void applyForProgress(LayerAndroid* layer, float progress);
85 };
86
87 class AndroidTransformAnimation : public AndroidAnimation {
88 public:
89     static PassRefPtr<AndroidTransformAnimation> create(
90                                                      const Animation* animation,
91                                                      KeyframeValueList* operations,
92                                                      double beginTime);
93     AndroidTransformAnimation(const Animation* animation,
94                               KeyframeValueList* operations,
95                               double beginTime);
96
97     virtual void applyForProgress(LayerAndroid* layer, float progress);
98 };
99
100 } // namespace WebCore
101
102
103 #endif // USE(ACCELERATED_COMPOSITING)
104
105 #endif // AndroidAnimation_h