OLD | NEW |
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 18 matching lines...) Expand all Loading... |
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 WebCore { | 37 namespace WebCore { |
38 | 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 minTimeBeforeUnsynchronizedAnimationClockTick = 0.005; |
| 45 |
39 class AnimationClock { | 46 class AnimationClock { |
40 public: | 47 public: |
41 static PassOwnPtr<AnimationClock> create(WTF::TimeFunction monotonicallyIncr
easingTime = WTF::monotonicallyIncreasingTime) | 48 static PassOwnPtr<AnimationClock> create(WTF::TimeFunction monotonicallyIncr
easingTime = WTF::monotonicallyIncreasingTime) |
42 { | 49 { |
43 return adoptPtr(new AnimationClock(monotonicallyIncreasingTime)); | 50 return adoptPtr(new AnimationClock(monotonicallyIncreasingTime)); |
44 } | 51 } |
45 | 52 |
46 void updateTime(double time) | 53 void updateTime(double time); |
47 { | 54 double currentTime(); |
48 if (time > m_time) | |
49 m_time = time; | |
50 m_frozen = true; | |
51 } | |
52 | |
53 double currentTime() | |
54 { | |
55 if (!m_frozen) | |
56 updateTime(m_monotonicallyIncreasingTime()); | |
57 return m_time; | |
58 } | |
59 | |
60 void unfreeze() { m_frozen = false; } | 55 void unfreeze() { m_frozen = false; } |
61 | |
62 void resetTimeForTesting() { m_time = 0; m_frozen = true; } | 56 void resetTimeForTesting() { m_time = 0; m_frozen = true; } |
63 | 57 |
64 private: | 58 private: |
65 AnimationClock(WTF::TimeFunction monotonicallyIncreasingTime) | 59 AnimationClock(WTF::TimeFunction monotonicallyIncreasingTime) |
66 : m_monotonicallyIncreasingTime(monotonicallyIncreasingTime) | 60 : m_monotonicallyIncreasingTime(monotonicallyIncreasingTime) |
67 , m_time(0) | 61 , m_time(0) |
68 , m_frozen(false) | 62 , m_frozen(false) |
69 { | 63 { |
70 } | 64 } |
71 WTF::TimeFunction m_monotonicallyIncreasingTime; | 65 WTF::TimeFunction m_monotonicallyIncreasingTime; |
72 double m_time; | 66 double m_time; |
73 bool m_frozen; | 67 bool m_frozen; |
74 }; | 68 }; |
75 | 69 |
76 } // namespace WebCore | 70 } // namespace WebCore |
77 | 71 |
78 #endif // AnimationClock_h | 72 #endif // AnimationClock_h |
OLD | NEW |