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

Side by Side Diff: sky/engine/core/animation/Animation.cpp

Issue 772673002: Fix Animations, Remove Compostior Animations. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 6 years 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
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 19 matching lines...) Expand all
30 30
31 #include "sky/engine/config.h" 31 #include "sky/engine/config.h"
32 #include "sky/engine/core/animation/Animation.h" 32 #include "sky/engine/core/animation/Animation.h"
33 33
34 #include "sky/engine/bindings/core/v8/Dictionary.h" 34 #include "sky/engine/bindings/core/v8/Dictionary.h"
35 #include "sky/engine/bindings/core/v8/ExceptionState.h" 35 #include "sky/engine/bindings/core/v8/ExceptionState.h"
36 #include "sky/engine/core/animation/ActiveAnimations.h" 36 #include "sky/engine/core/animation/ActiveAnimations.h"
37 #include "sky/engine/core/animation/AnimationHelpers.h" 37 #include "sky/engine/core/animation/AnimationHelpers.h"
38 #include "sky/engine/core/animation/AnimationPlayer.h" 38 #include "sky/engine/core/animation/AnimationPlayer.h"
39 #include "sky/engine/core/animation/AnimationTimeline.h" 39 #include "sky/engine/core/animation/AnimationTimeline.h"
40 #include "sky/engine/core/animation/CompositorAnimations.h"
41 #include "sky/engine/core/animation/Interpolation.h" 40 #include "sky/engine/core/animation/Interpolation.h"
42 #include "sky/engine/core/animation/KeyframeEffectModel.h" 41 #include "sky/engine/core/animation/KeyframeEffectModel.h"
43 #include "sky/engine/core/dom/Element.h" 42 #include "sky/engine/core/dom/Element.h"
44 #include "sky/engine/core/frame/UseCounter.h" 43 #include "sky/engine/core/frame/UseCounter.h"
45 #include "sky/engine/core/rendering/RenderLayer.h" 44 #include "sky/engine/core/rendering/RenderLayer.h"
46 45
47 namespace blink { 46 namespace blink {
48 47
49 PassRefPtr<Animation> Animation::create(Element* target, PassRefPtr<AnimationEff ect> effect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDelegate) 48 PassRefPtr<Animation> Animation::create(Element* target, PassRefPtr<AnimationEff ect> effect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDelegate)
50 { 49 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 m_target->setNeedsAnimationStyleRecalc(); 160 m_target->setNeedsAnimationStyleRecalc();
162 } 161 }
163 162
164 void Animation::clearEffects() 163 void Animation::clearEffects()
165 { 164 {
166 ASSERT(player()); 165 ASSERT(player());
167 ASSERT(m_sampledEffect); 166 ASSERT(m_sampledEffect);
168 167
169 m_sampledEffect->clear(); 168 m_sampledEffect->clear();
170 m_sampledEffect = nullptr; 169 m_sampledEffect = nullptr;
171 cancelAnimationOnCompositor(); 170 // cancelAnimationOnCompositor();
172 m_target->setNeedsAnimationStyleRecalc(); 171 m_target->setNeedsAnimationStyleRecalc();
173 invalidate(); 172 invalidate();
174 } 173 }
175 174
176 void Animation::updateChildrenAndEffects() const 175 void Animation::updateChildrenAndEffects() const
177 { 176 {
178 if (!m_effect) 177 if (!m_effect)
179 return; 178 return;
180 if (isInEffect()) 179 if (isInEffect())
181 const_cast<Animation*>(this)->applyEffects(); 180 const_cast<Animation*>(this)->applyEffects();
182 else if (m_sampledEffect) 181 else if (m_sampledEffect)
183 const_cast<Animation*>(this)->clearEffects(); 182 const_cast<Animation*>(this)->clearEffects();
184 } 183 }
185 184
186 double Animation::calculateTimeToEffectChange(bool forwards, double localTime, d ouble timeToNextIteration) const 185 double Animation::calculateTimeToEffectChange(bool forwards, double localTime, d ouble timeToNextIteration) const
187 { 186 {
188 const double start = startTimeInternal() + specifiedTiming().startDelay; 187 const double start = startTimeInternal() + specifiedTiming().startDelay;
189 const double end = start + activeDurationInternal(); 188 const double end = start + activeDurationInternal();
190 189
191 switch (phase()) { 190 switch (phase()) {
192 case PhaseBefore: 191 case PhaseBefore:
193 ASSERT(start >= localTime); 192 ASSERT(start >= localTime);
194 return forwards 193 return forwards
195 ? start - localTime 194 ? start - localTime
196 : std::numeric_limits<double>::infinity(); 195 : std::numeric_limits<double>::infinity();
197 case PhaseActive: 196 case PhaseActive:
198 if (forwards && hasActiveAnimationsOnCompositor()) {
199 ASSERT(specifiedTiming().playbackRate == 1);
200 // Need service to apply fill / fire events.
201 const double timeToEnd = end - localTime;
202 if (hasEvents()) {
203 return std::min(timeToEnd, timeToNextIteration);
204 } else {
205 return timeToEnd;
206 }
207 }
208 return 0; 197 return 0;
209 case PhaseAfter: 198 case PhaseAfter:
210 ASSERT(localTime >= end); 199 ASSERT(localTime >= end);
211 // If this Animation is still in effect then it will need to update 200 // If this Animation is still in effect then it will need to update
212 // when its parent goes out of effect. We have no way of knowing when 201 // when its parent goes out of effect. We have no way of knowing when
213 // that will be, however, so the parent will need to supply it. 202 // that will be, however, so the parent will need to supply it.
214 return forwards 203 return forwards
215 ? std::numeric_limits<double>::infinity() 204 ? std::numeric_limits<double>::infinity()
216 : localTime - end; 205 : localTime - end;
217 default: 206 default:
(...skipping 14 matching lines...) Expand all
232 // destructor called when we call SampledEffect::clear(), so we need to 221 // destructor called when we call SampledEffect::clear(), so we need to
233 // clear m_sampledEffect first. 222 // clear m_sampledEffect first.
234 m_target = nullptr; 223 m_target = nullptr;
235 clearEventDelegate(); 224 clearEventDelegate();
236 SampledEffect* sampledEffect = m_sampledEffect; 225 SampledEffect* sampledEffect = m_sampledEffect;
237 m_sampledEffect = nullptr; 226 m_sampledEffect = nullptr;
238 if (sampledEffect) 227 if (sampledEffect)
239 sampledEffect->clear(); 228 sampledEffect->clear();
240 } 229 }
241 230
242 bool Animation::isCandidateForAnimationOnCompositor() const
243 {
244 if (!effect() || !m_target)
245 return false;
246 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *effect());
247 }
248
249 bool Animation::maybeStartAnimationOnCompositor(double startTime, double current Time)
250 {
251 ASSERT(!hasActiveAnimationsOnCompositor());
252 if (!isCandidateForAnimationOnCompositor())
253 return false;
254 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ et))
255 return false;
256 if (!CompositorAnimations::instance()->startAnimationOnCompositor(*m_target, startTime, currentTime, specifiedTiming(), *effect(), m_compositorAnimationIds) )
257 return false;
258 ASSERT(!m_compositorAnimationIds.isEmpty());
259 return true;
260 }
261
262 bool Animation::hasActiveAnimationsOnCompositor() const
263 {
264 return !m_compositorAnimationIds.isEmpty();
265 }
266
267 bool Animation::hasActiveAnimationsOnCompositor(CSSPropertyID property) const
268 {
269 return hasActiveAnimationsOnCompositor() && affects(property);
270 }
271
272 bool Animation::affects(CSSPropertyID property) const
273 {
274 return m_effect && m_effect->affects(property);
275 }
276
277 void Animation::cancelAnimationOnCompositor()
278 {
279 if (!hasActiveAnimationsOnCompositor())
280 return;
281 if (!m_target || !m_target->renderer())
282 return;
283 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i)
284 CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target, m_compositorAnimationIds[i]);
285 m_compositorAnimationIds.clear();
286 player()->setCompositorPending(true);
287 }
288
289 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime)
290 {
291 ASSERT(hasActiveAnimationsOnCompositor());
292 if (!m_target || !m_target->renderer())
293 return;
294 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i)
295 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(* m_target, m_compositorAnimationIds[i], pauseTime);
296 }
297
298 } // namespace blink 231 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698