Index: ui/compositor/layer_animation_element.cc |
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc |
index 7ba0993f0acebe69092fbebb2364237092fcf479..9f6797fa9cd010cbc8f5494e5f8ac1bdae9dc1f1 100644 |
--- a/ui/compositor/layer_animation_element.cc |
+++ b/ui/compositor/layer_animation_element.cc |
@@ -254,6 +254,40 @@ class ColorTransition : public LayerAnimationElement { |
DISALLOW_COPY_AND_ASSIGN(ColorTransition); |
}; |
+// TemperatureTransition ------------------------------------------------------- |
+ |
+class TemperatureTransition : public LayerAnimationElement { |
+ public: |
+ TemperatureTransition(float target, base::TimeDelta duration) |
+ : LayerAnimationElement(TEMPERATURE, duration), |
+ start_(0.0f), |
+ target_(target) {} |
+ ~TemperatureTransition() override {} |
+ |
+ protected: |
+ void OnStart(LayerAnimationDelegate* delegate) override { |
+ start_ = delegate->GetTemperatureFromAnimation(); |
+ } |
+ |
+ bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
+ delegate->SetTemperatureFromAnimation( |
+ gfx::Tween::FloatValueBetween(t, start_, target_)); |
+ return true; |
+ } |
+ |
+ void OnGetTarget(TargetValue* target) const override { |
+ target->temperature = target_; |
+ } |
+ |
+ void OnAbort(LayerAnimationDelegate* delegate) override {} |
+ |
+ private: |
+ float start_; |
+ const float target_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TemperatureTransition); |
+}; |
+ |
// ThreadedLayerAnimationElement ----------------------------------------------- |
class ThreadedLayerAnimationElement : public LayerAnimationElement { |
@@ -442,8 +476,8 @@ LayerAnimationElement::TargetValue::TargetValue( |
visibility(delegate ? delegate->GetVisibilityForAnimation() : false), |
brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), |
grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), |
- color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT) { |
-} |
+ color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT), |
+ temperature(delegate ? delegate->GetTemperatureFromAnimation() : 0.0f) {} |
// LayerAnimationElement ------------------------------------------------------- |
@@ -686,4 +720,11 @@ LayerAnimationElement::CreateColorElement(SkColor color, |
return base::MakeUnique<ColorTransition>(color, duration); |
} |
+// static |
+std::unique_ptr<LayerAnimationElement> |
+LayerAnimationElement::CreateTemperatureElement(float temperature, |
+ base::TimeDelta duration) { |
+ return base::MakeUnique<TemperatureTransition>(temperature, duration); |
+} |
+ |
} // namespace ui |