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

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
« 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.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()->isThreadedAnimationEnabled()) { 80 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && Platfor m::current()->isThreadedAnimationEnabled()) {
81 ASSERT(Platform::current()->compositorSupport()); 81 ASSERT(Platform::current()->compositorSupport());
82 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport() ->createAnimationTimeline()); 82 m_compositorTimeline = adoptPtr(Platform::current()->compositorSupport() ->createAnimationTimeline());
83 } 83 }
84 84
85 ASSERT(document); 85 ASSERT(document);
86 } 86 }
87 87
88 AnimationTimeline::~AnimationTimeline() 88 AnimationTimeline::~AnimationTimeline()
89 { 89 {
90 #if !ENABLE(OILPAN)
91 for (const auto& animation : m_animations)
92 animation->detachFromTimeline();
93 #endif
94 } 90 }
95 91
96 void AnimationTimeline::animationAttached(Animation& animation) 92 void AnimationTimeline::animationAttached(Animation& animation)
97 { 93 {
98 ASSERT(animation.timeline() == this); 94 ASSERT(animation.timeline() == this);
99 ASSERT(!m_animations.contains(&animation)); 95 ASSERT(!m_animations.contains(&animation));
100 m_animations.add(&animation); 96 m_animations.add(&animation);
101 } 97 }
102 98
103 Animation* AnimationTimeline::play(AnimationEffect* child) 99 Animation* AnimationTimeline::play(AnimationEffect* child)
104 { 100 {
105 if (!m_document) 101 if (!m_document)
106 return nullptr; 102 return nullptr;
107 103
108 RefPtrWillBeRawPtr<Animation> animation = Animation::create(child, this); 104 Animation* animation = Animation::create(child, this);
109 ASSERT(m_animations.contains(animation.get())); 105 ASSERT(m_animations.contains(animation));
110 106
111 animation->play(); 107 animation->play();
112 ASSERT(m_animationsNeedingUpdate.contains(animation)); 108 ASSERT(m_animationsNeedingUpdate.contains(animation));
113 109
114 return animation.get(); 110 return animation;
115 } 111 }
116 112
117 WillBeHeapVector<RefPtrWillBeMember<Animation>> AnimationTimeline::getAnimations () 113 HeapVector<Member<Animation>> AnimationTimeline::getAnimations()
118 { 114 {
119 WillBeHeapVector<RefPtrWillBeMember<Animation>> animations; 115 HeapVector<Member<Animation>> animations;
120 for (const auto& animation : m_animations) { 116 for (const auto& animation : m_animations) {
121 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect())) 117 if (animation->effect() && (animation->effect()->isCurrent() || animatio n->effect()->isInEffect()))
122 animations.append(animation); 118 animations.append(animation);
123 } 119 }
124 std::sort(animations.begin(), animations.end(), compareAnimations); 120 std::sort(animations.begin(), animations.end(), compareAnimations);
125 return animations; 121 return animations;
126 } 122 }
127 123
128 void AnimationTimeline::wake() 124 void AnimationTimeline::wake()
129 { 125 {
130 m_timing->serviceOnNextFrame(); 126 m_timing->serviceOnNextFrame();
131 } 127 }
132 128
133 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason) 129 void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
134 { 130 {
135 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations"); 131 TRACE_EVENT0("blink", "AnimationTimeline::serviceAnimations");
136 132
137 m_lastCurrentTimeInternal = currentTimeInternal(); 133 m_lastCurrentTimeInternal = currentTimeInternal();
138 134
139 m_timing->cancelWake(); 135 m_timing->cancelWake();
140 136
141 WillBeHeapVector<RawPtrWillBeMember<Animation>> animations; 137 HeapVector<Member<Animation>> animations;
142 animations.reserveInitialCapacity(m_animationsNeedingUpdate.size()); 138 animations.reserveInitialCapacity(m_animationsNeedingUpdate.size());
143 for (RefPtrWillBeMember<Animation> animation : m_animationsNeedingUpdate) 139 for (Animation* animation : m_animationsNeedingUpdate)
144 animations.append(animation.get()); 140 animations.append(animation);
145 141
146 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ; 142 std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority) ;
147 143
148 for (Animation* animation : animations) { 144 for (Animation* animation : animations) {
149 if (!animation->update(reason)) 145 if (!animation->update(reason))
150 m_animationsNeedingUpdate.remove(animation); 146 m_animationsNeedingUpdate.remove(animation);
151 } 147 }
152 148
153 ASSERT(m_outdatedAnimationCount == 0); 149 ASSERT(m_outdatedAnimationCount == 0);
154 150
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 #if !ENABLE(OILPAN) 314 #if !ENABLE(OILPAN)
319 void AnimationTimeline::detachFromDocument() 315 void AnimationTimeline::detachFromDocument()
320 { 316 {
321 // FIXME: AnimationTimeline should keep Document alive. 317 // FIXME: AnimationTimeline should keep Document alive.
322 m_document = nullptr; 318 m_document = nullptr;
323 } 319 }
324 #endif 320 #endif
325 321
326 DEFINE_TRACE(AnimationTimeline) 322 DEFINE_TRACE(AnimationTimeline)
327 { 323 {
328 #if ENABLE(OILPAN)
329 visitor->trace(m_document); 324 visitor->trace(m_document);
330 visitor->trace(m_timing); 325 visitor->trace(m_timing);
331 visitor->trace(m_animationsNeedingUpdate); 326 visitor->trace(m_animationsNeedingUpdate);
332 visitor->trace(m_animations); 327 visitor->trace(m_animations);
333 #endif
334 } 328 }
335 329
336 } // namespace 330 } // 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