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

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 11316315: Remove ui::LayerAnimationSequence::duration and ui::LayerAnimationElement::duration. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make unit tests use IsFinished() instead of duration() Created 8 years 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 | « ui/compositor/layer_animation_sequence_unittest.cc ('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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/base/animation/animation_container.h" 10 #include "ui/base/animation/animation_container.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 void LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence, 327 void LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence,
328 base::TimeDelta delta) { 328 base::TimeDelta delta) {
329 if (!delegate()) 329 if (!delegate())
330 return; 330 return;
331 331
332 sequence->Progress(delta, delegate()); 332 sequence->Progress(delta, delegate());
333 } 333 }
334 334
335 void LayerAnimator::ProgressAnimationToEnd(LayerAnimationSequence* sequence) { 335 void LayerAnimator::ProgressAnimationToEnd(LayerAnimationSequence* sequence) {
336 ProgressAnimation(sequence, sequence->duration()); 336 if (!delegate())
337 return;
338
339 sequence->ProgressToEnd(delegate());
337 } 340 }
338 341
339 342
340 bool LayerAnimator::HasAnimation(LayerAnimationSequence* sequence) const { 343 bool LayerAnimator::HasAnimation(LayerAnimationSequence* sequence) const {
341 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin(); 344 for (AnimationQueue::const_iterator queue_iter = animation_queue_.begin();
342 queue_iter != animation_queue_.end(); ++queue_iter) { 345 queue_iter != animation_queue_.end(); ++queue_iter) {
343 if ((*queue_iter).get() == sequence) 346 if ((*queue_iter).get() == sequence)
344 return true; 347 return true;
345 } 348 }
346 return false; 349 return false;
(...skipping 11 matching lines...) Expand all
358 361
359 // We need to make a copy of the running animations because progressing them 362 // We need to make a copy of the running animations because progressing them
360 // and finishing them may indirectly affect the collection of running 363 // and finishing them may indirectly affect the collection of running
361 // animations. 364 // animations.
362 RunningAnimations running_animations_copy = running_animations_; 365 RunningAnimations running_animations_copy = running_animations_;
363 for (size_t i = 0; i < running_animations_copy.size(); ++i) { 366 for (size_t i = 0; i < running_animations_copy.size(); ++i) {
364 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) 367 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
365 continue; 368 continue;
366 369
367 base::TimeDelta delta = now - running_animations_copy[i].start_time(); 370 base::TimeDelta delta = now - running_animations_copy[i].start_time();
368 if (delta >= running_animations_copy[i].sequence()->duration() && 371 if (running_animations_copy[i].sequence()->IsFinished(delta)) {
369 !running_animations_copy[i].sequence()->is_cyclic()) {
370 SAFE_INVOKE_VOID(FinishAnimation, running_animations_copy[i]); 372 SAFE_INVOKE_VOID(FinishAnimation, running_animations_copy[i]);
371 } else 373 } else
372 SAFE_INVOKE_VOID(ProgressAnimation, running_animations_copy[i], delta); 374 SAFE_INVOKE_VOID(ProgressAnimation, running_animations_copy[i], delta);
373 } 375 }
374 } 376 }
375 377
376 void LayerAnimator::SetStartTime(base::TimeTicks start_time) { 378 void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
377 // Do nothing. 379 // Do nothing.
378 } 380 }
379 381
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 break; 418 break;
417 } 419 }
418 } 420 }
419 421
420 return to_return.release(); 422 return to_return.release();
421 } 423 }
422 424
423 void LayerAnimator::FinishAnimation(LayerAnimationSequence* sequence) { 425 void LayerAnimator::FinishAnimation(LayerAnimationSequence* sequence) {
424 scoped_refptr<LayerAnimator> retain(this); 426 scoped_refptr<LayerAnimator> retain(this);
425 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence)); 427 scoped_ptr<LayerAnimationSequence> removed(RemoveAnimation(sequence));
426 if (delegate()) 428 ProgressAnimationToEnd(sequence);
427 sequence->Progress(sequence->duration(), delegate());
428 ProcessQueue(); 429 ProcessQueue();
429 UpdateAnimationState(); 430 UpdateAnimationState();
430 } 431 }
431 432
432 void LayerAnimator::FinishAnyAnimationWithZeroDuration() { 433 void LayerAnimator::FinishAnyAnimationWithZeroDuration() {
433 scoped_refptr<LayerAnimator> retain(this); 434 scoped_refptr<LayerAnimator> retain(this);
434 // Special case: if we've started a 0 duration animation, just finish it now 435 // Special case: if we've started a 0 duration animation, just finish it now
435 // and get rid of it. We need to make a copy because Progress may indirectly 436 // and get rid of it. We need to make a copy because Progress may indirectly
436 // cause new animations to start running. 437 // cause new animations to start running.
437 RunningAnimations running_animations_copy = running_animations_; 438 RunningAnimations running_animations_copy = running_animations_;
438 for (size_t i = 0; i < running_animations_copy.size(); ++i) { 439 for (size_t i = 0; i < running_animations_copy.size(); ++i) {
439 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i])) 440 if (!SAFE_INVOKE_BOOL(HasAnimation, running_animations_copy[i]))
440 continue; 441 continue;
441 442
442 if (running_animations_copy[i].sequence()->duration() == 443 if (running_animations_copy[i].sequence()->IsFinished(base::TimeDelta())) {
443 base::TimeDelta()) {
444 SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]); 444 SAFE_INVOKE_VOID(ProgressAnimationToEnd, running_animations_copy[i]);
445 scoped_ptr<LayerAnimationSequence> removed( 445 scoped_ptr<LayerAnimationSequence> removed(
446 SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i])); 446 SAFE_INVOKE_PTR(RemoveAnimation, running_animations_copy[i]));
447 } 447 }
448 } 448 }
449 ProcessQueue(); 449 ProcessQueue();
450 UpdateAnimationState(); 450 UpdateAnimationState();
451 } 451 }
452 452
453 void LayerAnimator::ClearAnimations() { 453 void LayerAnimator::ClearAnimations() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 const bool abort = false; 533 const bool abort = false;
534 RemoveAllAnimationsWithACommonProperty(sequence, abort); 534 RemoveAllAnimationsWithACommonProperty(sequence, abort);
535 if (!weak_sequence_ptr) 535 if (!weak_sequence_ptr)
536 return; 536 return;
537 537
538 LayerAnimationSequence* removed = RemoveAnimation(sequence); 538 LayerAnimationSequence* removed = RemoveAnimation(sequence);
539 DCHECK(removed == NULL || removed == sequence); 539 DCHECK(removed == NULL || removed == sequence);
540 if (!weak_sequence_ptr) 540 if (!weak_sequence_ptr)
541 return; 541 return;
542 542
543 ProgressAnimation(sequence, sequence->duration()); 543 ProgressAnimationToEnd(sequence);
544 if (!weak_sequence_ptr) 544 if (!weak_sequence_ptr)
545 return; 545 return;
546 546
547 delete sequence; 547 delete sequence;
548 } 548 }
549 549
550 void LayerAnimator::ImmediatelyAnimateToNewTarget( 550 void LayerAnimator::ImmediatelyAnimateToNewTarget(
551 LayerAnimationSequence* sequence) { 551 LayerAnimationSequence* sequence) {
552 // Need to detect if our sequence gets destroyed. 552 // Need to detect if our sequence gets destroyed.
553 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr = 553 base::WeakPtr<LayerAnimationSequence> weak_sequence_ptr =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 LayerAnimator::RunningAnimation::RunningAnimation( 749 LayerAnimator::RunningAnimation::RunningAnimation(
750 const base::WeakPtr<LayerAnimationSequence>& sequence, 750 const base::WeakPtr<LayerAnimationSequence>& sequence,
751 base::TimeTicks start_time) 751 base::TimeTicks start_time)
752 : sequence_(sequence), 752 : sequence_(sequence),
753 start_time_(start_time) { 753 start_time_(start_time) {
754 } 754 }
755 755
756 LayerAnimator::RunningAnimation::~RunningAnimation() { } 756 LayerAnimator::RunningAnimation::~RunningAnimation() { }
757 757
758 } // namespace ui 758 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_sequence_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698