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

Side by Side Diff: third_party/WebKit/Source/core/svg/animation/SMILTimeContainer.cpp

Issue 2257803002: Refactor SMILTimeContainer can-schedule-frame predicate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@smilcontainer-timeline-cleanup
Patch Set: Rebase Created 4 years, 4 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 | « third_party/WebKit/Source/core/svg/animation/SMILTimeContainer.h ('k') | no next file » | 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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return; 176 return;
177 177
178 // Sample the document timeline to get a time reference for the "presentatio n time". 178 // Sample the document timeline to get a time reference for the "presentatio n time".
179 synchronizeToDocumentTimeline(); 179 synchronizeToDocumentTimeline();
180 m_started = true; 180 m_started = true;
181 181
182 // If the "presentation time" is non-zero, the timeline was modified via 182 // If the "presentation time" is non-zero, the timeline was modified via
183 // setElapsed() before the document began. 183 // setElapsed() before the document began.
184 // In this case pass on 'seekToTime=true' to updateAnimations() to issue a s eek. 184 // In this case pass on 'seekToTime=true' to updateAnimations() to issue a s eek.
185 SMILTime earliestFireTime = updateAnimations(SMILTime(m_presentationTime), m _presentationTime ? true : false); 185 SMILTime earliestFireTime = updateAnimations(SMILTime(m_presentationTime), m _presentationTime ? true : false);
186 186 if (!canScheduleFrame(earliestFireTime))
187 if (isPaused()) {
188 // If updateAnimations() caused new syncbase instances to be generated,
189 // we don't want to cancel those. Excepting that, no frame should've
190 // been scheduled at this point.
191 DCHECK(m_frameSchedulingState == Idle || m_frameSchedulingState == Synch ronizeAnimations);
192 return;
193 }
194 // If synchronizations are pending, those will in turn schedule additional
195 // frames.
196 if (hasPendingSynchronization())
197 return;
198 DCHECK(isTimelineRunning());
199 if (!earliestFireTime.isFinite())
200 return; 187 return;
201 // If the timeline is running, and there are pending animation updates, 188 // If the timeline is running, and there are pending animation updates,
202 // always perform the first update after the timeline was started using 189 // always perform the first update after the timeline was started using
203 // the wake-up mechanism. 190 // the wake-up mechanism.
204 SMILTime delay = earliestFireTime - m_presentationTime; 191 SMILTime delay = earliestFireTime - m_presentationTime;
205 scheduleWakeUp(std::max(initialFrameDelay, delay.value()), SynchronizeAnimat ions); 192 scheduleWakeUp(std::max(initialFrameDelay, delay.value()), SynchronizeAnimat ions);
206 } 193 }
207 194
208 void SMILTimeContainer::pause() 195 void SMILTimeContainer::pause()
209 { 196 {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 397
411 void SMILTimeContainer::serviceAnimations() 398 void SMILTimeContainer::serviceAnimations()
412 { 399 {
413 if (m_frameSchedulingState != AnimationFrame) 400 if (m_frameSchedulingState != AnimationFrame)
414 return; 401 return;
415 402
416 m_frameSchedulingState = Idle; 403 m_frameSchedulingState = Idle;
417 updateAnimationsAndScheduleFrameIfNeeded(elapsed()); 404 updateAnimationsAndScheduleFrameIfNeeded(elapsed());
418 } 405 }
419 406
407 bool SMILTimeContainer::canScheduleFrame(SMILTime earliestFireTime) const
408 {
409 // If there's synchronization pending (most likely due to syncbases), then
410 // let that complete first before attempting to schedule a frame.
411 if (hasPendingSynchronization())
412 return false;
413 if (!isTimelineRunning())
414 return false;
415 return earliestFireTime.isFinite();
416 }
417
420 void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapse d, bool seekToTime) 418 void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapse d, bool seekToTime)
421 { 419 {
422 if (!document().isActive()) 420 if (!document().isActive())
423 return; 421 return;
424 422
425 SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); 423 SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime);
426 // If updateAnimations() ended up triggering a synchronization (most likely 424 if (!canScheduleFrame(earliestFireTime))
427 // via syncbases), then give that priority.
428 if (hasPendingSynchronization())
429 return; 425 return;
430
431 if (!isTimelineRunning())
432 return;
433
434 if (!earliestFireTime.isFinite())
435 return;
436
437 SMILTime delay = earliestFireTime - elapsed; 426 SMILTime delay = earliestFireTime - elapsed;
438 scheduleAnimationFrame(delay.value()); 427 scheduleAnimationFrame(delay.value());
439 } 428 }
440 429
441 SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) 430 SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
442 { 431 {
443 ASSERT(document().isActive()); 432 ASSERT(document().isActive());
444 SMILTime earliestFireTime = SMILTime::unresolved(); 433 SMILTime earliestFireTime = SMILTime::unresolved();
445 434
446 #if ENABLE(ASSERT) 435 #if ENABLE(ASSERT)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 setElapsed(elapsed().value() + initialFrameDelay); 534 setElapsed(elapsed().value() + initialFrameDelay);
546 } 535 }
547 536
548 DEFINE_TRACE(SMILTimeContainer) 537 DEFINE_TRACE(SMILTimeContainer)
549 { 538 {
550 visitor->trace(m_scheduledAnimations); 539 visitor->trace(m_scheduledAnimations);
551 visitor->trace(m_ownerSVGElement); 540 visitor->trace(m_ownerSVGElement);
552 } 541 }
553 542
554 } // namespace blink 543 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/animation/SMILTimeContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698