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

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

Issue 8362006: Reland r107720 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/compositor/layer_animator.h" 5 #include "ui/gfx/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void LayerAnimator::SetTransform(const Transform& transform) { 54 void LayerAnimator::SetTransform(const Transform& transform) {
55 if (transition_duration_ == base::TimeDelta()) 55 if (transition_duration_ == base::TimeDelta())
56 delegate_->SetTransformFromAnimation(transform); 56 delegate_->SetTransformFromAnimation(transform);
57 else 57 else
58 StartAnimation(new LayerAnimationSequence( 58 StartAnimation(new LayerAnimationSequence(
59 LayerAnimationElement::CreateTransformElement(transform, 59 LayerAnimationElement::CreateTransformElement(transform,
60 transition_duration_))); 60 transition_duration_)));
61 } 61 }
62 62
63 Transform LayerAnimator::GetTargetTransform() const {
64 LayerAnimationElement::TargetValue target;
65 GetTargetValue(&target);
66 return target.transform;
67 }
68
63 void LayerAnimator::SetBounds(const gfx::Rect& bounds) { 69 void LayerAnimator::SetBounds(const gfx::Rect& bounds) {
64 if (transition_duration_ == base::TimeDelta()) 70 if (transition_duration_ == base::TimeDelta())
65 delegate_->SetBoundsFromAnimation(bounds); 71 delegate_->SetBoundsFromAnimation(bounds);
66 else 72 else
67 StartAnimation(new LayerAnimationSequence( 73 StartAnimation(new LayerAnimationSequence(
68 LayerAnimationElement::CreateBoundsElement(bounds, 74 LayerAnimationElement::CreateBoundsElement(bounds,
69 transition_duration_))); 75 transition_duration_)));
70 } 76 }
71 77
78 gfx::Rect LayerAnimator::GetTargetBounds() const {
79 LayerAnimationElement::TargetValue target;
80 GetTargetValue(&target);
81 return target.bounds;
82 }
83
72 void LayerAnimator::SetOpacity(float opacity) { 84 void LayerAnimator::SetOpacity(float opacity) {
73 if (transition_duration_ == base::TimeDelta()) 85 if (transition_duration_ == base::TimeDelta())
74 delegate_->SetOpacityFromAnimation(opacity); 86 delegate_->SetOpacityFromAnimation(opacity);
75 else 87 else
76 StartAnimation(new LayerAnimationSequence( 88 StartAnimation(new LayerAnimationSequence(
77 LayerAnimationElement::CreateOpacityElement(opacity, 89 LayerAnimationElement::CreateOpacityElement(opacity,
78 transition_duration_))); 90 transition_duration_)));
79 } 91 }
80 92
93 float LayerAnimator::GetTargetOpacity() const {
94 LayerAnimationElement::TargetValue target;
95 GetTargetValue(&target);
96 return target.opacity;
97 }
98
81 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) { 99 void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
82 DCHECK(delegate); 100 DCHECK(delegate);
83 delegate_ = delegate; 101 delegate_ = delegate;
84 } 102 }
85 103
86 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) { 104 void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
87 if (!StartSequenceImmediately(animation)) { 105 if (!StartSequenceImmediately(animation)) {
88 // Attempt to preempt a running animation. 106 // Attempt to preempt a running animation.
89 switch (preemption_strategy_) { 107 switch (preemption_strategy_) {
90 case IMMEDIATELY_SET_NEW_TARGET: 108 case IMMEDIATELY_SET_NEW_TARGET:
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 451
434 // Need to keep a reference to the animation. 452 // Need to keep a reference to the animation.
435 AddToQueueIfNotPresent(sequence); 453 AddToQueueIfNotPresent(sequence);
436 454
437 // Ensure that animations get stepped at their start time. 455 // Ensure that animations get stepped at their start time.
438 Step(start_time); 456 Step(start_time);
439 457
440 return true; 458 return true;
441 } 459 }
442 460
461 void LayerAnimator::GetTargetValue(
462 LayerAnimationElement::TargetValue* target) const {
463 for (RunningAnimations::const_iterator iter = running_animations_.begin();
464 iter != running_animations_.end(); ++iter) {
465 (*iter).sequence->GetTargetValue(target);
466 }
467
468 for (AnimationQueue::const_iterator iter = animation_queue_.begin();
469 iter != animation_queue_.end(); ++iter) {
470 (*iter)->GetTargetValue(target);
471 }
472 }
473
443 } // namespace ui 474 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698