OLD | NEW |
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_animation_element.h" | 5 #include "ui/compositor/layer_animation_element.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
8 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_id_provider.h" | 11 #include "cc/animation/animation_id_provider.h" |
10 #include "ui/compositor/float_animation_curve_adapter.h" | 12 #include "ui/compositor/float_animation_curve_adapter.h" |
11 #include "ui/compositor/layer.h" | 13 #include "ui/compositor/layer.h" |
12 #include "ui/compositor/layer_animation_delegate.h" | 14 #include "ui/compositor/layer_animation_delegate.h" |
13 #include "ui/compositor/layer_animator.h" | 15 #include "ui/compositor/layer_animator.h" |
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
15 #include "ui/compositor/transform_animation_curve_adapter.h" | 17 #include "ui/compositor/transform_animation_curve_adapter.h" |
16 #include "ui/gfx/animation/tween.h" | 18 #include "ui/gfx/animation/tween.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 358 |
357 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { | 359 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { |
358 DCHECK(animation_group_id()); | 360 DCHECK(animation_group_id()); |
359 if (!IsThreaded()) { | 361 if (!IsThreaded()) { |
360 set_effective_start_time(requested_start_time()); | 362 set_effective_start_time(requested_start_time()); |
361 return; | 363 return; |
362 } | 364 } |
363 set_effective_start_time(base::TimeTicks()); | 365 set_effective_start_time(base::TimeTicks()); |
364 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); | 366 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); |
365 animation->set_needs_synchronized_start_time(true); | 367 animation->set_needs_synchronized_start_time(true); |
366 delegate->AddThreadedAnimation(animation.Pass()); | 368 delegate->AddThreadedAnimation(std::move(animation)); |
367 } | 369 } |
368 | 370 |
369 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; | 371 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; |
370 | 372 |
371 virtual scoped_ptr<cc::Animation> CreateCCAnimation() = 0; | 373 virtual scoped_ptr<cc::Animation> CreateCCAnimation() = 0; |
372 | 374 |
373 private: | 375 private: |
374 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement); | 376 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement); |
375 }; | 377 }; |
376 | 378 |
(...skipping 27 matching lines...) Expand all Loading... |
404 delegate->SetOpacityFromAnimation(target_); | 406 delegate->SetOpacityFromAnimation(target_); |
405 } | 407 } |
406 | 408 |
407 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 409 scoped_ptr<cc::Animation> CreateCCAnimation() override { |
408 scoped_ptr<cc::AnimationCurve> animation_curve( | 410 scoped_ptr<cc::AnimationCurve> animation_curve( |
409 new FloatAnimationCurveAdapter(tween_type(), | 411 new FloatAnimationCurveAdapter(tween_type(), |
410 start_, | 412 start_, |
411 target_, | 413 target_, |
412 duration())); | 414 duration())); |
413 scoped_ptr<cc::Animation> animation( | 415 scoped_ptr<cc::Animation> animation( |
414 cc::Animation::Create(animation_curve.Pass(), animation_id(), | 416 cc::Animation::Create(std::move(animation_curve), animation_id(), |
415 animation_group_id(), cc::Animation::OPACITY)); | 417 animation_group_id(), cc::Animation::OPACITY)); |
416 return animation.Pass(); | 418 return animation; |
417 } | 419 } |
418 | 420 |
419 void OnGetTarget(TargetValue* target) const override { | 421 void OnGetTarget(TargetValue* target) const override { |
420 target->opacity = target_; | 422 target->opacity = target_; |
421 } | 423 } |
422 | 424 |
423 private: | 425 private: |
424 float start_; | 426 float start_; |
425 const float target_; | 427 const float target_; |
426 | 428 |
(...skipping 30 matching lines...) Expand all Loading... |
457 delegate->SetTransformFromAnimation(target_); | 459 delegate->SetTransformFromAnimation(target_); |
458 } | 460 } |
459 | 461 |
460 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 462 scoped_ptr<cc::Animation> CreateCCAnimation() override { |
461 scoped_ptr<cc::AnimationCurve> animation_curve( | 463 scoped_ptr<cc::AnimationCurve> animation_curve( |
462 new TransformAnimationCurveAdapter(tween_type(), | 464 new TransformAnimationCurveAdapter(tween_type(), |
463 start_, | 465 start_, |
464 target_, | 466 target_, |
465 duration())); | 467 duration())); |
466 scoped_ptr<cc::Animation> animation( | 468 scoped_ptr<cc::Animation> animation( |
467 cc::Animation::Create(animation_curve.Pass(), animation_id(), | 469 cc::Animation::Create(std::move(animation_curve), animation_id(), |
468 animation_group_id(), cc::Animation::TRANSFORM)); | 470 animation_group_id(), cc::Animation::TRANSFORM)); |
469 return animation.Pass(); | 471 return animation; |
470 } | 472 } |
471 | 473 |
472 void OnGetTarget(TargetValue* target) const override { | 474 void OnGetTarget(TargetValue* target) const override { |
473 target->transform = target_; | 475 target->transform = target_; |
474 } | 476 } |
475 | 477 |
476 private: | 478 private: |
477 gfx::Transform start_; | 479 gfx::Transform start_; |
478 const gfx::Transform target_; | 480 const gfx::Transform target_; |
479 | 481 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 533 } |
532 | 534 |
533 void OnEnd(LayerAnimationDelegate* delegate) override { | 535 void OnEnd(LayerAnimationDelegate* delegate) override { |
534 delegate->SetTransformFromAnimation(computed_target_transform_); | 536 delegate->SetTransformFromAnimation(computed_target_transform_); |
535 } | 537 } |
536 | 538 |
537 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 539 scoped_ptr<cc::Animation> CreateCCAnimation() override { |
538 scoped_ptr<cc::Animation> animation( | 540 scoped_ptr<cc::Animation> animation( |
539 cc::Animation::Create(animation_curve_->Clone(), animation_id(), | 541 cc::Animation::Create(animation_curve_->Clone(), animation_id(), |
540 animation_group_id(), cc::Animation::TRANSFORM)); | 542 animation_group_id(), cc::Animation::TRANSFORM)); |
541 return animation.Pass(); | 543 return animation; |
542 } | 544 } |
543 | 545 |
544 void OnGetTarget(TargetValue* target) const override { | 546 void OnGetTarget(TargetValue* target) const override { |
545 target->transform = computed_target_transform_; | 547 target->transform = computed_target_transform_; |
546 } | 548 } |
547 | 549 |
548 private: | 550 private: |
549 gfx::Transform ComputeCurrentTransform() const { | 551 gfx::Transform ComputeCurrentTransform() const { |
550 gfx::Transform base_current = gfx::Tween::TransformValueBetween( | 552 gfx::Transform base_current = gfx::Tween::TransformValueBetween( |
551 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 553 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 } | 835 } |
834 | 836 |
835 // static | 837 // static |
836 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 838 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
837 SkColor color, | 839 SkColor color, |
838 base::TimeDelta duration) { | 840 base::TimeDelta duration) { |
839 return new ColorTransition(color, duration); | 841 return new ColorTransition(color, duration); |
840 } | 842 } |
841 | 843 |
842 } // namespace ui | 844 } // namespace ui |
OLD | NEW |