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 using
24 // ScopedAnimationDurationScaleMode.
25 const int kSlowDurationScaleMultiplier = 4;
26 const int kFastDurationScaleDivisor = 4;
27 const int kNonZeroDurationScaleDivisor = 20;
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();
454 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {
455 if (delegate && Started()) {
456 ThreadedLayerAnimationElement::OnAbort(delegate);
457 delegate->SetTransformFromAnimation(gfx::Tween::TransformValueBetween(
458 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()),
464 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE {
465 delegate->SetTransformFromAnimation(target_);
468 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE {
469 scoped_ptr<cc::AnimationCurve> animation_curve(
470 new TransformAnimationCurveAdapter(tween_type(),
474 scoped_ptr<cc::Animation> animation(
475 cc::Animation::Create(animation_curve.Pass(),
477 animation_group_id(),
478 cc::Animation::Transform));
479 return animation.Pass();
482 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
483 target->transform = target_;
487 gfx::Transform start_;
488 const gfx::Transform target_;
490 DISALLOW_COPY_AND_ASSIGN(ThreadedTransformTransition);
493 // InverseTransformTransision --------------------------------------------------
495 class InverseTransformTransition : public ThreadedLayerAnimationElement {
497 InverseTransformTransition(const gfx::Transform& base_transform,
498 const LayerAnimationElement* uninverted_transition)
499 : ThreadedLayerAnimationElement(*uninverted_transition),
500 base_transform_(base_transform),
501 uninverted_transition_(
502 CheckAndCast<const ThreadedTransformTransition*>(
503 uninverted_transition)) {
505 virtual ~InverseTransformTransition() {}
507 static InverseTransformTransition* Clone(const LayerAnimationElement* other) {
508 const InverseTransformTransition* other_inverse =
509 CheckAndCast<const InverseTransformTransition*>(other);
510 return new InverseTransformTransition(
511 other_inverse->base_transform_, other_inverse->uninverted_transition_);
515 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
516 gfx::Transform start(delegate->GetTransformForAnimation());
517 effective_start_ = base_transform_ * start;
520 uninverted_transition_->GetTargetValue(&target);
521 base_target_ = target.transform;
523 set_tween_type(uninverted_transition_->tween_type());
525 TransformAnimationCurveAdapter base_curve(tween_type(),
530 animation_curve_.reset(new InverseTransformCurveAdapter(
531 base_curve, start, duration()));
532 computed_target_transform_ = ComputeWithBaseTransform(effective_start_,
536 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {
537 if (delegate && Started()) {
538 ThreadedLayerAnimationElement::OnAbort(delegate);
539 delegate->SetTransformFromAnimation(ComputeCurrentTransform());
543 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE {
544 delegate->SetTransformFromAnimation(computed_target_transform_);
547 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE {
548 scoped_ptr<cc::Animation> animation(
549 cc::Animation::Create(animation_curve_->Clone(),
551 animation_group_id(),
552 cc::Animation::Transform));
553 return animation.Pass();
556 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
557 target->transform = computed_target_transform_;
561 gfx::Transform ComputeCurrentTransform() const {
562 gfx::Transform base_current = gfx::Tween::TransformValueBetween(
563 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()),
566 return ComputeWithBaseTransform(effective_start_, base_current);
569 gfx::Transform ComputeWithBaseTransform(gfx::Transform start,
570 gfx::Transform target) const {
571 gfx::Transform to_return(gfx::Transform::kSkipInitialization);
572 bool success = target.GetInverse(&to_return);
573 DCHECK(success) << "Target transform must be invertible.";
575 to_return.PreconcatTransform(start);
579 template <typename T>
580 static T CheckAndCast(const LayerAnimationElement* element) {
581 AnimatableProperties properties = element->properties();
582 DCHECK(properties & TRANSFORM);
583 return static_cast<T>(element);
586 gfx::Transform effective_start_;
587 gfx::Transform computed_target_transform_;
589 const gfx::Transform base_transform_;
590 gfx::Transform base_target_;
592 scoped_ptr<cc::AnimationCurve> animation_curve_;
594 const ThreadedTransformTransition* const uninverted_transition_;
596 DISALLOW_COPY_AND_ASSIGN(InverseTransformTransition);
601 // LayerAnimationElement::TargetValue ------------------------------------------
603 LayerAnimationElement::TargetValue::TargetValue()
608 color(SK_ColorBLACK) {
611 LayerAnimationElement::TargetValue::TargetValue(
612 const LayerAnimationDelegate* delegate)
613 : bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()),
615 delegate->GetTransformForAnimation() : gfx::Transform()),
616 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f),
617 visibility(delegate ? delegate->GetVisibilityForAnimation() : false),
618 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f),
619 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f),
620 color(delegate ? delegate->GetColorForAnimation() : 0.0f) {
623 // LayerAnimationElement -------------------------------------------------------
625 LayerAnimationElement::LayerAnimationElement(
626 AnimatableProperties properties, base::TimeDelta duration)
627 : first_frame_(true),
628 properties_(properties),
629 duration_(GetEffectiveDuration(duration)),
630 tween_type_(gfx::Tween::LINEAR),
631 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
632 animation_group_id_(0),
633 last_progressed_fraction_(0.0),
634 weak_ptr_factory_(this) {
637 LayerAnimationElement::LayerAnimationElement(
638 const LayerAnimationElement &element)
639 : first_frame_(element.first_frame_),
640 properties_(element.properties_),
641 duration_(element.duration_),
642 tween_type_(element.tween_type_),
643 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
644 animation_group_id_(element.animation_group_id_),
645 last_progressed_fraction_(element.last_progressed_fraction_),
646 weak_ptr_factory_(this) {
649 LayerAnimationElement::~LayerAnimationElement() {
652 void LayerAnimationElement::Start(LayerAnimationDelegate* delegate,
653 int animation_group_id) {
654 DCHECK(requested_start_time_ != base::TimeTicks());
655 DCHECK(first_frame_);
656 animation_group_id_ = animation_group_id;
657 last_progressed_fraction_ = 0.0;
659 RequestEffectiveStart(delegate);
660 first_frame_ = false;
663 bool LayerAnimationElement::Progress(base::TimeTicks now,
664 LayerAnimationDelegate* delegate) {
665 DCHECK(requested_start_time_ != base::TimeTicks());
666 DCHECK(!first_frame_);
671 if ((effective_start_time_ == base::TimeTicks()) ||
672 (now < effective_start_time_)) {
673 // This hasn't actually started yet.
675 last_progressed_fraction_ = 0.0;
679 base::TimeDelta elapsed = now - effective_start_time_;
680 if ((duration_ > base::TimeDelta()) && (elapsed < duration_))
681 t = elapsed.InMillisecondsF() / duration_.InMillisecondsF();
682 base::WeakPtr<LayerAnimationElement> alive(weak_ptr_factory_.GetWeakPtr());
683 need_draw = OnProgress(gfx::Tween::CalculateValue(tween_type_, t), delegate);
686 first_frame_ = t == 1.0;
687 last_progressed_fraction_ = t;
691 bool LayerAnimationElement::IsFinished(base::TimeTicks time,
692 base::TimeDelta* total_duration) {
693 // If an effective start has been requested but the effective start time
694 // hasn't yet been set, the animation is not finished, regardless of the
696 if (!first_frame_ && (effective_start_time_ == base::TimeTicks()))
699 base::TimeDelta queueing_delay;
701 queueing_delay = effective_start_time_ - requested_start_time_;
703 base::TimeDelta elapsed = time - requested_start_time_;
704 if (elapsed >= duration_ + queueing_delay) {
705 *total_duration = duration_ + queueing_delay;
711 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) {
714 base::WeakPtr<LayerAnimationElement> alive(weak_ptr_factory_.GetWeakPtr());
715 bool need_draw = OnProgress(1.0, delegate);
718 last_progressed_fraction_ = 1.0;
723 void LayerAnimationElement::GetTargetValue(TargetValue* target) const {
727 bool LayerAnimationElement::IsThreaded() const {
731 void LayerAnimationElement::Abort(LayerAnimationDelegate* delegate) {
736 void LayerAnimationElement::RequestEffectiveStart(
737 LayerAnimationDelegate* delegate) {
738 DCHECK(requested_start_time_ != base::TimeTicks());
739 effective_start_time_ = requested_start_time_;
743 LayerAnimationElement::AnimatableProperty
744 LayerAnimationElement::ToAnimatableProperty(
745 cc::Animation::TargetProperty property) {
747 case cc::Animation::Transform:
749 case cc::Animation::Opacity:
753 return AnimatableProperty();
758 base::TimeDelta LayerAnimationElement::GetEffectiveDuration(
759 const base::TimeDelta& duration) {
760 switch (ScopedAnimationDurationScaleMode::duration_scale_mode()) {
761 case ScopedAnimationDurationScaleMode::NORMAL_DURATION:
763 case ScopedAnimationDurationScaleMode::FAST_DURATION:
764 return duration / kFastDurationScaleDivisor;
765 case ScopedAnimationDurationScaleMode::SLOW_DURATION:
766 return duration * kSlowDurationScaleMultiplier;
767 case ScopedAnimationDurationScaleMode::NON_ZERO_DURATION:
768 return duration / kNonZeroDurationScaleDivisor;
769 case ScopedAnimationDurationScaleMode::ZERO_DURATION:
770 return base::TimeDelta();
773 return base::TimeDelta();
778 LayerAnimationElement* LayerAnimationElement::CreateTransformElement(
779 const gfx::Transform& transform,
780 base::TimeDelta duration) {
781 return new ThreadedTransformTransition(transform, duration);
785 LayerAnimationElement* LayerAnimationElement::CreateInverseTransformElement(
786 const gfx::Transform& base_transform,
787 const LayerAnimationElement* uninverted_transition) {
788 return new InverseTransformTransition(base_transform, uninverted_transition);
792 LayerAnimationElement* LayerAnimationElement::CloneInverseTransformElement(
793 const LayerAnimationElement* other) {
794 return InverseTransformTransition::Clone(other);
798 LayerAnimationElement*
799 LayerAnimationElement::CreateInterpolatedTransformElement(
800 InterpolatedTransform* interpolated_transform,
801 base::TimeDelta duration) {
802 return new InterpolatedTransformTransition(interpolated_transform, duration);
806 LayerAnimationElement* LayerAnimationElement::CreateBoundsElement(
807 const gfx::Rect& bounds,
808 base::TimeDelta duration) {
809 return new BoundsTransition(bounds, duration);
813 LayerAnimationElement* LayerAnimationElement::CreateOpacityElement(
815 base::TimeDelta duration) {
816 return new ThreadedOpacityTransition(opacity, duration);
820 LayerAnimationElement* LayerAnimationElement::CreateVisibilityElement(
822 base::TimeDelta duration) {
823 return new VisibilityTransition(visibility, duration);
827 LayerAnimationElement* LayerAnimationElement::CreateBrightnessElement(
829 base::TimeDelta duration) {
830 return new BrightnessTransition(brightness, duration);
834 LayerAnimationElement* LayerAnimationElement::CreateGrayscaleElement(
836 base::TimeDelta duration) {
837 return new GrayscaleTransition(grayscale, duration);
841 LayerAnimationElement* LayerAnimationElement::CreatePauseElement(
842 AnimatableProperties properties,
843 base::TimeDelta duration) {
844 return new Pause(properties, duration);
848 LayerAnimationElement* LayerAnimationElement::CreateColorElement(
850 base::TimeDelta duration) {
851 return new ColorTransition(color, duration);