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

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

Issue 1318543009: Oilpan: Partially ship Oilpan for core/animations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 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.get(), right.get());
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)
89 for (const auto& animation : m_animations)
90 animation->detachFromTimeline();
91 #endif
92 } 88 }
93 89
94 void AnimationTimeline::animationAttached(Animation& animation) 90 void AnimationTimeline::animationAttached(Animation& animation)
95 { 91 {
96 ASSERT(animation.timeline() == this); 92 ASSERT(animation.timeline() == this);
97 ASSERT(!m_animations.contains(&animation)); 93 ASSERT(!m_animations.contains(&animation));
98 m_animations.add(&animation); 94 m_animations.add(&animation);
99 } 95 }
100 96
101 Animation* AnimationTimeline::play(AnimationEffect* child) 97 Animation* AnimationTimeline::play(AnimationEffect* child)
102 { 98 {
103 if (!m_document) 99 if (!m_document)
104 return nullptr; 100 return nullptr;
105 101
106 RefPtrWillBeRawPtr<Animation> animation = Animation::create(child, this); 102 RefPtr<Animation> animation = Animation::create(child, this);
107 ASSERT(m_animations.contains(animation.get())); 103 ASSERT(m_animations.contains(animation.get()));
108 104
109 animation->play(); 105 animation->play();
110 ASSERT(m_animationsNeedingUpdate.contains(animation)); 106 ASSERT(m_animationsNeedingUpdate.contains(animation));
111 107
112 return animation.get(); 108 return animation.get();
113 } 109 }
114 110
115 WillBeHeapVector<RefPtrWillBeMember<Animation>> AnimationTimeline::getAnimations () 111 HeapVector<Member<Animation>> AnimationTimeline::getAnimations()
116 { 112 {
117 WillBeHeapVector<RefPtrWillBeMember<Animation>> animations; 113 HeapVector<Member<Animation>> animations;
118 for (const auto& animation : m_animations) { 114 for (const auto& animation : m_animations) {
119 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect())) 115 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect()))
120 animations.append(animation); 116 animations.append(animation);
121 } 117 }
122 std::sort(animations.begin(), animations.end(), compareAnimations); 118 std::sort(animations.begin(), animations.end(), compareAnimations);
123 return animations; 119 return animations;
124 } 120 }
125 121
126 void AnimationTimeline::wake() 122 void AnimationTimeline::wake()
127 { 123 {
128 m_timing->serviceOnNextFrame(); 124 m_timing->serviceOnNextFrame();
129 } 125 }
130 126
131 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason) 127 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
132 { 128 {
133 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations"); 129 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations");
134 130
135 m_lastCurrentTimeInternal = currentTimeInternal(); 131 m_lastCurrentTimeInternal = currentTimeInternal();
136 132
137 m_timing->cancelWake(); 133 m_timing->cancelWake();
138 134
139 WillBeHeapVector<RawPtrWillBeMember<Animation>> animations; 135 HeapVector<Member<Animation>> animations;
140 animations.reserveInitialCapacity(m_animationsNeedingUpdate.size()); 136 animations.reserveInitialCapacity(m_animationsNeedingUpdate.size());
141 for (RefPtrWillBeMember<Animation> animation : m_animationsNeedingUpdate) 137 for (Animation* animation : m_animationsNeedingUpdate)
142 animations.append(animation.get()); 138 animations.append(animation);
143 139
144 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ; 140 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ;
145 141
146 for (Animation* animation : animations) { 142 for (Animation* animation : animations) {
147 if (!animation->update(reason)) 143 if (!animation->update(reason))
148 m_animationsNeedingUpdate.remove(animation); 144 m_animationsNeedingUpdate.remove(animation);
149 } 145 }
150 146
151 ASSERT(m_outdatedAnimationCount == 0); 147 ASSERT(m_outdatedAnimationCount == 0);
152 148
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #if !ENABLE(OILPAN) 312 #if !ENABLE(OILPAN)
317 void AnimationTimeline::detachFromDocument() 313 void AnimationTimeline::detachFromDocument()
318 { 314 {
319 // FIXME: AnimationTimeline should keep Document alive. 315 // FIXME: AnimationTimeline should keep Document alive.
320 m_document = nullptr; 316 m_document = nullptr;
321 } 317 }
322 #endif 318 #endif
323 319
324 DEFINE_TRACE(AnimationTimeline) 320 DEFINE_TRACE(AnimationTimeline)
325 { 321 {
326 #if ENABLE(OILPAN)
327 visitor->trace(m_document); 322 visitor->trace(m_document);
328 visitor->trace(m_timing); 323 visitor->trace(m_timing);
329 visitor->trace(m_animationsNeedingUpdate); 324 visitor->trace(m_animationsNeedingUpdate);
330 visitor->trace(m_animations); 325 visitor->trace(m_animations);
331 #endif
332 } 326 }
333 327
334 } // namespace 328 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698