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
3 // found in the LICENSE file.
5 #include "ui/compositor/layer_animation_element.h"
7 #include "base/compiler_specific.h"
8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_id_provider.h"
10 #include "ui/compositor/float_animation_curve_adapter.h"
11 #include "ui/compositor/layer.h"
12 #include "ui/compositor/layer_animation_delegate.h"
13 #include "ui/compositor/layer_animator.h"
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
15 #include "ui/compositor/transform_animation_curve_adapter.h"
16 #include "ui/gfx/animation/tween.h"
17 #include "ui/gfx/interpolated_transform.h"
23 // The factor by which duration is scaled up or down when
24 // ScopedAnimationDurationScaleMode::duration_scale_mode() is SLOW_DURATION or
26 const int kSlowDurationScaleFactor
= 4;
27 const int kFastDurationScaleFactor
= 4;
29 // Pause -----------------------------------------------------------------------
30 class Pause
: public LayerAnimationElement
{
32 Pause(AnimatableProperties properties
, base::TimeDelta duration
)
33 : LayerAnimationElement(properties
, duration
) {
38 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
39 virtual bool OnProgress(double t
,
40 LayerAnimationDelegate
* delegate
) OVERRIDE
{
43 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{}
44 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
46 DISALLOW_COPY_AND_ASSIGN(Pause
);
49 // TransformTransition ---------------------------------------------------------
51 class TransformTransition
: public LayerAnimationElement
{
53 TransformTransition(const gfx::Transform
& target
, base::TimeDelta duration
)
54 : LayerAnimationElement(TRANSFORM
, duration
),
57 virtual ~TransformTransition() {}
60 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
61 start_
= delegate
->GetTransformForAnimation();
64 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
65 delegate
->SetTransformFromAnimation(
66 gfx::Tween::TransformValueBetween(t
, start_
, target_
));
70 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
71 target
->transform
= target_
;
74 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
77 gfx::Transform start_
;
78 const gfx::Transform target_
;
80 DISALLOW_COPY_AND_ASSIGN(TransformTransition
);
83 // InterpolatedTransformTransition ---------------------------------------------
85 class InterpolatedTransformTransition
: public LayerAnimationElement
{
87 InterpolatedTransformTransition(InterpolatedTransform
* interpolated_transform
,
88 base::TimeDelta duration
)
89 : LayerAnimationElement(TRANSFORM
, duration
),
90 interpolated_transform_(interpolated_transform
) {
92 virtual ~InterpolatedTransformTransition() {}
95 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
98 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
99 delegate
->SetTransformFromAnimation(
100 interpolated_transform_
->Interpolate(static_cast<float>(t
)));
104 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
105 target
->transform
= interpolated_transform_
->Interpolate(1.0f
);
108 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
111 scoped_ptr
<InterpolatedTransform
> interpolated_transform_
;
113 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition
);
116 // BoundsTransition ------------------------------------------------------------
118 class BoundsTransition
: public LayerAnimationElement
{
120 BoundsTransition(const gfx::Rect
& target
, base::TimeDelta duration
)
121 : LayerAnimationElement(BOUNDS
, duration
),
124 virtual ~BoundsTransition() {}
127 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
128 start_
= delegate
->GetBoundsForAnimation();
131 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
132 delegate
->SetBoundsFromAnimation(
133 gfx::Tween::RectValueBetween(t
, start_
, target_
));
137 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
138 target
->bounds
= target_
;
141 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
145 const gfx::Rect target_
;
147 DISALLOW_COPY_AND_ASSIGN(BoundsTransition
);
150 // OpacityTransition -----------------------------------------------------------
152 class OpacityTransition
: public LayerAnimationElement
{
154 OpacityTransition(float target
, base::TimeDelta duration
)
155 : LayerAnimationElement(OPACITY
, duration
),
159 virtual ~OpacityTransition() {}
162 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
163 start_
= delegate
->GetOpacityForAnimation();
166 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
167 delegate
->SetOpacityFromAnimation(
168 gfx::Tween::FloatValueBetween(t
, start_
, target_
));
172 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
173 target
->opacity
= target_
;
176 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
182 DISALLOW_COPY_AND_ASSIGN(OpacityTransition
);
185 // VisibilityTransition --------------------------------------------------------
187 class VisibilityTransition
: public LayerAnimationElement
{
189 VisibilityTransition(bool target
, base::TimeDelta duration
)
190 : LayerAnimationElement(VISIBILITY
, duration
),
194 virtual ~VisibilityTransition() {}
197 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
198 start_
= delegate
->GetVisibilityForAnimation();
201 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
202 delegate
->SetVisibilityFromAnimation(t
== 1.0 ? target_
: start_
);
206 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
207 target
->visibility
= target_
;
210 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
216 DISALLOW_COPY_AND_ASSIGN(VisibilityTransition
);
219 // BrightnessTransition --------------------------------------------------------
221 class BrightnessTransition
: public LayerAnimationElement
{
223 BrightnessTransition(float target
, base::TimeDelta duration
)
224 : LayerAnimationElement(BRIGHTNESS
, duration
),
228 virtual ~BrightnessTransition() {}
231 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
232 start_
= delegate
->GetBrightnessForAnimation();
235 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
236 delegate
->SetBrightnessFromAnimation(
237 gfx::Tween::FloatValueBetween(t
, start_
, target_
));
241 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
242 target
->brightness
= target_
;
245 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
251 DISALLOW_COPY_AND_ASSIGN(BrightnessTransition
);
254 // GrayscaleTransition ---------------------------------------------------------
256 class GrayscaleTransition
: public LayerAnimationElement
{
258 GrayscaleTransition(float target
, base::TimeDelta duration
)
259 : LayerAnimationElement(GRAYSCALE
, duration
),
263 virtual ~GrayscaleTransition() {}
266 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
267 start_
= delegate
->GetGrayscaleForAnimation();
270 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
271 delegate
->SetGrayscaleFromAnimation(
272 gfx::Tween::FloatValueBetween(t
, start_
, target_
));
276 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
277 target
->grayscale
= target_
;
280 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
286 DISALLOW_COPY_AND_ASSIGN(GrayscaleTransition
);
289 // ColorTransition -------------------------------------------------------------
291 class ColorTransition
: public LayerAnimationElement
{
293 ColorTransition(SkColor target
, base::TimeDelta duration
)
294 : LayerAnimationElement(COLOR
, duration
),
295 start_(SK_ColorBLACK
),
298 virtual ~ColorTransition() {}
301 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
302 start_
= delegate
->GetColorForAnimation();
305 virtual bool OnProgress(double t
, LayerAnimationDelegate
* delegate
) OVERRIDE
{
306 delegate
->SetColorFromAnimation(
307 gfx::Tween::ColorValueBetween(t
, start_
, target_
));
311 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
312 target
->color
= target_
;
315 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{}
319 const SkColor target_
;
321 DISALLOW_COPY_AND_ASSIGN(ColorTransition
);
324 // ThreadedLayerAnimationElement -----------------------------------------------
326 class ThreadedLayerAnimationElement
: public LayerAnimationElement
{
328 ThreadedLayerAnimationElement(AnimatableProperties properties
,
329 base::TimeDelta duration
)
330 : LayerAnimationElement(properties
, duration
) {
332 virtual ~ThreadedLayerAnimationElement() {}
334 virtual bool IsThreaded() const OVERRIDE
{
335 return (duration() != base::TimeDelta());
339 explicit ThreadedLayerAnimationElement(const LayerAnimationElement
& element
)
340 : LayerAnimationElement(element
) {
343 virtual bool OnProgress(double t
,
344 LayerAnimationDelegate
* delegate
) OVERRIDE
{
349 delegate
->RemoveThreadedAnimation(animation_id());
356 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{
357 if (delegate
&& Started()) {
358 delegate
->RemoveThreadedAnimation(animation_id());
362 virtual void RequestEffectiveStart(
363 LayerAnimationDelegate
* delegate
) OVERRIDE
{
364 DCHECK(animation_group_id());
365 if (duration() == base::TimeDelta()) {
366 set_effective_start_time(requested_start_time());
369 set_effective_start_time(base::TimeTicks());
370 scoped_ptr
<cc::Animation
> animation
= CreateCCAnimation();
371 animation
->set_needs_synchronized_start_time(true);
372 delegate
->AddThreadedAnimation(animation
.Pass());
375 virtual void OnEnd(LayerAnimationDelegate
* delegate
) = 0;
377 virtual scoped_ptr
<cc::Animation
> CreateCCAnimation() = 0;
380 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement
);
383 // ThreadedOpacityTransition ---------------------------------------------------
385 class ThreadedOpacityTransition
: public ThreadedLayerAnimationElement
{
387 ThreadedOpacityTransition(float target
, base::TimeDelta duration
)
388 : ThreadedLayerAnimationElement(OPACITY
, duration
),
392 virtual ~ThreadedOpacityTransition() {}
395 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
396 start_
= delegate
->GetOpacityForAnimation();
399 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{
400 if (delegate
&& Started()) {
401 ThreadedLayerAnimationElement::OnAbort(delegate
);
402 delegate
->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween(
403 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()),
409 virtual void OnEnd(LayerAnimationDelegate
* delegate
) OVERRIDE
{
410 delegate
->SetOpacityFromAnimation(target_
);
413 virtual scoped_ptr
<cc::Animation
> CreateCCAnimation() OVERRIDE
{
414 scoped_ptr
<cc::AnimationCurve
> animation_curve(
415 new FloatAnimationCurveAdapter(tween_type(),
419 scoped_ptr
<cc::Animation
> animation(
420 cc::Animation::Create(animation_curve
.Pass(),
422 animation_group_id(),
423 cc::Animation::Opacity
));
424 return animation
.Pass();
427 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
428 target
->opacity
= target_
;
435 DISALLOW_COPY_AND_ASSIGN(ThreadedOpacityTransition
);
438 // ThreadedTransformTransition -------------------------------------------------
440 class ThreadedTransformTransition
: public ThreadedLayerAnimationElement
{
442 ThreadedTransformTransition(const gfx::Transform
& target
,
443 base::TimeDelta duration
)
444 : ThreadedLayerAnimationElement(TRANSFORM
, duration
),
447 virtual ~ThreadedTransformTransition() {}
450 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
451 start_
= delegate
->GetTransformForAnimation();
452 float device_scale_factor
= delegate
->GetDeviceScaleFactor();
453 cc_start_
= Layer::ConvertTransformToCCTransform(start_
,
454 device_scale_factor
);
455 cc_target_
= Layer::ConvertTransformToCCTransform(target_
,
456 device_scale_factor
);
459 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{
460 if (delegate
&& Started()) {
461 ThreadedLayerAnimationElement::OnAbort(delegate
);
462 delegate
->SetTransformFromAnimation(gfx::Tween::TransformValueBetween(
463 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()),
469 virtual void OnEnd(LayerAnimationDelegate
* delegate
) OVERRIDE
{
470 delegate
->SetTransformFromAnimation(target_
);
473 virtual scoped_ptr
<cc::Animation
> CreateCCAnimation() OVERRIDE
{
474 scoped_ptr
<cc::AnimationCurve
> animation_curve(
475 new TransformAnimationCurveAdapter(tween_type(),
479 scoped_ptr
<cc::Animation
> animation(
480 cc::Animation::Create(animation_curve
.Pass(),
482 animation_group_id(),
483 cc::Animation::Transform
));
484 return animation
.Pass();
487 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
488 target
->transform
= target_
;
492 gfx::Transform start_
;
493 gfx::Transform cc_start_
;
494 const gfx::Transform target_
;
495 gfx::Transform cc_target_
;
497 DISALLOW_COPY_AND_ASSIGN(ThreadedTransformTransition
);
500 // InverseTransformTransision --------------------------------------------------
502 class InverseTransformTransition
: public ThreadedLayerAnimationElement
{
504 InverseTransformTransition(const gfx::Transform
& base_transform
,
505 const LayerAnimationElement
* uninverted_transition
)
506 : ThreadedLayerAnimationElement(*uninverted_transition
),
507 base_transform_(base_transform
),
508 uninverted_transition_(
509 CheckAndCast
<const ThreadedTransformTransition
*>(
510 uninverted_transition
)) {
512 virtual ~InverseTransformTransition() {}
514 static InverseTransformTransition
* Clone(const LayerAnimationElement
* other
) {
515 const InverseTransformTransition
* other_inverse
=
516 CheckAndCast
<const InverseTransformTransition
*>(other
);
517 return new InverseTransformTransition(
518 other_inverse
->base_transform_
, other_inverse
->uninverted_transition_
);
522 virtual void OnStart(LayerAnimationDelegate
* delegate
) OVERRIDE
{
523 gfx::Transform
start(delegate
->GetTransformForAnimation());
524 effective_start_
= base_transform_
* start
;
527 uninverted_transition_
->GetTargetValue(&target
);
528 base_target_
= target
.transform
;
530 set_tween_type(uninverted_transition_
->tween_type());
532 float device_scale_factor
= delegate
->GetDeviceScaleFactor();
533 const gfx::Transform cc_base_start
= Layer::ConvertTransformToCCTransform(
535 device_scale_factor
);
536 const gfx::Transform cc_base_target
= Layer::ConvertTransformToCCTransform(
538 device_scale_factor
);
539 TransformAnimationCurveAdapter
base_curve(tween_type(),
544 const gfx::Transform cc_start
= Layer::ConvertTransformToCCTransform(
545 start
, device_scale_factor
);
546 animation_curve_
.reset(new InverseTransformCurveAdapter(
547 base_curve
, cc_start
, duration()));
548 computed_target_transform_
= ComputeWithBaseTransform(effective_start_
,
552 virtual void OnAbort(LayerAnimationDelegate
* delegate
) OVERRIDE
{
553 if (delegate
&& Started()) {
554 ThreadedLayerAnimationElement::OnAbort(delegate
);
555 delegate
->SetTransformFromAnimation(ComputeCurrentTransform());
559 virtual void OnEnd(LayerAnimationDelegate
* delegate
) OVERRIDE
{
560 delegate
->SetTransformFromAnimation(computed_target_transform_
);
563 virtual scoped_ptr
<cc::Animation
> CreateCCAnimation() OVERRIDE
{
564 scoped_ptr
<cc::Animation
> animation(
565 cc::Animation::Create(animation_curve_
->Clone(),
567 animation_group_id(),
568 cc::Animation::Transform
));
569 return animation
.Pass();
572 virtual void OnGetTarget(TargetValue
* target
) const OVERRIDE
{
573 target
->transform
= computed_target_transform_
;
577 gfx::Transform
ComputeCurrentTransform() const {
578 gfx::Transform base_current
= gfx::Tween::TransformValueBetween(
579 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()),
582 return ComputeWithBaseTransform(effective_start_
, base_current
);
585 gfx::Transform
ComputeWithBaseTransform(gfx::Transform start
,
586 gfx::Transform target
) const {
587 gfx::Transform
to_return(gfx::Transform::kSkipInitialization
);
588 bool success
= target
.GetInverse(&to_return
);
589 DCHECK(success
) << "Target transform must be invertible.";
591 to_return
.PreconcatTransform(start
);
595 template <typename T
>
596 static T
CheckAndCast(const LayerAnimationElement
* element
) {
597 AnimatableProperties properties
= element
->properties();
598 DCHECK(properties
& TRANSFORM
);
599 return static_cast<T
>(element
);
602 gfx::Transform effective_start_
;
603 gfx::Transform computed_target_transform_
;
605 const gfx::Transform base_transform_
;
606 gfx::Transform base_target_
;
608 scoped_ptr
<cc::AnimationCurve
> animation_curve_
;
610 const ThreadedTransformTransition
* const uninverted_transition_
;
612 DISALLOW_COPY_AND_ASSIGN(InverseTransformTransition
);
617 // LayerAnimationElement::TargetValue ------------------------------------------
619 LayerAnimationElement::TargetValue::TargetValue()
624 color(SK_ColorBLACK
) {
627 LayerAnimationElement::TargetValue::TargetValue(
628 const LayerAnimationDelegate
* delegate
)
629 : bounds(delegate
? delegate
->GetBoundsForAnimation() : gfx::Rect()),
631 delegate
->GetTransformForAnimation() : gfx::Transform()),
632 opacity(delegate
? delegate
->GetOpacityForAnimation() : 0.0f
),
633 visibility(delegate
? delegate
->GetVisibilityForAnimation() : false),
634 brightness(delegate
? delegate
->GetBrightnessForAnimation() : 0.0f
),
635 grayscale(delegate
? delegate
->GetGrayscaleForAnimation() : 0.0f
),
636 color(delegate
? delegate
->GetColorForAnimation() : 0.0f
) {
639 // LayerAnimationElement -------------------------------------------------------
641 LayerAnimationElement::LayerAnimationElement(
642 AnimatableProperties properties
, base::TimeDelta duration
)
643 : first_frame_(true),
644 properties_(properties
),
645 duration_(GetEffectiveDuration(duration
)),
646 tween_type_(gfx::Tween::LINEAR
),
647 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
648 animation_group_id_(0),
649 last_progressed_fraction_(0.0),
650 weak_ptr_factory_(this) {
653 LayerAnimationElement::LayerAnimationElement(
654 const LayerAnimationElement
&element
)
655 : first_frame_(element
.first_frame_
),
656 properties_(element
.properties_
),
657 duration_(element
.duration_
),
658 tween_type_(element
.tween_type_
),
659 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
660 animation_group_id_(element
.animation_group_id_
),
661 last_progressed_fraction_(element
.last_progressed_fraction_
),
662 weak_ptr_factory_(this) {
665 LayerAnimationElement::~LayerAnimationElement() {
668 void LayerAnimationElement::Start(LayerAnimationDelegate
* delegate
,
669 int animation_group_id
) {
670 DCHECK(requested_start_time_
!= base::TimeTicks());
671 DCHECK(first_frame_
);
672 animation_group_id_
= animation_group_id
;
673 last_progressed_fraction_
= 0.0;
675 RequestEffectiveStart(delegate
);
676 first_frame_
= false;
679 bool LayerAnimationElement::Progress(base::TimeTicks now
,
680 LayerAnimationDelegate
* delegate
) {
681 DCHECK(requested_start_time_
!= base::TimeTicks());
682 DCHECK(!first_frame_
);
687 if ((effective_start_time_
== base::TimeTicks()) ||
688 (now
< effective_start_time_
)) {
689 // This hasn't actually started yet.
691 last_progressed_fraction_
= 0.0;
695 base::TimeDelta elapsed
= now
- effective_start_time_
;
696 if ((duration_
> base::TimeDelta()) && (elapsed
< duration_
))
697 t
= elapsed
.InMillisecondsF() / duration_
.InMillisecondsF();
698 base::WeakPtr
<LayerAnimationElement
> alive(weak_ptr_factory_
.GetWeakPtr());
699 need_draw
= OnProgress(gfx::Tween::CalculateValue(tween_type_
, t
), delegate
);
702 first_frame_
= t
== 1.0;
703 last_progressed_fraction_
= t
;
707 bool LayerAnimationElement::IsFinished(base::TimeTicks time
,
708 base::TimeDelta
* total_duration
) {
709 // If an effective start has been requested but the effective start time
710 // hasn't yet been set, the animation is not finished, regardless of the
712 if (!first_frame_
&& (effective_start_time_
== base::TimeTicks()))
715 base::TimeDelta queueing_delay
;
717 queueing_delay
= effective_start_time_
- requested_start_time_
;
719 base::TimeDelta elapsed
= time
- requested_start_time_
;
720 if (elapsed
>= duration_
+ queueing_delay
) {
721 *total_duration
= duration_
+ queueing_delay
;
727 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate
* delegate
) {
730 base::WeakPtr
<LayerAnimationElement
> alive(weak_ptr_factory_
.GetWeakPtr());
731 bool need_draw
= OnProgress(1.0, delegate
);
734 last_progressed_fraction_
= 1.0;
739 void LayerAnimationElement::GetTargetValue(TargetValue
* target
) const {
743 bool LayerAnimationElement::IsThreaded() const {
747 void LayerAnimationElement::Abort(LayerAnimationDelegate
* delegate
) {
752 void LayerAnimationElement::RequestEffectiveStart(
753 LayerAnimationDelegate
* delegate
) {
754 DCHECK(requested_start_time_
!= base::TimeTicks());
755 effective_start_time_
= requested_start_time_
;
759 LayerAnimationElement::AnimatableProperty
760 LayerAnimationElement::ToAnimatableProperty(
761 cc::Animation::TargetProperty property
) {
763 case cc::Animation::Transform
:
765 case cc::Animation::Opacity
:
769 return AnimatableProperty();
774 base::TimeDelta
LayerAnimationElement::GetEffectiveDuration(
775 const base::TimeDelta
& duration
) {
776 switch (ScopedAnimationDurationScaleMode::duration_scale_mode()) {
777 case ScopedAnimationDurationScaleMode::NORMAL_DURATION
:
779 case ScopedAnimationDurationScaleMode::FAST_DURATION
:
780 return duration
/ kFastDurationScaleFactor
;
781 case ScopedAnimationDurationScaleMode::SLOW_DURATION
:
782 return duration
* kSlowDurationScaleFactor
;
783 case ScopedAnimationDurationScaleMode::ZERO_DURATION
:
784 return base::TimeDelta();
787 return base::TimeDelta();
792 LayerAnimationElement
* LayerAnimationElement::CreateTransformElement(
793 const gfx::Transform
& transform
,
794 base::TimeDelta duration
) {
795 return new ThreadedTransformTransition(transform
, duration
);
799 LayerAnimationElement
* LayerAnimationElement::CreateInverseTransformElement(
800 const gfx::Transform
& base_transform
,
801 const LayerAnimationElement
* uninverted_transition
) {
802 return new InverseTransformTransition(base_transform
, uninverted_transition
);
806 LayerAnimationElement
* LayerAnimationElement::CloneInverseTransformElement(
807 const LayerAnimationElement
* other
) {
808 return InverseTransformTransition::Clone(other
);
812 LayerAnimationElement
*
813 LayerAnimationElement::CreateInterpolatedTransformElement(
814 InterpolatedTransform
* interpolated_transform
,
815 base::TimeDelta duration
) {
816 return new InterpolatedTransformTransition(interpolated_transform
, duration
);
820 LayerAnimationElement
* LayerAnimationElement::CreateBoundsElement(
821 const gfx::Rect
& bounds
,
822 base::TimeDelta duration
) {
823 return new BoundsTransition(bounds
, duration
);
827 LayerAnimationElement
* LayerAnimationElement::CreateOpacityElement(
829 base::TimeDelta duration
) {
830 return new ThreadedOpacityTransition(opacity
, duration
);
834 LayerAnimationElement
* LayerAnimationElement::CreateVisibilityElement(
836 base::TimeDelta duration
) {
837 return new VisibilityTransition(visibility
, duration
);
841 LayerAnimationElement
* LayerAnimationElement::CreateBrightnessElement(
843 base::TimeDelta duration
) {
844 return new BrightnessTransition(brightness
, duration
);
848 LayerAnimationElement
* LayerAnimationElement::CreateGrayscaleElement(
850 base::TimeDelta duration
) {
851 return new GrayscaleTransition(grayscale
, duration
);
855 LayerAnimationElement
* LayerAnimationElement::CreatePauseElement(
856 AnimatableProperties properties
,
857 base::TimeDelta duration
) {
858 return new Pause(properties
, duration
);
862 LayerAnimationElement
* LayerAnimationElement::CreateColorElement(
864 base::TimeDelta duration
) {
865 return new ColorTransition(color
, duration
);