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 RefCounted<AndroidAnimation> { 37 public: 38 AndroidAnimation(AnimatedPropertyID type, 39 const Animation* animation, 40 KeyframeValueList* operations, 41 double beginTime); 42 AndroidAnimation(AndroidAnimation* anim); 43 44 virtual ~AndroidAnimation(); 45 virtual PassRefPtr<AndroidAnimation> copy() = 0; 46 double elapsedTime(double time); 47 void pickValues(double progress, int* start, int* end); 48 bool checkIterationsAndProgress(double time, float* finalProgress); 49 double applyTimingFunction(float from, float to, double progress, 50 const TimingFunction* timingFunction); 51 bool evaluate(LayerAndroid* layer, double time); 52 virtual void applyForProgress(LayerAndroid* layer, float progress) = 0; 53 static long instancesCount(); setName(const String & name)54 void setName(const String& name) { m_name = name; } name()55 String name() { return m_name; } type()56 AnimatedPropertyID type() { return m_type; } fillsBackwards()57 bool fillsBackwards() { return m_fillsBackwards; } fillsForwards()58 bool fillsForwards() { return m_fillsForwards; } 59 60 61 protected: 62 double m_beginTime; 63 double m_elapsedTime; 64 double m_duration; 65 bool m_fillsBackwards; 66 bool m_fillsForwards; 67 int m_iterationCount; 68 int m_direction; 69 RefPtr<TimingFunction> m_timingFunction; 70 String m_name; 71 AnimatedPropertyID m_type; 72 KeyframeValueList* m_operations; 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 AndroidOpacityAnimation(AndroidOpacityAnimation* anim); 84 virtual PassRefPtr<AndroidAnimation> copy(); 85 86 virtual void applyForProgress(LayerAndroid* layer, float progress); 87 }; 88 89 class AndroidTransformAnimation : public AndroidAnimation { 90 public: 91 static PassRefPtr<AndroidTransformAnimation> create( 92 const Animation* animation, 93 KeyframeValueList* operations, 94 double beginTime); 95 AndroidTransformAnimation(const Animation* animation, 96 KeyframeValueList* operations, 97 double beginTime); 98 99 AndroidTransformAnimation(AndroidTransformAnimation* anim); 100 virtual PassRefPtr<AndroidAnimation> copy(); 101 102 virtual void applyForProgress(LayerAndroid* layer, float progress); 103 }; 104 105 } // namespace WebCore 106 107 108 #endif // USE(ACCELERATED_COMPOSITING) 109 110 #endif // AndroidAnimation_h 111