| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | |
| 3 | |
| 4 This library is free software; you can redistribute it and/or | |
| 5 modify it under the terms of the GNU Library General Public | |
| 6 License as published by the Free Software Foundation; either | |
| 7 version 2 of the License, or (at your option) any later version. | |
| 8 | |
| 9 This library is distributed in the hope that it will be useful, | |
| 10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 Library General Public License for more details. | |
| 13 | |
| 14 You should have received a copy of the GNU Library General Public License | |
| 15 along with this library; see the file COPYING.LIB. If not, write to | |
| 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 17 Boston, MA 02110-1301, USA. | |
| 18 */ | |
| 19 | |
| 20 #ifndef GraphicsLayerAnimation_h | |
| 21 #define GraphicsLayerAnimation_h | |
| 22 | |
| 23 #include "core/platform/graphics/GraphicsLayer.h" | |
| 24 #include "core/platform/graphics/transforms/TransformationMatrix.h" | |
| 25 #include <wtf/HashMap.h> | |
| 26 #include <wtf/text/StringHash.h> | |
| 27 | |
| 28 namespace WebCore { | |
| 29 | |
| 30 class GraphicsLayerAnimation { | |
| 31 public: | |
| 32 enum AnimationState { PlayingState, PausedState, StoppedState }; | |
| 33 class Client { | |
| 34 public: | |
| 35 virtual void setAnimatedTransform(const TransformationMatrix&) = 0; | |
| 36 virtual void setAnimatedOpacity(float) = 0; | |
| 37 virtual void setAnimatedFilters(const FilterOperations&) = 0; | |
| 38 }; | |
| 39 | |
| 40 GraphicsLayerAnimation() | |
| 41 : m_keyframes(AnimatedPropertyInvalid) | |
| 42 { } | |
| 43 GraphicsLayerAnimation(const String&, const KeyframeValueList&, const IntSiz
e&, const CSSAnimationData*, double, bool); | |
| 44 void apply(Client*); | |
| 45 void pause(double); | |
| 46 void resume(); | |
| 47 double computeTotalRunningTime(); | |
| 48 AnimationState state() const { return m_state; } | |
| 49 void setState(AnimationState s, double pauseTime = 0) | |
| 50 { | |
| 51 m_state = s; | |
| 52 m_pauseTime = pauseTime; | |
| 53 } | |
| 54 AnimatedPropertyID property() const { return m_keyframes.property(); } | |
| 55 bool isActive() const; | |
| 56 String name() const { return m_name; } | |
| 57 IntSize boxSize() const { return m_boxSize; } | |
| 58 double startTime() const { return m_startTime; } | |
| 59 double pauseTime() const { return m_pauseTime; } | |
| 60 PassRefPtr<CSSAnimationData> animation() const { return m_animation.get(); } | |
| 61 const KeyframeValueList& keyframes() const { return m_keyframes; } | |
| 62 bool listsMatch() const { return m_listsMatch; } | |
| 63 | |
| 64 private: | |
| 65 void applyInternal(Client*, const AnimationValue* from, const AnimationValue
* to, float progress); | |
| 66 KeyframeValueList m_keyframes; | |
| 67 IntSize m_boxSize; | |
| 68 RefPtr<CSSAnimationData> m_animation; | |
| 69 String m_name; | |
| 70 bool m_listsMatch; | |
| 71 double m_startTime; | |
| 72 double m_pauseTime; | |
| 73 double m_totalRunningTime; | |
| 74 double m_lastRefreshedTime; | |
| 75 AnimationState m_state; | |
| 76 }; | |
| 77 | |
| 78 class GraphicsLayerAnimations { | |
| 79 public: | |
| 80 GraphicsLayerAnimations() { } | |
| 81 | |
| 82 void add(const GraphicsLayerAnimation&); | |
| 83 void remove(const String& name); | |
| 84 void remove(const String& name, AnimatedPropertyID); | |
| 85 void pause(const String&, double); | |
| 86 void suspend(double); | |
| 87 void resume(); | |
| 88 void apply(GraphicsLayerAnimation::Client*); | |
| 89 bool isEmpty() const { return m_animations.isEmpty(); } | |
| 90 size_t size() const { return m_animations.size(); } | |
| 91 const Vector<GraphicsLayerAnimation>& animations() const { return m_animatio
ns; } | |
| 92 Vector<GraphicsLayerAnimation>& animations() { return m_animations; } | |
| 93 | |
| 94 bool hasRunningAnimations() const; | |
| 95 bool hasActiveAnimationsOfType(AnimatedPropertyID type) const; | |
| 96 | |
| 97 GraphicsLayerAnimations getActiveAnimations() const; | |
| 98 | |
| 99 private: | |
| 100 Vector<GraphicsLayerAnimation> m_animations; | |
| 101 }; | |
| 102 | |
| 103 } | |
| 104 | |
| 105 #endif // GraphicsLayerAnimation_h | |
| OLD | NEW |