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

Side by Side Diff: Source/core/animation/AnimationClock.h

Issue 251183006: Web Animations: Timeline should not advance during task execution (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use task start time Created 6 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef AnimationClock_h 31 #ifndef AnimationClock_h
32 #define AnimationClock_h 32 #define AnimationClock_h
33 33
34 #include "wtf/CurrentTime.h"
35 #include "wtf/PassOwnPtr.h" 34 #include "wtf/PassOwnPtr.h"
36 35
37 namespace WebCore { 36 namespace WebCore {
38 37
39 // FIXME: This value is used to suppress updates when time is required outside o f a frame.
40 // The purpose of allowing the clock to update during such periods is to allow a nimations
41 // to have an appropriate start time and for getComputedStyle to attempt to catc h-up to a
42 // compositor animation. However a more accurate system might be to attempt to p hase-lock
43 // with the frame clock.
44 const double minTimeBeforeUnsynchronizedAnimationClockTick = 0.005;
45
46 class AnimationClock { 38 class AnimationClock {
47 public: 39 public:
48 static PassOwnPtr<AnimationClock> create(WTF::TimeFunction monotonicallyIncr easingTime = WTF::monotonicallyIncreasingTime) 40 AnimationClock()
41 : m_time(0)
49 { 42 {
50 return adoptPtr(new AnimationClock(monotonicallyIncreasingTime));
51 } 43 }
52 44
53 void updateTime(double time); 45 void updateTime(double time);
54 double currentTime(); 46 double currentTime();
55 void unfreeze() { m_frozen = false; } 47 void resetTimeForTesting() { m_time = 0; taskTime() = 0; }
56 void resetTimeForTesting() { m_time = 0; m_frozen = true; } 48
49 static double& taskTime()
shans 2014/04/30 20:43:07 I think this needs a comment indicating its purpos
esprehn 2014/04/30 22:43:50 Can we use a regular getter/setter pair instead of
dstockwell 2014/04/30 22:59:51 It's a static local, I can't access it from two di
esprehn 2014/04/30 23:54:33 Don't use a static local, make it a static member
50 {
51 static double time = 0;
52 return time;
53 }
54
55 static void notifyTaskStartTime(double time) { taskTime() = time; }
57 56
58 private: 57 private:
59 AnimationClock(WTF::TimeFunction monotonicallyIncreasingTime)
60 : m_monotonicallyIncreasingTime(monotonicallyIncreasingTime)
61 , m_time(0)
62 , m_frozen(false)
63 {
64 }
65 WTF::TimeFunction m_monotonicallyIncreasingTime;
66 double m_time; 58 double m_time;
67 bool m_frozen;
68 }; 59 };
69 60
70 } // namespace WebCore 61 } // namespace WebCore
71 62
72 #endif // AnimationClock_h 63 #endif // AnimationClock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698