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

Side by Side Diff: sky/engine/core/animation/css/CSSAnimations.cpp

Issue 772673002: Fix Animations, Remove Compostior Animations. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: CompositorPendingAnimations -> PendingAnimations 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
« no previous file with comments | « sky/engine/core/animation/PendingAnimations.cpp ('k') | sky/engine/core/core.gni » ('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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "sky/engine/config.h" 31 #include "sky/engine/config.h"
32 #include "sky/engine/core/animation/css/CSSAnimations.h" 32 #include "sky/engine/core/animation/css/CSSAnimations.h"
33 33
34 #include "gen/sky/core/StylePropertyShorthand.h" 34 #include "gen/sky/core/StylePropertyShorthand.h"
35 #include "sky/engine/core/animation/ActiveAnimations.h" 35 #include "sky/engine/core/animation/ActiveAnimations.h"
36 #include "sky/engine/core/animation/AnimationTimeline.h" 36 #include "sky/engine/core/animation/AnimationTimeline.h"
37 #include "sky/engine/core/animation/CompositorAnimations.h"
38 #include "sky/engine/core/animation/KeyframeEffectModel.h" 37 #include "sky/engine/core/animation/KeyframeEffectModel.h"
39 #include "sky/engine/core/animation/LegacyStyleInterpolation.h" 38 #include "sky/engine/core/animation/LegacyStyleInterpolation.h"
40 #include "sky/engine/core/animation/css/CSSAnimatableValueFactory.h" 39 #include "sky/engine/core/animation/css/CSSAnimatableValueFactory.h"
41 #include "sky/engine/core/animation/css/CSSPropertyEquality.h" 40 #include "sky/engine/core/animation/css/CSSPropertyEquality.h"
42 #include "sky/engine/core/css/CSSKeyframeRule.h" 41 #include "sky/engine/core/css/CSSKeyframeRule.h"
43 #include "sky/engine/core/css/CSSPropertyMetadata.h" 42 #include "sky/engine/core/css/CSSPropertyMetadata.h"
44 #include "sky/engine/core/css/CSSValueList.h" 43 #include "sky/engine/core/css/CSSValueList.h"
45 #include "sky/engine/core/css/resolver/CSSToStyleMap.h" 44 #include "sky/engine/core/css/resolver/CSSToStyleMap.h"
46 #include "sky/engine/core/css/resolver/StyleResolver.h" 45 #include "sky/engine/core/css/resolver/StyleResolver.h"
47 #include "sky/engine/core/dom/Element.h" 46 #include "sky/engine/core/dom/Element.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // lazily. However, we need the new state to know what the from state shoud 328 // lazily. However, we need the new state to know what the from state shoud
330 // be when transitions are retargeted. Instead of triggering complete style 329 // be when transitions are retargeted. Instead of triggering complete style
331 // recalculation, we find these cases by searching for new transitions that 330 // recalculation, we find these cases by searching for new transitions that
332 // have matching cancelled animation property IDs on the compositor. 331 // have matching cancelled animation property IDs on the compositor.
333 HashMap<CSSPropertyID, std::pair<RefPtr<Animation>, double> > retargetedComp ositorTransitions; 332 HashMap<CSSPropertyID, std::pair<RefPtr<Animation>, double> > retargetedComp ositorTransitions;
334 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) { 333 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) {
335 CSSPropertyID id = *iter; 334 CSSPropertyID id = *iter;
336 ASSERT(m_transitions.contains(id)); 335 ASSERT(m_transitions.contains(id));
337 336
338 RefPtr<AnimationPlayer> player = m_transitions.take(id).player; 337 RefPtr<AnimationPlayer> player = m_transitions.take(id).player;
339 Animation* animation = toAnimation(player->source());
340 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit ions().find(id) != update->newTransitions().end())
341 retargetedCompositorTransitions.add(id, std::pair<RefPtr<Animation>, double>(animation, player->startTimeInternal()));
342 player->cancel(); 338 player->cancel();
343 player->update(TimingUpdateOnDemand); 339 player->update(TimingUpdateOnDemand);
344 } 340 }
345 341
346 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new Transitions().begin(); iter != update->newTransitions().end(); ++iter) { 342 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new Transitions().begin(); iter != update->newTransitions().end(); ++iter) {
347 const CSSAnimationUpdate::NewTransition& newTransition = iter->value; 343 const CSSAnimationUpdate::NewTransition& newTransition = iter->value;
348 344
349 RunningTransition runningTransition; 345 RunningTransition runningTransition;
350 runningTransition.from = newTransition.from; 346 runningTransition.from = newTransition.from;
351 runningTransition.to = newTransition.to; 347 runningTransition.to = newTransition.to;
352 348
353 CSSPropertyID id = newTransition.id; 349 CSSPropertyID id = newTransition.id;
354 InertAnimation* inertAnimation = newTransition.animation.get(); 350 InertAnimation* inertAnimation = newTransition.animation.get();
355 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, newTransition.eventId)); 351 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, newTransition.eventId));
356 352
357 RefPtr<AnimationEffect> effect = inertAnimation->effect(); 353 RefPtr<AnimationEffect> effect = inertAnimation->effect();
358
359 if (retargetedCompositorTransitions.contains(id)) {
360 const std::pair<RefPtr<Animation>, double>& oldTransition = retarget edCompositorTransitions.get(id);
361 RefPtr<Animation> oldAnimation = oldTransition.first;
362 double oldStartTime = oldTransition.second;
363 double inheritedTime = isNull(oldStartTime) ? 0 : element->document( ).timeline().currentTimeInternal() - oldStartTime;
364
365 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey frameEffectModel(inertAnimation->effect());
366 const KeyframeVector& frames = oldEffect->getFrames();
367
368 AnimatableValueKeyframeVector newFrames;
369 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get()) );
370 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get()) );
371
372 newFrames[0]->clearPropertyValue(id);
373 RefPtr<InertAnimation> inertAnimationForSampling = InertAnimation::c reate(oldAnimation->effect(), oldAnimation->specifiedTiming(), false);
374 OwnPtr<Vector<RefPtr<Interpolation> > > sample = inertAnimationForSa mpling->sample(inheritedTime);
375 ASSERT(sample->size() == 1);
376 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sample ->at(0).get())->currentValue());
377
378 effect = AnimatableValueKeyframeEffectModel::create(newFrames);
379 }
380
381 RefPtr<Animation> transition = Animation::create(element, effect, inertA nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas e()); 354 RefPtr<Animation> transition = Animation::create(element, effect, inertA nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas e());
382 RefPtr<AnimationPlayer> player = element->document().timeline().createAn imationPlayer(transition.get()); 355 RefPtr<AnimationPlayer> player = element->document().timeline().createAn imationPlayer(transition.get());
383 player->update(TimingUpdateOnDemand); 356 player->update(TimingUpdateOnDemand);
384 runningTransition.player = player; 357 runningTransition.player = player;
385 m_transitions.set(id, runningTransition); 358 m_transitions.set(id, runningTransition);
386 ASSERT(id != CSSPropertyInvalid); 359 ASSERT(id != CSSPropertyInvalid);
387 } 360 }
388 } 361 }
389 362
390 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde x, const RenderStyle& oldStyle, const RenderStyle& style, const TransitionMap* a ctiveTransitions, CSSAnimationUpdate* update, const Element* element) 363 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, CSSPr opertyID eventId, const CSSTransitionData& transitionData, size_t transitionInde x, const RenderStyle& oldStyle, const RenderStyle& style, const TransitionMap* a ctiveTransitions, CSSAnimationUpdate* update, const Element* element)
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 case CSSPropertyWebkitTransitionDuration: 655 case CSSPropertyWebkitTransitionDuration:
683 case CSSPropertyWebkitTransitionProperty: 656 case CSSPropertyWebkitTransitionProperty:
684 case CSSPropertyWebkitTransitionTimingFunction: 657 case CSSPropertyWebkitTransitionTimingFunction:
685 return false; 658 return false;
686 default: 659 default:
687 return true; 660 return true;
688 } 661 }
689 } 662 }
690 663
691 } // namespace blink 664 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/animation/PendingAnimations.cpp ('k') | sky/engine/core/core.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698