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

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

Issue 1196023003: Web Animations: Avoid iteration when checking for outdated animations on timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/Animation.h ('k') | Source/core/animation/AnimationTimeline.h » ('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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 ASSERT(m_held); 360 ASSERT(m_held);
361 361
362 if (m_playbackRate == 0) { 362 if (m_playbackRate == 0) {
363 setStartTimeInternal(timelineTime); 363 setStartTimeInternal(timelineTime);
364 } else { 364 } else {
365 setStartTimeInternal(timelineTime + currentTimeInternal() / -m_playb ackRate); 365 setStartTimeInternal(timelineTime + currentTimeInternal() / -m_playb ackRate);
366 } 366 }
367 367
368 // FIXME: This avoids marking this animation as outdated needlessly when a start time 368 // FIXME: This avoids marking this animation as outdated needlessly when a start time
369 // is notified, but we should refactor how outdating works to avoid this . 369 // is notified, but we should refactor how outdating works to avoid this .
370 m_outdated = false; 370 clearOutdated();
371
372 m_currentTimePending = false; 371 m_currentTimePending = false;
373 } 372 }
374 } 373 }
375 374
376 bool Animation::affects(const Element& element, CSSPropertyID property) const 375 bool Animation::affects(const Element& element, CSSPropertyID property) const
377 { 376 {
378 if (!m_content || !m_content->isAnimation()) 377 if (!m_content || !m_content->isAnimation())
379 return false; 378 return false;
380 379
381 const KeyframeEffect* effect = toKeyframeEffect(m_content.get()); 380 const KeyframeEffect* effect = toKeyframeEffect(m_content.get());
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 675
677 double storedCurrentTime = currentTimeInternal(); 676 double storedCurrentTime = currentTimeInternal();
678 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0)) 677 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0))
679 m_finished = false; 678 m_finished = false;
680 679
681 m_playbackRate = playbackRate; 680 m_playbackRate = playbackRate;
682 m_startTime = std::numeric_limits<double>::quiet_NaN(); 681 m_startTime = std::numeric_limits<double>::quiet_NaN();
683 setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand); 682 setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand);
684 } 683 }
685 684
685 void Animation::clearOutdated()
686 {
687 if (!m_outdated)
688 return;
689 m_outdated = false;
690 if (m_timeline)
691 m_timeline->clearOutdatedAnimation(this);
692 }
693
686 void Animation::setOutdated() 694 void Animation::setOutdated()
687 { 695 {
696 if (m_outdated)
697 return;
688 m_outdated = true; 698 m_outdated = true;
689 if (m_timeline) 699 if (m_timeline)
690 m_timeline->setOutdatedAnimation(this); 700 m_timeline->setOutdatedAnimation(this);
691 } 701 }
692 702
693 bool Animation::canStartAnimationOnCompositor() const 703 bool Animation::canStartAnimationOnCompositor() const
694 { 704 {
695 // FIXME: Timeline playback rates should be compositable 705 // FIXME: Timeline playback rates should be compositable
696 if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0) | | (timeline() && timeline()->playbackRate() != 1)) 706 if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0) | | (timeline() && timeline()->playbackRate() != 1))
697 return false; 707 return false;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 return toKeyframeEffect(m_content.get())->hasActiveAnimationsOnCompositor(); 790 return toKeyframeEffect(m_content.get())->hasActiveAnimationsOnCompositor();
781 } 791 }
782 792
783 bool Animation::update(TimingUpdateReason reason) 793 bool Animation::update(TimingUpdateReason reason)
784 { 794 {
785 if (!m_timeline) 795 if (!m_timeline)
786 return false; 796 return false;
787 797
788 PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending); 798 PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);
789 799
790 m_outdated = false; 800 clearOutdated();
791 bool idle = playStateInternal() == Idle; 801 bool idle = playStateInternal() == Idle;
792 802
793 if (m_content) { 803 if (m_content) {
794 double inheritedTime = idle || isNull(m_timeline->currentTimeInternal()) 804 double inheritedTime = idle || isNull(m_timeline->currentTimeInternal())
795 ? nullValue() 805 ? nullValue()
796 : currentTimeInternal(); 806 : currentTimeInternal();
797 807
798 if (!isNull(inheritedTime)) { 808 if (!isNull(inheritedTime)) {
799 double timeForClipping = m_held && (!limited(inheritedTime) || isNul l(m_startTime)) 809 double timeForClipping = m_held && (!limited(inheritedTime) || isNul l(m_startTime))
800 // Use hold time when there is no start time. 810 // Use hold time when there is no start time.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 visitor->trace(m_content); 1088 visitor->trace(m_content);
1079 visitor->trace(m_timeline); 1089 visitor->trace(m_timeline);
1080 visitor->trace(m_pendingFinishedEvent); 1090 visitor->trace(m_pendingFinishedEvent);
1081 visitor->trace(m_finishedPromise); 1091 visitor->trace(m_finishedPromise);
1082 visitor->trace(m_readyPromise); 1092 visitor->trace(m_readyPromise);
1083 EventTargetWithInlineData::trace(visitor); 1093 EventTargetWithInlineData::trace(visitor);
1084 ActiveDOMObject::trace(visitor); 1094 ActiveDOMObject::trace(visitor);
1085 } 1095 }
1086 1096
1087 } // namespace 1097 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/Animation.h ('k') | Source/core/animation/AnimationTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698