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 14 matching lines...) Expand all Loading... |
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 #include "core/animation/DocumentTimeline.h" | 31 #include "core/animation/DocumentTimeline.h" |
32 | 32 |
33 #include <algorithm> | 33 #include <algorithm> |
34 #include "core/animation/AnimationClock.h" | 34 #include "core/animation/AnimationClock.h" |
| 35 #include "core/animation/DocumentTimelineOptions.h" |
35 #include "core/animation/ElementAnimations.h" | 36 #include "core/animation/ElementAnimations.h" |
36 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
37 #include "core/frame/LocalFrameView.h" | 38 #include "core/frame/LocalFrameView.h" |
38 #include "core/loader/DocumentLoader.h" | 39 #include "core/loader/DocumentLoader.h" |
39 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
40 #include "platform/RuntimeEnabledFeatures.h" | 41 #include "platform/RuntimeEnabledFeatures.h" |
41 #include "platform/animation/CompositorAnimationTimeline.h" | 42 #include "platform/animation/CompositorAnimationTimeline.h" |
42 #include "platform/instrumentation/tracing/TraceEvent.h" | 43 #include "platform/instrumentation/tracing/TraceEvent.h" |
43 #include "platform/wtf/PtrUtil.h" | 44 #include "platform/wtf/PtrUtil.h" |
44 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
45 #include "public/platform/WebCompositorSupport.h" | 46 #include "public/platform/WebCompositorSupport.h" |
46 | 47 |
47 namespace blink { | 48 namespace blink { |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 bool CompareAnimations(const Member<Animation>& left, | 52 bool CompareAnimations(const Member<Animation>& left, |
52 const Member<Animation>& right) { | 53 const Member<Animation>& right) { |
53 return Animation::HasLowerPriority(left.Get(), right.Get()); | 54 return Animation::HasLowerPriority(left.Get(), right.Get()); |
54 } | 55 } |
55 } // namespace | 56 } // namespace |
56 | 57 |
57 // This value represents 1 frame at 30Hz plus a little bit of wiggle room. | 58 // This value represents 1 frame at 30Hz plus a little bit of wiggle room. |
58 // TODO: Plumb a nominal framerate through and derive this value from that. | 59 // TODO: Plumb a nominal framerate through and derive this value from that. |
59 const double DocumentTimeline::kMinimumDelay = 0.04; | 60 const double DocumentTimeline::kMinimumDelay = 0.04; |
60 | 61 |
61 DocumentTimeline* DocumentTimeline::Create(Document* document, | 62 DocumentTimeline* DocumentTimeline::Create(Document* document, |
| 63 double origin_time, |
62 PlatformTiming* timing) { | 64 PlatformTiming* timing) { |
63 return new DocumentTimeline(document, timing); | 65 return new DocumentTimeline(document, origin_time, timing); |
64 } | 66 } |
65 | 67 |
66 DocumentTimeline::DocumentTimeline(Document* document, PlatformTiming* timing) | 68 DocumentTimeline* DocumentTimeline::Create( |
| 69 ExecutionContext* execution_context, |
| 70 const DocumentTimelineOptions& options) { |
| 71 Document* document = ToDocument(execution_context); |
| 72 return new DocumentTimeline(document, options.originTime(), nullptr); |
| 73 } |
| 74 |
| 75 DocumentTimeline::DocumentTimeline(Document* document, |
| 76 double origin_time, |
| 77 PlatformTiming* timing) |
67 : document_(document), | 78 : document_(document), |
68 // 0 is used by unit tests which cannot initialize from the loader | 79 origin_time_(origin_time / 1000), |
69 zero_time_(0), | 80 zero_time_(origin_time_), |
70 zero_time_initialized_(false), | 81 zero_time_initialized_(false), |
71 outdated_animation_count_(0), | 82 outdated_animation_count_(0), |
72 playback_rate_(1), | 83 playback_rate_(1), |
73 last_current_time_internal_(0) { | 84 last_current_time_internal_(0) { |
74 if (!timing) | 85 if (!timing) |
75 timing_ = new DocumentTimelineTiming(this); | 86 timing_ = new DocumentTimelineTiming(this); |
76 else | 87 else |
77 timing_ = timing; | 88 timing_ = timing; |
78 | 89 |
79 if (Platform::Current()->IsThreadedAnimationEnabled()) | 90 if (Platform::Current()->IsThreadedAnimationEnabled()) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 timeline_->document_->View()->ScheduleAnimation(); | 186 timeline_->document_->View()->ScheduleAnimation(); |
176 } | 187 } |
177 | 188 |
178 DEFINE_TRACE(DocumentTimeline::DocumentTimelineTiming) { | 189 DEFINE_TRACE(DocumentTimeline::DocumentTimelineTiming) { |
179 visitor->Trace(timeline_); | 190 visitor->Trace(timeline_); |
180 DocumentTimeline::PlatformTiming::Trace(visitor); | 191 DocumentTimeline::PlatformTiming::Trace(visitor); |
181 } | 192 } |
182 | 193 |
183 double DocumentTimeline::ZeroTime() { | 194 double DocumentTimeline::ZeroTime() { |
184 if (!zero_time_initialized_ && document_ && document_->Loader()) { | 195 if (!zero_time_initialized_ && document_ && document_->Loader()) { |
185 zero_time_ = document_->Loader()->GetTiming().ReferenceMonotonicTime(); | 196 zero_time_ = document_->Loader()->GetTiming().ReferenceMonotonicTime() + |
| 197 origin_time_; |
186 zero_time_initialized_ = true; | 198 zero_time_initialized_ = true; |
187 } | 199 } |
188 return zero_time_; | 200 return zero_time_; |
189 } | 201 } |
190 | 202 |
191 void DocumentTimeline::ResetForTesting() { | 203 void DocumentTimeline::ResetForTesting() { |
192 zero_time_ = 0; | 204 zero_time_ = origin_time_; |
193 zero_time_initialized_ = true; | 205 zero_time_initialized_ = true; |
194 playback_rate_ = 1; | 206 playback_rate_ = 1; |
195 last_current_time_internal_ = 0; | 207 last_current_time_internal_ = 0; |
196 } | 208 } |
197 | 209 |
198 double DocumentTimeline::currentTime(bool& is_null) { | 210 double DocumentTimeline::currentTime(bool& is_null) { |
199 return CurrentTimeInternal(is_null) * 1000; | 211 return CurrentTimeInternal(is_null) * 1000; |
200 } | 212 } |
201 | 213 |
202 double DocumentTimeline::CurrentTimeInternal(bool& is_null) { | 214 double DocumentTimeline::CurrentTimeInternal(bool& is_null) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 308 |
297 DEFINE_TRACE(DocumentTimeline) { | 309 DEFINE_TRACE(DocumentTimeline) { |
298 visitor->Trace(document_); | 310 visitor->Trace(document_); |
299 visitor->Trace(timing_); | 311 visitor->Trace(timing_); |
300 visitor->Trace(animations_needing_update_); | 312 visitor->Trace(animations_needing_update_); |
301 visitor->Trace(animations_); | 313 visitor->Trace(animations_); |
302 AnimationTimeline::Trace(visitor); | 314 AnimationTimeline::Trace(visitor); |
303 } | 315 } |
304 | 316 |
305 } // namespace blink | 317 } // namespace blink |
OLD | NEW |