Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: ui/compositor/layer_animation_element.cc

Issue 2854653003: [Night Light] Backend ui::Layer work (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698