Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: ui/cc/cc/CCActiveAnimation.h

Issue 10701016: Initial import attempt, just to play with. Many things disabled/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/cc/cc.gyp ('k') | ui/cc/cc/CCActiveAnimation.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #ifndef CCActiveAnimation_h
26 #define CCActiveAnimation_h
27
28 #include <wtf/Noncopyable.h>
29 #include <wtf/OwnPtr.h>
30 #include <wtf/PassOwnPtr.h>
31
32 namespace WebCore {
33
34 class CCAnimationCurve;
35
36 // A CCActiveAnimation, contains all the state required to play a CCAnimationCur ve.
37 // Specifically, the affected property, the run state (paused, finished, etc.),
38 // loop count, last pause time, and the total time spent paused.
39 class CCActiveAnimation {
40 WTF_MAKE_NONCOPYABLE(CCActiveAnimation);
41 public:
42 // Animations begin in one of the 'waiting' states. Animations waiting for t he next tick
43 // will start the next time the controller animates. Animations waiting for target
44 // availibility will run as soon as their target property is free (and all t he animations
45 // animating with it are also able to run). Animations waiting for their sta rt time to
46 // come have be scheduled to run at a particular point in time. When this ti me arrives,
47 // the controller will move the animations into the Running state. Running a nimations
48 // may toggle between Running and Paused, and may be stopped by moving into either the
49 // Aborted or Finished states. A Finished animation was allowed to run to co mpletion, but
50 // an Aborted animation was not.
51 enum RunState {
52 WaitingForNextTick = 1,
53 WaitingForTargetAvailability,
54 WaitingForStartTime,
55 WaitingForDeletion,
56 Running,
57 Paused,
58 Finished,
59 Aborted
60 };
61
62 enum TargetProperty {
63 Transform = 1,
64 Opacity
65 };
66
67 static PassOwnPtr<CCActiveAnimation> create(PassOwnPtr<CCAnimationCurve>, in t animationId, int groupId, TargetProperty);
68
69 virtual ~CCActiveAnimation();
70
71 int id() const { return m_id; }
72 int group() const { return m_group; }
73 TargetProperty targetProperty() const { return m_targetProperty; }
74
75 RunState runState() const { return m_runState; }
76 void setRunState(RunState, double monotonicTime);
77
78 // This is the number of times that the animation will play. If this
79 // value is zero the animation will not play. If it is negative, then
80 // the animation will loop indefinitely.
81 int iterations() const { return m_iterations; }
82 void setIterations(int n) { m_iterations = n; }
83
84 double startTime() const { return m_startTime; }
85 void setStartTime(double monotonicTime) { m_startTime = monotonicTime; }
86 bool hasSetStartTime() const { return m_startTime; }
87
88 double timeOffset() const { return m_timeOffset; }
89 void setTimeOffset(double monotonicTime) { m_timeOffset = monotonicTime; }
90
91 void suspend(double monotonicTime);
92 void resume(double monotonicTime);
93
94 // If alternatesDirection is true, on odd numbered iterations we reverse the curve.
95 bool alternatesDirection() const { return m_alternatesDirection; }
96 void setAlternatesDirection(bool alternates) { m_alternatesDirection = alter nates; }
97
98 bool isFinishedAt(double monotonicTime) const;
99 bool isFinished() const { return m_runState == Finished
100 || m_runState == Aborted
101 || m_runState == WaitingForDeletion; }
102
103 CCAnimationCurve* curve() { return m_curve.get(); }
104 const CCAnimationCurve* curve() const { return m_curve.get(); }
105
106 // If this is true, even if the animation is running, it will not be tickabl e until
107 // it is given a start time. This is true for animations running on the main thread.
108 bool needsSynchronizedStartTime() const { return m_needsSynchronizedStartTim e; }
109 void setNeedsSynchronizedStartTime(bool needsSynchronizedStartTime) { m_need sSynchronizedStartTime = needsSynchronizedStartTime; }
110
111 // Takes the given absolute time, and using the start time and the number
112 // of iterations, returns the relative time in the current iteration.
113 double trimTimeToCurrentIteration(double monotonicTime) const;
114
115 PassOwnPtr<CCActiveAnimation> cloneForImplThread() const;
116
117 void pushPropertiesTo(CCActiveAnimation*) const;
118
119 private:
120 CCActiveAnimation(PassOwnPtr<CCAnimationCurve>, int animationId, int groupId , TargetProperty);
121
122 OwnPtr<CCAnimationCurve> m_curve;
123
124 // IDs are not necessarily unique.
125 int m_id;
126
127 // Animations that must be run together are called 'grouped' and have the sa me group id
128 // Grouped animations are guaranteed to start at the same time and no other animations
129 // may animate any of the group's target properties until all animations in the
130 // group have finished animating. Note: an active animation's group id and t arget
131 // property uniquely identify that animation.
132 int m_group;
133
134 TargetProperty m_targetProperty;
135 RunState m_runState;
136 int m_iterations;
137 double m_startTime;
138 bool m_alternatesDirection;
139
140 // The time offset effectively pushes the start of the animation back in tim e. This is
141 // used for resuming paused animations -- an animation is added with a non-z ero time
142 // offset, causing the animation to skip ahead to the desired point in time.
143 double m_timeOffset;
144
145 bool m_needsSynchronizedStartTime;
146
147 // When an animation is suspended, it behaves as if it is paused and it also ignores
148 // all run state changes until it is resumed. This is used for testing purpo ses.
149 bool m_suspended;
150
151 // These are used in trimTimeToCurrentIteration to account for time
152 // spent while paused. This is not included in AnimationState since it
153 // there is absolutely no need for clients of this controller to know
154 // about these values.
155 double m_pauseTime;
156 double m_totalPausedTime;
157 };
158
159 } // namespace WebCore
160
161 #endif // CCActiveAnimation_h
OLDNEW
« no previous file with comments | « ui/cc/cc.gyp ('k') | ui/cc/cc/CCActiveAnimation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698