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

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

Issue 210703002: Web Animations: Sort Animations in the AnimationStack (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix compile? :| Created 6 years, 9 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
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/AnimationPlayerTest.cpp » ('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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 PassRefPtr<AnimationPlayer> AnimationPlayer::create(DocumentTimeline& timeline, TimedItem* content) 49 PassRefPtr<AnimationPlayer> AnimationPlayer::create(DocumentTimeline& timeline, TimedItem* content)
50 { 50 {
51 return adoptRef(new AnimationPlayer(timeline, content)); 51 return adoptRef(new AnimationPlayer(timeline, content));
52 } 52 }
53 53
54 AnimationPlayer::AnimationPlayer(DocumentTimeline& timeline, TimedItem* content) 54 AnimationPlayer::AnimationPlayer(DocumentTimeline& timeline, TimedItem* content)
55 : m_playbackRate(1) 55 : m_playbackRate(1)
56 , m_startTime(nullValue()) 56 , m_startTime(nullValue())
57 , m_holdTime(nullValue()) 57 , m_holdTime(nullValue())
58 , m_storedTimeLag(0) 58 , m_storedTimeLag(0)
59 , m_sortInfo(nextSequenceNumber(), timeline.effectiveTime())
59 , m_content(content) 60 , m_content(content)
60 , m_timeline(&timeline) 61 , m_timeline(&timeline)
61 , m_paused(false) 62 , m_paused(false)
62 , m_held(false) 63 , m_held(false)
63 , m_isPausedForTesting(false) 64 , m_isPausedForTesting(false)
64 , m_outdated(false) 65 , m_outdated(false)
65 , m_sequenceNumber(nextSequenceNumber())
66 { 66 {
67 if (m_content) { 67 if (m_content) {
68 if (m_content->player()) 68 if (m_content->player())
69 m_content->player()->cancel(); 69 m_content->player()->cancel();
70 m_content->attach(this); 70 m_content->attach(this);
71 } 71 }
72 } 72 }
73 73
74 AnimationPlayer::~AnimationPlayer() 74 AnimationPlayer::~AnimationPlayer()
75 { 75 {
(...skipping 10 matching lines...) Expand all
86 86
87 bool AnimationPlayer::limited(double currentTime) const 87 bool AnimationPlayer::limited(double currentTime) const
88 { 88 {
89 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu rrentTime >= sourceEnd()); 89 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu rrentTime >= sourceEnd());
90 } 90 }
91 91
92 double AnimationPlayer::currentTimeWithoutLag() const 92 double AnimationPlayer::currentTimeWithoutLag() const
93 { 93 {
94 if (isNull(m_startTime) || !m_timeline) 94 if (isNull(m_startTime) || !m_timeline)
95 return 0; 95 return 0;
96 double timelineTime = m_timeline->currentTime(); 96 return (m_timeline->effectiveTime() - m_startTime) * m_playbackRate;
97 if (isNull(timelineTime))
98 timelineTime = 0;
99 return (timelineTime - m_startTime) * m_playbackRate;
100 } 97 }
101 98
102 double AnimationPlayer::currentTimeWithLag() const 99 double AnimationPlayer::currentTimeWithLag() const
103 { 100 {
104 ASSERT(!m_held); 101 ASSERT(!m_held);
105 double time = currentTimeWithoutLag(); 102 double time = currentTimeWithoutLag();
106 return std::isinf(time) ? time : time - m_storedTimeLag; 103 return std::isinf(time) ? time : time - m_storedTimeLag;
107 } 104 }
108 105
109 void AnimationPlayer::updateTimingState(double newCurrentTime) 106 void AnimationPlayer::updateTimingState(double newCurrentTime)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return; 147 return;
151 updateTimingState(newCurrentTime); 148 updateTimingState(newCurrentTime);
152 } 149 }
153 150
154 void AnimationPlayer::setStartTime(double newStartTime) 151 void AnimationPlayer::setStartTime(double newStartTime)
155 { 152 {
156 if (!std::isfinite(newStartTime)) 153 if (!std::isfinite(newStartTime))
157 return; 154 return;
158 updateCurrentTimingState(); // Update the value of held 155 updateCurrentTimingState(); // Update the value of held
159 m_startTime = newStartTime; 156 m_startTime = newStartTime;
157 m_sortInfo.m_startTime = newStartTime;
160 if (m_held) 158 if (m_held)
161 return; 159 return;
162 updateCurrentTimingState(); 160 updateCurrentTimingState();
163 setOutdated(); 161 setOutdated();
164 } 162 }
165 163
166 void AnimationPlayer::setSource(TimedItem* newSource) 164 void AnimationPlayer::setSource(TimedItem* newSource)
167 { 165 {
168 if (m_content == newSource) 166 if (m_content == newSource)
169 return; 167 return;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 void AnimationPlayer::cancel() 305 void AnimationPlayer::cancel()
308 { 306 {
309 if (!m_content) 307 if (!m_content)
310 return; 308 return;
311 309
312 ASSERT(m_content->player() == this); 310 ASSERT(m_content->player() == this);
313 m_content->detach(); 311 m_content->detach();
314 m_content = nullptr; 312 m_content = nullptr;
315 } 313 }
316 314
317 bool AnimationPlayer::hasLowerPriority(AnimationPlayer* player1, AnimationPlayer * player2) 315 bool AnimationPlayer::SortInfo::operator<(const SortInfo& other) const
318 { 316 {
319 if (player1->m_startTime < player2->m_startTime) 317 ASSERT(!std::isnan(m_startTime) && !std::isnan(other.m_startTime));
318 if (m_startTime < other.m_startTime)
320 return true; 319 return true;
321 if (player1->m_startTime > player2->m_startTime) 320 if (m_startTime > other.m_startTime)
322 return false; 321 return false;
323 if (isNull(player1->m_startTime) != isNull(player2->m_startTime)) 322 return m_sequenceNumber < other.m_sequenceNumber;
324 return isNull(player1->m_startTime);
325 return player1->m_sequenceNumber < player2->m_sequenceNumber;
326 } 323 }
327 324
328 void AnimationPlayer::pauseForTesting(double pauseTime) 325 void AnimationPlayer::pauseForTesting(double pauseTime)
329 { 326 {
330 RELEASE_ASSERT(!paused()); 327 RELEASE_ASSERT(!paused());
331 updateTimingState(pauseTime); 328 updateTimingState(pauseTime);
332 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) 329 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor())
333 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre ntTime()); 330 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre ntTime());
334 m_isPausedForTesting = true; 331 m_isPausedForTesting = true;
335 pause(); 332 pause();
336 } 333 }
337 334
338 } // namespace 335 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/AnimationPlayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698