OLD | NEW |
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 Loading... |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/animation/AnimationPlayer.h" | 32 #include "core/animation/AnimationPlayer.h" |
33 | 33 |
34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
35 #include "core/animation/AnimationTimeline.h" | 35 #include "core/animation/AnimationTimeline.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/events/AnimationPlayerEvent.h" | 37 #include "core/events/AnimationPlayerEvent.h" |
38 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
39 #include "platform/TraceEvent.h" | 39 #include "platform/TraceEvent.h" |
| 40 #include "wtf/MathExtras.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
45 static unsigned nextSequenceNumber() | 46 static unsigned nextSequenceNumber() |
46 { | 47 { |
47 static unsigned next = 0; | 48 static unsigned next = 0; |
48 return ++next; | 49 return ++next; |
49 } | 50 } |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 591 |
591 void AnimationPlayer::setOutdated() | 592 void AnimationPlayer::setOutdated() |
592 { | 593 { |
593 m_outdated = true; | 594 m_outdated = true; |
594 if (m_timeline) | 595 if (m_timeline) |
595 m_timeline->setOutdatedAnimationPlayer(this); | 596 m_timeline->setOutdatedAnimationPlayer(this); |
596 } | 597 } |
597 | 598 |
598 bool AnimationPlayer::canStartAnimationOnCompositor() | 599 bool AnimationPlayer::canStartAnimationOnCompositor() |
599 { | 600 { |
600 if (m_playbackRate == 0) | 601 if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0)) |
601 return false; | 602 return false; |
602 | 603 |
603 return m_timeline && m_content && m_content->isAnimation() && playing(); | 604 return m_timeline && m_content && m_content->isAnimation() && playing(); |
604 } | 605 } |
605 | 606 |
606 bool AnimationPlayer::maybeStartAnimationOnCompositor() | 607 bool AnimationPlayer::maybeStartAnimationOnCompositor() |
607 { | 608 { |
608 if (!canStartAnimationOnCompositor()) | 609 if (!canStartAnimationOnCompositor()) |
609 return false; | 610 return false; |
610 | 611 |
611 double startTime = timeline()->zeroTime() + startTimeInternal(); | 612 double startTime = timeline()->zeroTime() + startTimeInternal(); |
612 double timeOffset = 0; | 613 double timeOffset = 0; |
613 if (std::isnan(startTime)) { | 614 if (std::isnan(startTime)) { |
614 timeOffset = m_playbackRate < 0 ? sourceEnd() - currentTimeInternal() :
currentTimeInternal(); | 615 timeOffset = m_playbackRate < 0 ? sourceEnd() - currentTimeInternal() :
currentTimeInternal(); |
| 616 timeOffset = timeOffset / fabs(m_playbackRate); |
615 } | 617 } |
616 return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(startTi
me, timeOffset, m_playbackRate); | 618 return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(startTi
me, timeOffset, m_playbackRate); |
617 } | 619 } |
618 | 620 |
619 void AnimationPlayer::setCompositorPending(bool sourceChanged) | 621 void AnimationPlayer::setCompositorPending(bool sourceChanged) |
620 { | 622 { |
621 // FIXME: Animation could notify this directly? | 623 // FIXME: Animation could notify this directly? |
622 if (!hasActiveAnimationsOnCompositor()) { | 624 if (!hasActiveAnimationsOnCompositor()) { |
623 m_compositorState.release(); | 625 m_compositorState.release(); |
624 } | 626 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 | 812 |
811 void AnimationPlayer::trace(Visitor* visitor) | 813 void AnimationPlayer::trace(Visitor* visitor) |
812 { | 814 { |
813 visitor->trace(m_content); | 815 visitor->trace(m_content); |
814 visitor->trace(m_timeline); | 816 visitor->trace(m_timeline); |
815 visitor->trace(m_pendingFinishedEvent); | 817 visitor->trace(m_pendingFinishedEvent); |
816 EventTargetWithInlineData::trace(visitor); | 818 EventTargetWithInlineData::trace(visitor); |
817 } | 819 } |
818 | 820 |
819 } // namespace | 821 } // namespace |
OLD | NEW |