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

Side by Side Diff: Source/core/animation/AnimationTimeline.cpp

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « Source/core/animation/AnimationTimeline.h ('k') | Source/core/animation/AnimationTimeline.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29 matching lines...) Expand all
40 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
41 #include "platform/TraceEvent.h" 41 #include "platform/TraceEvent.h"
42 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
43 #include "public/platform/WebCompositorAnimationTimeline.h" 43 #include "public/platform/WebCompositorAnimationTimeline.h"
44 #include "public/platform/WebCompositorSupport.h" 44 #include "public/platform/WebCompositorSupport.h"
45 45
46 namespace blink { 46 namespace blink {
47 47
48 namespace { 48 namespace {
49 49
50 bool compareAnimations(const RefPtrWillBeMember<Animation>& left, const RefPtrWi llBeMember<Animation>& right) 50 bool compareAnimations(const Member<Animation>& left, const Member<Animation>& r ight)
51 { 51 {
52 return Animation::hasLowerPriority(left.get(), right.get()); 52 return Animation::hasLowerPriority(left, right);
53 } 53 }
54 54
55 } 55 }
56 56
57 // This value represents 1 frame at 30Hz plus a little bit of wiggle room. 57 // 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. 58 // TODO: Plumb a nominal framerate through and derive this value from that.
59 const double AnimationTimeline::s_minimumDelay = 0.04; 59 const double AnimationTimeline::s_minimumDelay = 0.04;
60 60
61 61
62 PassRefPtrWillBeRawPtr<AnimationTimeline> AnimationTimeline::create(Document* do cument, PassOwnPtrWillBeRawPtr<PlatformTiming> timing) 62 AnimationTimeline* AnimationTimeline::create(Document* document, PlatformTiming* timing)
63 { 63 {
64 return adoptRefWillBeNoop(new AnimationTimeline(document, timing)); 64 return new AnimationTimeline(document, timing);
65 } 65 }
66 66
67 AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr< 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 if (!timing) 75 if (!timing)
76 m_timing = adoptPtrWillBeNoop(new AnimationTimelineTiming(this)); 76 m_timing = new AnimationTimelineTiming(this);
77 else 77 else
78 m_timing = timing; 78 m_timing = timing;
79 79
80 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->compositorSupport()) 80 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->compositorSupport())
81 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport() ->createAnimationTimeline()); 81 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport() ->createAnimationTimeline());
82 82
83 ASSERT(document); 83 ASSERT(document);
84 } 84 }
85 85
86 AnimationTimeline::~AnimationTimeline() 86 AnimationTimeline::~AnimationTimeline()
87 { 87 {
88 #if !ENABLE(OILPAN) 88 #if !ENABLE(OILPAN)
89 for (const auto& animation : m_animations) 89 for (const auto& animation : m_animations)
90 animation->detachFromTimeline(); 90 animation->detachFromTimeline();
91 #endif 91 #endif
92 } 92 }
93 93
94 void AnimationTimeline::animationAttached(Animation& animation) 94 void AnimationTimeline::animationAttached(Animation& animation)
95 { 95 {
96 ASSERT(animation.timeline() == this); 96 ASSERT(animation.timeline() == this);
97 ASSERT(!m_animations.contains(&animation)); 97 ASSERT(!m_animations.contains(&animation));
98 m_animations.add(&animation); 98 m_animations.add(&animation);
99 } 99 }
100 100
101 Animation* AnimationTimeline::play(AnimationEffect* child) 101 Animation* AnimationTimeline::play(AnimationEffect* child)
102 { 102 {
103 if (!m_document) 103 if (!m_document)
104 return nullptr; 104 return nullptr;
105 105
106 RefPtrWillBeRawPtr<Animation> animation = Animation::create(child, this); 106 Animation* animation = Animation::create(child, this);
107 ASSERT(m_animations.contains(animation.get())); 107 ASSERT(m_animations.contains(animation));
108 108
109 animation->play(); 109 animation->play();
110 ASSERT(m_animationsNeedingUpdate.contains(animation)); 110 ASSERT(m_animationsNeedingUpdate.contains(animation));
111 111
112 return animation.get(); 112 return animation;
113 } 113 }
114 114
115 WillBeHeapVector<RefPtrWillBeMember<Animation>> AnimationTimeline::getAnimations () 115 HeapVector<Member<Animation>> AnimationTimeline::getAnimations()
116 { 116 {
117 WillBeHeapVector<RefPtrWillBeMember<Animation>> animations; 117 HeapVector<Member<Animation>> animations;
118 for (const auto& animation : m_animations) { 118 for (const auto& animation : m_animations) {
119 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect())) 119 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect()))
120 animations.append(animation); 120 animations.append(animation);
121 } 121 }
122 std::sort(animations.begin(), animations.end(), compareAnimations); 122 std::sort(animations.begin(), animations.end(), compareAnimations);
123 return animations; 123 return animations;
124 } 124 }
125 125
126 void AnimationTimeline::wake() 126 void AnimationTimeline::wake()
127 { 127 {
128 m_timing->serviceOnNextFrame(); 128 m_timing->serviceOnNextFrame();
129 } 129 }
130 130
131 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason) 131 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
132 { 132 {
133 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations"); 133 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations");
134 134
135 m_lastCurrentTimeInternal = currentTimeInternal(); 135 m_lastCurrentTimeInternal = currentTimeInternal();
136 136
137 m_timing->cancelWake(); 137 m_timing->cancelWake();
138 138
139 WillBeHeapVector<RawPtrWillBeMember<Animation>> animations; 139 HeapVector<Member<Animation>> animations;
140 animations.reserveInitialCapacity(m_animationsNeedingUpdate.size()); 140 copyToVector(m_animationsNeedingUpdate, animations);
141 for (RefPtrWillBeMember<Animation> animation : m_animationsNeedingUpdate)
142 animations.append(animation.get());
143
144 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ; 141 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ;
145 142
146 for (Animation* animation : animations) { 143 for (Member<Animation> animation : animations) {
147 if (!animation->update(reason)) 144 if (!animation->update(reason))
148 m_animationsNeedingUpdate.remove(animation); 145 m_animationsNeedingUpdate.remove(animation);
149 } 146 }
150 147
151 ASSERT(m_outdatedAnimationCount == 0); 148 ASSERT(m_outdatedAnimationCount == 0);
152 149
153 #if ENABLE(ASSERT) 150 #if ENABLE(ASSERT)
154 for (const auto& animation : m_animationsNeedingUpdate) 151 for (const auto& animation : m_animationsNeedingUpdate)
155 ASSERT(!animation->outdated()); 152 ASSERT(!animation->outdated());
156 #endif 153 #endif
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 315 {
319 // FIXME: AnimationTimeline should keep Document alive. 316 // FIXME: AnimationTimeline should keep Document alive.
320 m_document = nullptr; 317 m_document = nullptr;
321 } 318 }
322 #endif 319 #endif
323 320
324 DEFINE_TRACE(AnimationTimeline) 321 DEFINE_TRACE(AnimationTimeline)
325 { 322 {
326 #if ENABLE(OILPAN) 323 #if ENABLE(OILPAN)
327 visitor->trace(m_document); 324 visitor->trace(m_document);
325 #endif
328 visitor->trace(m_timing); 326 visitor->trace(m_timing);
329 visitor->trace(m_animationsNeedingUpdate); 327 visitor->trace(m_animationsNeedingUpdate);
330 visitor->trace(m_animations); 328 visitor->trace(m_animations);
331 #endif
332 } 329 }
333 330
334 } // namespace 331 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationTimeline.h ('k') | Source/core/animation/AnimationTimeline.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698