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

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

Issue 881183003: Animation: Cancel same-property animations on compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 cancelAnimationOnCompositor(); 239 cancelAnimationOnCompositor();
240 m_compositorState = nullptr; 240 m_compositorState = nullptr;
241 } 241 }
242 242
243 if (!shouldStart) { 243 if (!shouldStart) {
244 m_currentTimePending = false; 244 m_currentTimePending = false;
245 } 245 }
246 246
247 if (shouldStart) { 247 if (shouldStart) {
248 m_compositorGroup = compositorGroup; 248 m_compositorGroup = compositorGroup;
249 if (startOnCompositor && maybeStartAnimationOnCompositor()) { 249 if (startOnCompositor) {
250 m_compositorState = adoptPtr(new CompositorState(*this)); 250 if (maybeStartAnimationOnCompositor())
251 m_compositorState = adoptPtr(new CompositorState(*this));
252 else
253 cancelAffectedAnimationsOnCompositor();
251 } 254 }
252 } 255 }
253 } 256 }
254 257
255 void AnimationPlayer::postCommit(double timelineTime) 258 void AnimationPlayer::postCommit(double timelineTime)
256 { 259 {
257 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos itorPending); 260 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompos itorPending);
258 261
259 m_compositorPending = false; 262 m_compositorPending = false;
260 263
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 327 }
325 328
326 // FIXME: This avoids marking this player as outdated needlessly when a start time 329 // FIXME: This avoids marking this player as outdated needlessly when a start time
327 // is notified, but we should refactor how outdating works to avoid this . 330 // is notified, but we should refactor how outdating works to avoid this .
328 m_outdated = false; 331 m_outdated = false;
329 332
330 m_currentTimePending = false; 333 m_currentTimePending = false;
331 } 334 }
332 } 335 }
333 336
337 bool AnimationPlayer::affects(CSSPropertyID property) const
338 {
339 if (!m_content || !m_content->isAnimation())
340 return false;
341
342 return toAnimation(m_content.get())->affects(property);
343 }
344
334 double AnimationPlayer::calculateStartTime(double currentTime) const 345 double AnimationPlayer::calculateStartTime(double currentTime) const
335 { 346 {
336 return m_timeline->effectiveTime() - currentTime / m_playbackRate; 347 return m_timeline->effectiveTime() - currentTime / m_playbackRate;
337 } 348 }
338 349
339 double AnimationPlayer::calculateCurrentTime() const 350 double AnimationPlayer::calculateCurrentTime() const
340 { 351 {
341 ASSERT(!m_held); 352 ASSERT(!m_held);
342 if (isNull(m_startTime) || !m_timeline) 353 if (isNull(m_startTime) || !m_timeline)
343 return 0; 354 return 0;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 694 }
684 695
685 if (sourceChanged || !m_compositorState 696 if (sourceChanged || !m_compositorState
686 || !playing() || m_compositorState->playbackRate != m_playbackRate 697 || !playing() || m_compositorState->playbackRate != m_playbackRate
687 || m_compositorState->startTime != m_startTime) { 698 || m_compositorState->startTime != m_startTime) {
688 m_compositorPending = true; 699 m_compositorPending = true;
689 timeline()->document()->compositorPendingAnimations().add(this); 700 timeline()->document()->compositorPendingAnimations().add(this);
690 } 701 }
691 } 702 }
692 703
704 void AnimationPlayer::cancelAnimationOnCompositor()
705 {
706 if (hasActiveAnimationsOnCompositor())
707 toAnimation(m_content.get())->cancelAnimationOnCompositor();
708 }
709
710 void AnimationPlayer::cancelAffectedAnimationsOnCompositor()
711 {
712 if (m_content && m_content->isAnimation())
713 toAnimation(m_content.get())->cancelAffectedAnimationsOnCompositor();
714 }
715
693 bool AnimationPlayer::hasActiveAnimationsOnCompositor() 716 bool AnimationPlayer::hasActiveAnimationsOnCompositor()
694 { 717 {
695 if (!m_content || !m_content->isAnimation()) 718 if (!m_content || !m_content->isAnimation())
696 return false; 719 return false;
697 720
698 return toAnimation(m_content.get())->hasActiveAnimationsOnCompositor(); 721 return toAnimation(m_content.get())->hasActiveAnimationsOnCompositor();
699 } 722 }
700 723
701 void AnimationPlayer::cancelAnimationOnCompositor()
702 {
703 if (hasActiveAnimationsOnCompositor())
704 toAnimation(m_content.get())->cancelAnimationOnCompositor();
705 }
706
707 bool AnimationPlayer::update(TimingUpdateReason reason) 724 bool AnimationPlayer::update(TimingUpdateReason reason)
708 { 725 {
709 if (!m_timeline) 726 if (!m_timeline)
710 return false; 727 return false;
711 728
712 PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending); 729 PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);
713 730
714 m_outdated = false; 731 m_outdated = false;
715 bool idle = playStateInternal() == Idle; 732 bool idle = playStateInternal() == Idle;
716 733
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 816
800 AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope() 817 AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope()
801 { 818 {
802 AnimationPlayState oldPlayState = m_initialPlayState; 819 AnimationPlayState oldPlayState = m_initialPlayState;
803 AnimationPlayState newPlayState = m_player->calculatePlayState(); 820 AnimationPlayState newPlayState = m_player->calculatePlayState();
804 821
805 m_player->m_playState = newPlayState; 822 m_player->m_playState = newPlayState;
806 if (oldPlayState != newPlayState) { 823 if (oldPlayState != newPlayState) {
807 bool wasActive = oldPlayState == Pending || oldPlayState == Running; 824 bool wasActive = oldPlayState == Pending || oldPlayState == Running;
808 bool isActive = newPlayState == Pending || newPlayState == Running; 825 bool isActive = newPlayState == Pending || newPlayState == Running;
809
810 if (!wasActive && isActive) 826 if (!wasActive && isActive)
811 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("blink.animations," TRACE_DISABLED _BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnimat ionEvent::data(*m_player)); 827 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("blink.animations," TRACE_DISABLED _BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnimat ionEvent::data(*m_player));
812 else if (wasActive && !isActive) 828 else if (wasActive && !isActive)
813 TRACE_EVENT_NESTABLE_ASYNC_END1("blink.animations," TRACE_DISABLED_B Y_DEFAULT("devtools.timeline"), "Animation", m_player, "endData", InspectorAnima tionStateEvent::data(*m_player)); 829 TRACE_EVENT_NESTABLE_ASYNC_END1("blink.animations," TRACE_DISABLED_B Y_DEFAULT("devtools.timeline"), "Animation", m_player, "endData", InspectorAnima tionStateEvent::data(*m_player));
814 else 830 else
815 TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("blink.animations," TRACE_DISABL ED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnim ationStateEvent::data(*m_player)); 831 TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("blink.animations," TRACE_DISABL ED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnim ationStateEvent::data(*m_player));
816 } 832 }
817 833
818 // Ordering is important, the ready promise should resolve/reject before 834 // Ordering is important, the ready promise should resolve/reject before
819 // the finished promise. 835 // the finished promise.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 visitor->trace(m_content); 917 visitor->trace(m_content);
902 visitor->trace(m_timeline); 918 visitor->trace(m_timeline);
903 visitor->trace(m_pendingFinishedEvent); 919 visitor->trace(m_pendingFinishedEvent);
904 visitor->trace(m_finishedPromise); 920 visitor->trace(m_finishedPromise);
905 visitor->trace(m_readyPromise); 921 visitor->trace(m_readyPromise);
906 EventTargetWithInlineData::trace(visitor); 922 EventTargetWithInlineData::trace(visitor);
907 ActiveDOMObject::trace(visitor); 923 ActiveDOMObject::trace(visitor);
908 } 924 }
909 925
910 } // namespace 926 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698