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

Side by Side Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 23874019: Web Animations CSS: Start running animations on the compositor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Cleanup isRunning* and shouldCompositeForAnimation Created 7 years, 1 month 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 "config.h" 31 #include "config.h"
32 #include "core/animation/css/CSSAnimations.h" 32 #include "core/animation/css/CSSAnimations.h"
33 33
34 #include "StylePropertyShorthand.h" 34 #include "StylePropertyShorthand.h"
35 #include "core/animation/ActiveAnimations.h" 35 #include "core/animation/ActiveAnimations.h"
36 #include "core/animation/CompositorAnimations.h"
36 #include "core/animation/DocumentTimeline.h" 37 #include "core/animation/DocumentTimeline.h"
37 #include "core/animation/KeyframeAnimationEffect.h" 38 #include "core/animation/KeyframeAnimationEffect.h"
38 #include "core/animation/css/CSSAnimatableValueFactory.h" 39 #include "core/animation/css/CSSAnimatableValueFactory.h"
39 #include "core/css/CSSKeyframeRule.h" 40 #include "core/css/CSSKeyframeRule.h"
40 #include "core/css/resolver/StyleResolver.h" 41 #include "core/css/resolver/StyleResolver.h"
41 #include "core/dom/Element.h" 42 #include "core/dom/Element.h"
42 #include "core/events/ThreadLocalEventNames.h" 43 #include "core/events/ThreadLocalEventNames.h"
43 #include "core/events/TransitionEvent.h" 44 #include "core/events/TransitionEvent.h"
44 #include "core/events/WebKitAnimationEvent.h" 45 #include "core/events/WebKitAnimationEvent.h"
45 #include "core/frame/UseCounter.h" 46 #include "core/frame/UseCounter.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 513 }
513 514
514 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update- >newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { 515 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update- >newAnimations().begin(); iter != update->newAnimations().end(); ++iter) {
515 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve ntDelegate(element, iter->name)); 516 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve ntDelegate(element, iter->name));
516 HashSet<RefPtr<Player> > players; 517 HashSet<RefPtr<Player> > players;
517 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI ter) { 518 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI ter) {
518 const InertAnimation* inertAnimation = animationsIter->get(); 519 const InertAnimation* inertAnimation = animationsIter->get();
519 // The event delegate is set on the the first animation only. We 520 // The event delegate is set on the the first animation only. We
520 // rely on the behavior of OwnPtr::release() to achieve this. 521 // rely on the behavior of OwnPtr::release() to achieve this.
521 RefPtr<Animation> animation = Animation::create(element, inertAnimat ion->effect(), inertAnimation->specified(), Animation::DefaultPriority, eventDel egate.release()); 522 RefPtr<Animation> animation = Animation::create(element, inertAnimat ion->effect(), inertAnimation->specified(), Animation::DefaultPriority, eventDel egate.release());
522 RefPtr<Player> player = element->document().timeline()->play(animati on.get()); 523 RefPtr<Player> player = element->document().timeline()->createPlayer (animation.get());
523 player->setPaused(inertAnimation->paused()); 524 player->setPaused(inertAnimation->paused());
525 element->document().cssPendingAnimations().add(player.get());
524 players.add(player.release()); 526 players.add(player.release());
525 } 527 }
526 m_animations.set(iter->name, players); 528 m_animations.set(iter->name, players);
527 } 529 }
528 530
529 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) { 531 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) {
530 ASSERT(m_transitions.contains(*iter)); 532 ASSERT(m_transitions.contains(*iter));
531 m_transitions.take(*iter).transition->player()->cancel(); 533 m_transitions.take(*iter).transition->player()->cancel();
532 } 534 }
533 535
534 for (size_t i = 0; i < update->newTransitions().size(); ++i) { 536 for (size_t i = 0; i < update->newTransitions().size(); ++i) {
535 const CSSAnimationUpdate::NewTransition& newTransition = update->newTran sitions()[i]; 537 const CSSAnimationUpdate::NewTransition& newTransition = update->newTran sitions()[i];
536 538
537 RunningTransition runningTransition; 539 RunningTransition runningTransition;
538 runningTransition.from = newTransition.from; 540 runningTransition.from = newTransition.from;
539 runningTransition.to = newTransition.to; 541 runningTransition.to = newTransition.to;
540 542
541 CSSPropertyID id = newTransition.id; 543 CSSPropertyID id = newTransition.id;
542 InertAnimation* inertAnimation = newTransition.animation.get(); 544 InertAnimation* inertAnimation = newTransition.animation.get();
543 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, id)); 545 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, id));
544 RefPtr<Animation> transition = Animation::create(element, inertAnimation ->effect(), inertAnimation->specified(), Animation::TransitionPriority, eventDel egate.release()); 546 RefPtr<Animation> transition = Animation::create(element, inertAnimation ->effect(), inertAnimation->specified(), Animation::TransitionPriority, eventDel egate.release());
545 element->document().transitionTimeline()->play(transition.get()); 547 RefPtr<Player> player = element->document().transitionTimeline()->create Player(transition.get());
548 element->document().cssPendingAnimations().add(player.get());
546 runningTransition.transition = transition.get(); 549 runningTransition.transition = transition.get();
547 m_transitions.set(id, runningTransition); 550 m_transitions.set(id, runningTransition);
548 ASSERT(id != CSSPropertyInvalid); 551 ASSERT(id != CSSPropertyInvalid);
549 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); 552 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id));
550 } 553 }
551 } 554 }
552 555
553 void CSSAnimations::calculateTransitionUpdateForProperty(CSSAnimationUpdate* upd ate, CSSPropertyID id, const CandidateTransition& newTransition, const Transitio nMap* existingTransitions) 556 void CSSAnimations::calculateTransitionUpdateForProperty(CSSAnimationUpdate* upd ate, CSSPropertyID id, const CandidateTransition& newTransition, const Transitio nMap* existingTransitions)
554 { 557 {
555 if (existingTransitions) { 558 if (existingTransitions) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 682 }
680 683
681 // Properties being animated by animations don't get values from transitions applied. 684 // Properties being animated by animations don't get values from transitions applied.
682 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal uesForTransitions.isEmpty()) { 685 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal uesForTransitions.isEmpty()) {
683 for (AnimationEffect::CompositableValueMap::const_iterator iter = update ->compositableValuesForAnimations().begin(); iter != update->compositableValuesF orAnimations().end(); ++iter) 686 for (AnimationEffect::CompositableValueMap::const_iterator iter = update ->compositableValuesForAnimations().begin(); iter != update->compositableValuesF orAnimations().end(); ++iter)
684 compositableValuesForTransitions.remove(iter->key); 687 compositableValuesForTransitions.remove(iter->key);
685 } 688 }
686 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio ns); 689 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio ns);
687 } 690 }
688 691
692 bool CSSAnimations::hasPendingCandidateWhichShouldComposite(bool inCompositingMo de) const
693 {
694 if (!m_pendingUpdate)
695 return false;
696
697 for (size_t i = 0; i < m_pendingUpdate->newAnimations().size(); ++i) {
698 HashSet<RefPtr<InertAnimation> > animations = m_pendingUpdate->newAnimat ions()[i].animations;
699 for (HashSet<RefPtr<InertAnimation> >::const_iterator it = animations.be gin(); it != animations.end(); ++it) {
700 ASSERT((*it)->effect());
701 AnimationEffect* effect = (*it)->effect();
702 // FIXME: Perhaps pass a predicate funciton so that we can remove th e explicit checks from this file?
703 if ((effect->affects(CSSPropertyOpacity) && inCompositingMode)
704 || effect->affects(CSSPropertyWebkitTransform)
705 || effect->affects(CSSPropertyWebkitFilter))
706 return true;
707 }
708 }
709
710 for (size_t i = 0; i < m_pendingUpdate->newTransitions().size(); ++i) {
711 AnimationEffect* effect = m_pendingUpdate->newTransitions()[i].animation ->effect();
712 if ((effect->affects(CSSPropertyOpacity) && inCompositingMode)
713 || effect->affects(CSSPropertyWebkitTransform)
714 || effect->affects(CSSPropertyWebkitFilter))
715 return true;
Steve Block 2013/11/18 05:03:03 It's a shame that the logic regarding these 3 prop
dstockwell 2013/11/18 06:11:20 There's a FIXME on line 702 with a possible soluti
716 }
717
718 return false;
719 }
720
689 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime) 721 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime)
690 { 722 {
691 if (m_target->document().hasListenerType(listenerType)) 723 if (m_target->document().hasListenerType(listenerType))
692 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime)); 724 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime));
693 } 725 }
694 726
695 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter ation) 727 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter ation)
696 { 728 {
697 // Events for a single document are queued and dispatched as a group at 729 // Events for a single document are queued and dispatched as a group at
698 // the end of DocumentTimeline::serviceAnimations. 730 // the end of DocumentTimeline::serviceAnimations.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 CSSPropertyID id = convertToCSSPropertyID(i); 907 CSSPropertyID id = convertToCSSPropertyID(i);
876 if (isAnimatableProperty(id)) 908 if (isAnimatableProperty(id))
877 properties.append(id); 909 properties.append(id);
878 } 910 }
879 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size()); 911 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size());
880 } 912 }
881 return propertyShorthand; 913 return propertyShorthand;
882 } 914 }
883 915
884 } // namespace WebCore 916 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698