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

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

Issue 135693003: Defer starting of animations until after compositing update (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Advance animation clock after minimum delay. Created 6 years, 10 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 16 matching lines...) Expand all
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" 34 #include "wtf/CurrentTime.h"
35 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PassOwnPtr.h"
36 36
37 namespace {
abarth-chromium 2014/02/20 17:52:00 Please don't use anonymous namespaces in headers.
dstockwell 2014/02/24 06:03:25 Done.
38
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 minTimeBeforeUnsynchronizedTick = 0.005;
45
46 }
47
37 namespace WebCore { 48 namespace WebCore {
38 49
39 class AnimationClock { 50 class AnimationClock {
40 public: 51 public:
41 static PassOwnPtr<AnimationClock> create(WTF::TimeFunction monotonicallyIncr easingTime = WTF::monotonicallyIncreasingTime) 52 static PassOwnPtr<AnimationClock> create(WTF::TimeFunction monotonicallyIncr easingTime = WTF::monotonicallyIncreasingTime)
42 { 53 {
43 return adoptPtr(new AnimationClock(monotonicallyIncreasingTime)); 54 return adoptPtr(new AnimationClock(monotonicallyIncreasingTime));
44 } 55 }
45 56
46 void updateTime(double time) 57 void updateTime(double time)
47 { 58 {
48 if (time > m_time) 59 if (time > m_time)
49 m_time = time; 60 m_time = time;
50 m_frozen = true; 61 m_frozen = true;
51 } 62 }
52 63
53 double currentTime() 64 double currentTime()
54 { 65 {
55 if (!m_frozen) 66 if (!m_frozen) {
56 updateTime(m_monotonicallyIncreasingTime()); 67 double newTime = m_monotonicallyIncreasingTime();
68 if (newTime >= m_time + minTimeBeforeUnsynchronizedTick)
69 m_time = newTime;
70 }
57 return m_time; 71 return m_time;
58 } 72 }
59 73
60 void unfreeze() { m_frozen = false; } 74 void unfreeze() { m_frozen = false; }
61 75
62 void resetTimeForTesting() { m_time = 0; m_frozen = true; } 76 void resetTimeForTesting() { m_time = 0; m_frozen = true; }
63 77
64 private: 78 private:
65 AnimationClock(WTF::TimeFunction monotonicallyIncreasingTime) 79 AnimationClock(WTF::TimeFunction monotonicallyIncreasingTime)
66 : m_monotonicallyIncreasingTime(monotonicallyIncreasingTime) 80 : m_monotonicallyIncreasingTime(monotonicallyIncreasingTime)
67 , m_time(0) 81 , m_time(0)
68 , m_frozen(false) 82 , m_frozen(false)
69 { 83 {
70 } 84 }
71 WTF::TimeFunction m_monotonicallyIncreasingTime; 85 WTF::TimeFunction m_monotonicallyIncreasingTime;
72 double m_time; 86 double m_time;
73 bool m_frozen; 87 bool m_frozen;
74 }; 88 };
75 89
76 } // namespace WebCore 90 } // namespace WebCore
77 91
78 #endif // AnimationClock_h 92 #endif // AnimationClock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698