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

Unified Diff: ui/compositor/layer_animation_element.cc

Issue 10800020: Add brightness/grayscale animations and use them for OOBE boot transition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix hide animation Created 8 years, 5 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_animation_element_unittest.cc » ('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 dde0b48b476f13c422c95bc752ec9582fdd04a54..98326d2fb25f83a37a850933d20ea9c8f40a32ce 100644
--- a/ui/compositor/layer_animation_element.cc
+++ b/ui/compositor/layer_animation_element.cc
@@ -232,13 +232,97 @@ class VisibilityTransition : public LayerAnimationElement {
DISALLOW_COPY_AND_ASSIGN(VisibilityTransition);
};
+// BrightnessTransition --------------------------------------------------------
+
+class BrightnessTransition : public LayerAnimationElement {
+ public:
+ BrightnessTransition(float target, base::TimeDelta duration)
+ : LayerAnimationElement(GetProperties(), duration),
+ start_(0.0f),
+ target_(target) {
+ }
+ virtual ~BrightnessTransition() {}
+
+ protected:
+ virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
+ start_ = delegate->GetBrightnessForAnimation();
+ }
+
+ virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
+ delegate->SetBrightnessFromAnimation(
+ Tween::ValueBetween(t, start_, target_));
+ return true;
+ }
+
+ virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
+ target->brightness = target_;
+ }
+
+ virtual void OnAbort() OVERRIDE {}
+
+ private:
+ static AnimatableProperties GetProperties() {
+ AnimatableProperties properties;
+ properties.insert(LayerAnimationElement::BRIGHTNESS);
+ return properties;
+ }
+
+ float start_;
+ const float target_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrightnessTransition);
+};
+
+// GrayscaleTransition ---------------------------------------------------------
+
+class GrayscaleTransition : public LayerAnimationElement {
+ public:
+ GrayscaleTransition(float target, base::TimeDelta duration)
+ : LayerAnimationElement(GetProperties(), duration),
+ start_(0.0f),
+ target_(target) {
+ }
+ virtual ~GrayscaleTransition() {}
+
+ protected:
+ virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
+ start_ = delegate->GetGrayscaleForAnimation();
+ }
+
+ virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
+ delegate->SetGrayscaleFromAnimation(
+ Tween::ValueBetween(t, start_, target_));
+ return true;
+ }
+
+ virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
+ target->grayscale = target_;
+ }
+
+ virtual void OnAbort() OVERRIDE {}
+
+ private:
+ static AnimatableProperties GetProperties() {
+ AnimatableProperties properties;
+ properties.insert(LayerAnimationElement::GRAYSCALE);
+ return properties;
+ }
+
+ float start_;
+ const float target_;
+
+ DISALLOW_COPY_AND_ASSIGN(GrayscaleTransition);
+};
+
} // namespace
// LayerAnimationElement::TargetValue ------------------------------------------
LayerAnimationElement::TargetValue::TargetValue()
: opacity(0.0f),
- visibility(false) {
+ visibility(false),
+ brightness(0.0f),
+ grayscale(0.0f) {
}
LayerAnimationElement::TargetValue::TargetValue(
@@ -246,7 +330,9 @@ LayerAnimationElement::TargetValue::TargetValue(
: bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()),
transform(delegate ? delegate->GetTransformForAnimation() : Transform()),
opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f),
- visibility(delegate ? delegate->GetVisibilityForAnimation() : false) {
+ visibility(delegate ? delegate->GetVisibilityForAnimation() : false),
+ brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f),
+ grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f) {
}
// LayerAnimationElement -------------------------------------------------------
@@ -325,6 +411,18 @@ LayerAnimationElement* LayerAnimationElement::CreateVisibilityElement(
}
// static
+LayerAnimationElement* LayerAnimationElement::CreateBrightnessElement(
+ float brightness, base::TimeDelta duration) {
+ return new BrightnessTransition(brightness, duration);
+}
+
+// static
+LayerAnimationElement* LayerAnimationElement::CreateGrayscaleElement(
+ float grayscale, base::TimeDelta duration) {
+ return new GrayscaleTransition(grayscale, duration);
+}
+
+// static
LayerAnimationElement* LayerAnimationElement::CreatePauseElement(
const AnimatableProperties& properties, base::TimeDelta duration) {
return new Pause(properties, duration);
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animation_element_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698