tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / GraphicsLayerAnimation.h
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 #if USE(ACCELERATED_COMPOSITING)
24
25 #include "GraphicsLayer.h"
26 #include "TransformationMatrix.h"
27 #include <wtf/HashMap.h>
28 #include <wtf/text/StringHash.h>
29
30 namespace WebCore {
31
32 class GraphicsLayerAnimation {
33 public:
34     enum AnimationState { PlayingState, PausedState, StoppedState };
35     class Client {
36     public:
37         virtual void setAnimatedTransform(const TransformationMatrix&) = 0;
38         virtual void setAnimatedOpacity(float) = 0;
39     };
40
41     GraphicsLayerAnimation()
42         : m_keyframes(AnimatedPropertyInvalid)
43     { }
44     GraphicsLayerAnimation(const String&, const KeyframeValueList&, const IntSize&, const Animation*, double, bool);
45     void apply(Client*);
46     void pause(double);
47     AnimationState state() const { return m_state; }
48     void setState(AnimationState s, double pauseTime = 0)
49     {
50         m_state = s;
51         m_pauseTime = pauseTime;
52     }
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; }
62
63 private:
64     void applyInternal(Client*, const AnimationValue* from, const AnimationValue* to, float progress);
65     KeyframeValueList m_keyframes;
66     IntSize m_boxSize;
67     RefPtr<Animation> m_animation;
68     String m_name;
69     bool m_listsMatch;
70     double m_startTime;
71     double m_pauseTime;
72     AnimationState m_state;
73 };
74
75 class GraphicsLayerAnimations {
76 public:
77     GraphicsLayerAnimations() { }
78
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; }
87
88     bool hasRunningAnimations() const;
89     bool hasActiveAnimationsOfType(AnimatedPropertyID type) const;
90
91     GraphicsLayerAnimations getActiveAnimations() const;
92
93 private:
94     Vector<GraphicsLayerAnimation> m_animations;
95 };
96
97 }
98 #endif
99
100 #endif // GraphicsLayerAnimation_h