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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 AnimationTimeline::AnimationTimeline(Document* document, PlatformTiming* timing) | 67 AnimationTimeline::AnimationTimeline(Document* document, PlatformTiming* timing) |
68 : m_document(document) | 68 : m_document(document) |
69 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the
loader | 69 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the
loader |
70 , m_zeroTimeInitialized(false) | 70 , m_zeroTimeInitialized(false) |
71 , m_outdatedAnimationCount(0) | 71 , m_outdatedAnimationCount(0) |
72 , m_playbackRate(1) | 72 , m_playbackRate(1) |
73 , m_lastCurrentTimeInternal(0) | 73 , m_lastCurrentTimeInternal(0) |
74 { | 74 { |
| 75 ThreadState::current()->registerPreFinalizer(this); |
75 if (!timing) | 76 if (!timing) |
76 m_timing = new AnimationTimelineTiming(this); | 77 m_timing = new AnimationTimelineTiming(this); |
77 else | 78 else |
78 m_timing = timing; | 79 m_timing = timing; |
79 | 80 |
80 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor
m::current()->isThreadedAnimationEnabled()) { | 81 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor
m::current()->isThreadedAnimationEnabled()) { |
81 ASSERT(Platform::current()->compositorSupport()); | 82 ASSERT(Platform::current()->compositorSupport()); |
82 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport()
->createAnimationTimeline()); | 83 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport()
->createAnimationTimeline()); |
83 } | 84 } |
84 | 85 |
85 ASSERT(document); | 86 ASSERT(document); |
86 } | 87 } |
87 | 88 |
88 AnimationTimeline::~AnimationTimeline() | 89 AnimationTimeline::~AnimationTimeline() |
89 { | 90 { |
90 } | 91 } |
91 | 92 |
| 93 void AnimationTimeline::dispose() |
| 94 { |
| 95 // The Animation objects depend on using this AnimationTimeline to |
| 96 // unregister from its underlying compositor timeline. To arrange |
| 97 // for that safely, this dispose() method will return first |
| 98 // during prefinalization, notifying each Animation object of |
| 99 // impending destruction. |
| 100 for (const auto& animation : m_animations) |
| 101 animation->dispose(); |
| 102 } |
| 103 |
92 bool AnimationTimeline::isActive() | 104 bool AnimationTimeline::isActive() |
93 { | 105 { |
94 return m_document && m_document->page(); | 106 return m_document && m_document->page(); |
95 } | 107 } |
96 | 108 |
97 void AnimationTimeline::animationAttached(Animation& animation) | 109 void AnimationTimeline::animationAttached(Animation& animation) |
98 { | 110 { |
99 ASSERT(animation.timeline() == this); | 111 ASSERT(animation.timeline() == this); |
100 ASSERT(!m_animations.contains(&animation)); | 112 ASSERT(!m_animations.contains(&animation)); |
101 m_animations.add(&animation); | 113 m_animations.add(&animation); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 358 |
347 DEFINE_TRACE(AnimationTimeline) | 359 DEFINE_TRACE(AnimationTimeline) |
348 { | 360 { |
349 visitor->trace(m_document); | 361 visitor->trace(m_document); |
350 visitor->trace(m_timing); | 362 visitor->trace(m_timing); |
351 visitor->trace(m_animationsNeedingUpdate); | 363 visitor->trace(m_animationsNeedingUpdate); |
352 visitor->trace(m_animations); | 364 visitor->trace(m_animations); |
353 } | 365 } |
354 | 366 |
355 } // namespace | 367 } // namespace |
OLD | NEW |