| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 void OnAbort(LayerAnimationDelegate* delegate) override {} | 248 void OnAbort(LayerAnimationDelegate* delegate) override {} |
| 249 | 249 |
| 250 private: | 250 private: |
| 251 SkColor start_; | 251 SkColor start_; |
| 252 const SkColor target_; | 252 const SkColor target_; |
| 253 | 253 |
| 254 DISALLOW_COPY_AND_ASSIGN(ColorTransition); | 254 DISALLOW_COPY_AND_ASSIGN(ColorTransition); |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 // TemperatureTransition ------------------------------------------------------- |
| 258 |
| 259 class TemperatureTransition : public LayerAnimationElement { |
| 260 public: |
| 261 TemperatureTransition(float target, base::TimeDelta duration) |
| 262 : LayerAnimationElement(TEMPERATURE, duration), |
| 263 start_(0.0f), |
| 264 target_(target) {} |
| 265 ~TemperatureTransition() override {} |
| 266 |
| 267 protected: |
| 268 void OnStart(LayerAnimationDelegate* delegate) override { |
| 269 start_ = delegate->GetTemperatureFromAnimation(); |
| 270 } |
| 271 |
| 272 bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
| 273 delegate->SetTemperatureFromAnimation( |
| 274 gfx::Tween::FloatValueBetween(t, start_, target_)); |
| 275 return true; |
| 276 } |
| 277 |
| 278 void OnGetTarget(TargetValue* target) const override { |
| 279 target->temperature = target_; |
| 280 } |
| 281 |
| 282 void OnAbort(LayerAnimationDelegate* delegate) override {} |
| 283 |
| 284 private: |
| 285 float start_; |
| 286 const float target_; |
| 287 |
| 288 DISALLOW_COPY_AND_ASSIGN(TemperatureTransition); |
| 289 }; |
| 290 |
| 257 // ThreadedLayerAnimationElement ----------------------------------------------- | 291 // ThreadedLayerAnimationElement ----------------------------------------------- |
| 258 | 292 |
| 259 class ThreadedLayerAnimationElement : public LayerAnimationElement { | 293 class ThreadedLayerAnimationElement : public LayerAnimationElement { |
| 260 public: | 294 public: |
| 261 ThreadedLayerAnimationElement(AnimatableProperties properties, | 295 ThreadedLayerAnimationElement(AnimatableProperties properties, |
| 262 base::TimeDelta duration) | 296 base::TimeDelta duration) |
| 263 : LayerAnimationElement(properties, duration) { | 297 : LayerAnimationElement(properties, duration) { |
| 264 } | 298 } |
| 265 ~ThreadedLayerAnimationElement() override {} | 299 ~ThreadedLayerAnimationElement() override {} |
| 266 | 300 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 469 |
| 436 LayerAnimationElement::TargetValue::TargetValue( | 470 LayerAnimationElement::TargetValue::TargetValue( |
| 437 const LayerAnimationDelegate* delegate) | 471 const LayerAnimationDelegate* delegate) |
| 438 : bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()), | 472 : bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()), |
| 439 transform(delegate ? delegate->GetTransformForAnimation() | 473 transform(delegate ? delegate->GetTransformForAnimation() |
| 440 : gfx::Transform()), | 474 : gfx::Transform()), |
| 441 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f), | 475 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f), |
| 442 visibility(delegate ? delegate->GetVisibilityForAnimation() : false), | 476 visibility(delegate ? delegate->GetVisibilityForAnimation() : false), |
| 443 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), | 477 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), |
| 444 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), | 478 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), |
| 445 color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT) { | 479 color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT), |
| 446 } | 480 temperature(delegate ? delegate->GetTemperatureFromAnimation() : 0.0f) {} |
| 447 | 481 |
| 448 // LayerAnimationElement ------------------------------------------------------- | 482 // LayerAnimationElement ------------------------------------------------------- |
| 449 | 483 |
| 450 LayerAnimationElement::LayerAnimationElement(AnimatableProperties properties, | 484 LayerAnimationElement::LayerAnimationElement(AnimatableProperties properties, |
| 451 base::TimeDelta duration) | 485 base::TimeDelta duration) |
| 452 : first_frame_(true), | 486 : first_frame_(true), |
| 453 properties_(properties), | 487 properties_(properties), |
| 454 duration_(GetEffectiveDuration(duration)), | 488 duration_(GetEffectiveDuration(duration)), |
| 455 tween_type_(gfx::Tween::LINEAR), | 489 tween_type_(gfx::Tween::LINEAR), |
| 456 animation_id_(cc::AnimationIdProvider::NextAnimationId()), | 490 animation_id_(cc::AnimationIdProvider::NextAnimationId()), |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 return base::MakeUnique<Pause>(properties, duration); | 713 return base::MakeUnique<Pause>(properties, duration); |
| 680 } | 714 } |
| 681 | 715 |
| 682 // static | 716 // static |
| 683 std::unique_ptr<LayerAnimationElement> | 717 std::unique_ptr<LayerAnimationElement> |
| 684 LayerAnimationElement::CreateColorElement(SkColor color, | 718 LayerAnimationElement::CreateColorElement(SkColor color, |
| 685 base::TimeDelta duration) { | 719 base::TimeDelta duration) { |
| 686 return base::MakeUnique<ColorTransition>(color, duration); | 720 return base::MakeUnique<ColorTransition>(color, duration); |
| 687 } | 721 } |
| 688 | 722 |
| 723 // static |
| 724 std::unique_ptr<LayerAnimationElement> |
| 725 LayerAnimationElement::CreateTemperatureElement(float temperature, |
| 726 base::TimeDelta duration) { |
| 727 return base::MakeUnique<TemperatureTransition>(temperature, duration); |
| 728 } |
| 729 |
| 689 } // namespace ui | 730 } // namespace ui |
| OLD | NEW |