2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
20 #ifndef GraphicsLayerAnimation_h
21 #define GraphicsLayerAnimation_h
23 #if USE(ACCELERATED_COMPOSITING)
25 #include "GraphicsLayer.h"
26 #include "TransformationMatrix.h"
27 #include <wtf/HashMap.h>
28 #include <wtf/text/StringHash.h>
32 class GraphicsLayerAnimation {
34 enum AnimationState { PlayingState, PausedState, StoppedState };
37 virtual void setAnimatedTransform(const TransformationMatrix&) = 0;
38 virtual void setAnimatedOpacity(float) = 0;
41 GraphicsLayerAnimation()
42 : m_keyframes(AnimatedPropertyInvalid)
44 GraphicsLayerAnimation(const String&, const KeyframeValueList&, const IntSize&, const Animation*, double, bool);
47 AnimationState state() const { return m_state; }
48 void setState(AnimationState s, double pauseTime = 0)
51 m_pauseTime = pauseTime;
53 AnimatedPropertyID property() const { return m_keyframes.property(); }
54 bool isActive() const;
55 String name() const { return m_name; }
56 IntSize boxSize() const { return m_boxSize; }
57 double startTime() const { return m_startTime; }
58 double pauseTime() const { return m_pauseTime; }
59 PassRefPtr<Animation> animation() const { return m_animation.get(); }
60 const KeyframeValueList& keyframes() const { return m_keyframes; }
61 bool listsMatch() const { return m_listsMatch; }
64 void applyInternal(Client*, const AnimationValue* from, const AnimationValue* to, float progress);
65 KeyframeValueList m_keyframes;
67 RefPtr<Animation> m_animation;
72 AnimationState m_state;
75 class GraphicsLayerAnimations {
77 GraphicsLayerAnimations() { }
79 void add(const GraphicsLayerAnimation&);
80 void remove(const String& name);
81 void pause(const String&, double);
82 void apply(GraphicsLayerAnimation::Client*);
83 bool isEmpty() const { return m_animations.isEmpty(); }
84 size_t size() const { return m_animations.size(); }
85 const Vector<GraphicsLayerAnimation>& animations() const { return m_animations; }
86 Vector<GraphicsLayerAnimation>& animations() { return m_animations; }
88 bool hasRunningAnimations() const;
89 bool hasActiveAnimationsOfType(AnimatedPropertyID type) const;
91 GraphicsLayerAnimations getActiveAnimations() const;
94 Vector<GraphicsLayerAnimation> m_animations;
100 #endif // GraphicsLayerAnimation_h