| 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 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ |
| 6 #define UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ | 6 #define UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class InterpolatedTransform; | 22 class InterpolatedTransform; |
| 23 class LayerAnimationDelegate; | 23 class LayerAnimationDelegate; |
| 24 | 24 |
| 25 // LayerAnimationElements represent one segment of an animation between two | 25 // LayerAnimationElements represent one segment of an animation between two |
| 26 // keyframes. They know how to update a LayerAnimationDelegate given a value | 26 // keyframes. They know how to update a LayerAnimationDelegate given a value |
| 27 // between 0 and 1 (0 for initial, and 1 for final). | 27 // between 0 and 1 (0 for initial, and 1 for final). |
| 28 class COMPOSITOR_EXPORT LayerAnimationElement { | 28 class COMPOSITOR_EXPORT LayerAnimationElement { |
| 29 public: | 29 public: |
| 30 enum AnimatableProperty { | 30 enum AnimatableProperty { |
| 31 TRANSFORM = 0, | 31 UNKNOWN = 0, |
| 32 BOUNDS, | 32 TRANSFORM = (1 << 0), |
| 33 OPACITY, | 33 BOUNDS = (1 << 1), |
| 34 VISIBILITY, | 34 OPACITY = (1 << 2), |
| 35 BRIGHTNESS, | 35 VISIBILITY = (1 << 3), |
| 36 GRAYSCALE, | 36 BRIGHTNESS = (1 << 4), |
| 37 COLOR, | 37 GRAYSCALE = (1 << 5), |
| 38 COLOR = (1 << 6), |
| 39 |
| 40 // Used when iterating over properties. |
| 41 FIRST_PROPERTY = TRANSFORM, |
| 42 SENTINEL = (1 << 7) |
| 38 }; | 43 }; |
| 39 | 44 |
| 40 static AnimatableProperty ToAnimatableProperty( | 45 static AnimatableProperty ToAnimatableProperty( |
| 41 cc::Animation::TargetProperty property); | 46 cc::Animation::TargetProperty property); |
| 42 | 47 |
| 43 struct COMPOSITOR_EXPORT TargetValue { | 48 struct COMPOSITOR_EXPORT TargetValue { |
| 44 TargetValue(); | 49 TargetValue(); |
| 45 // Initializes the target value to match the delegate. NULL may be supplied. | 50 // Initializes the target value to match the delegate. NULL may be supplied. |
| 46 explicit TargetValue(const LayerAnimationDelegate* delegate); | 51 explicit TargetValue(const LayerAnimationDelegate* delegate); |
| 47 | 52 |
| 48 gfx::Rect bounds; | 53 gfx::Rect bounds; |
| 49 gfx::Transform transform; | 54 gfx::Transform transform; |
| 50 float opacity; | 55 float opacity; |
| 51 bool visibility; | 56 bool visibility; |
| 52 float brightness; | 57 float brightness; |
| 53 float grayscale; | 58 float grayscale; |
| 54 SkColor color; | 59 SkColor color; |
| 55 }; | 60 }; |
| 56 | 61 |
| 57 typedef std::set<AnimatableProperty> AnimatableProperties; | 62 typedef uint32 AnimatableProperties; |
| 58 | 63 |
| 59 LayerAnimationElement(const AnimatableProperties& properties, | 64 LayerAnimationElement(AnimatableProperties properties, |
| 60 base::TimeDelta duration); | 65 base::TimeDelta duration); |
| 61 | 66 |
| 62 virtual ~LayerAnimationElement(); | 67 virtual ~LayerAnimationElement(); |
| 63 | 68 |
| 64 // Creates an element that transitions to the given transform. The caller owns | 69 // Creates an element that transitions to the given transform. The caller owns |
| 65 // the return value. | 70 // the return value. |
| 66 static LayerAnimationElement* CreateTransformElement( | 71 static LayerAnimationElement* CreateTransformElement( |
| 67 const gfx::Transform& transform, | 72 const gfx::Transform& transform, |
| 68 base::TimeDelta duration); | 73 base::TimeDelta duration); |
| 69 | 74 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 122 |
| 118 // Creates an element that transitions to the given grayscale value. | 123 // Creates an element that transitions to the given grayscale value. |
| 119 // The caller owns the return value. | 124 // The caller owns the return value. |
| 120 static LayerAnimationElement* CreateGrayscaleElement( | 125 static LayerAnimationElement* CreateGrayscaleElement( |
| 121 float grayscale, | 126 float grayscale, |
| 122 base::TimeDelta duration); | 127 base::TimeDelta duration); |
| 123 | 128 |
| 124 // Creates an element that pauses the given properties. The caller owns the | 129 // Creates an element that pauses the given properties. The caller owns the |
| 125 // return value. | 130 // return value. |
| 126 static LayerAnimationElement* CreatePauseElement( | 131 static LayerAnimationElement* CreatePauseElement( |
| 127 const AnimatableProperties& properties, | 132 AnimatableProperties properties, |
| 128 base::TimeDelta duration); | 133 base::TimeDelta duration); |
| 129 | 134 |
| 130 // Creates an element that transitions to the given color. The caller owns the | 135 // Creates an element that transitions to the given color. The caller owns the |
| 131 // return value. | 136 // return value. |
| 132 static LayerAnimationElement* CreateColorElement( | 137 static LayerAnimationElement* CreateColorElement( |
| 133 SkColor color, | 138 SkColor color, |
| 134 base::TimeDelta duration); | 139 base::TimeDelta duration); |
| 135 | 140 |
| 136 // Sets the start time for the animation. This must be called before the first | 141 // Sets the start time for the animation. This must be called before the first |
| 137 // call to {Start, IsFinished}. Once the animation is finished, this must | 142 // call to {Start, IsFinished}. Once the animation is finished, this must |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool ProgressToEnd(LayerAnimationDelegate* delegate); | 176 bool ProgressToEnd(LayerAnimationDelegate* delegate); |
| 172 | 177 |
| 173 // Called if the animation is not allowed to complete. This may be called | 178 // Called if the animation is not allowed to complete. This may be called |
| 174 // before OnStarted or Progress. | 179 // before OnStarted or Progress. |
| 175 void Abort(LayerAnimationDelegate* delegate); | 180 void Abort(LayerAnimationDelegate* delegate); |
| 176 | 181 |
| 177 // Assigns the target value to |target|. | 182 // Assigns the target value to |target|. |
| 178 void GetTargetValue(TargetValue* target) const; | 183 void GetTargetValue(TargetValue* target) const; |
| 179 | 184 |
| 180 // The properties that the element modifies. | 185 // The properties that the element modifies. |
| 181 const AnimatableProperties& properties() const { return properties_; } | 186 AnimatableProperties properties() const { return properties_; } |
| 182 | 187 |
| 183 // Whether this element animates on the compositor thread. | 188 // Whether this element animates on the compositor thread. |
| 184 virtual bool IsThreaded() const; | 189 virtual bool IsThreaded() const; |
| 185 | 190 |
| 186 gfx::Tween::Type tween_type() const { return tween_type_; } | 191 gfx::Tween::Type tween_type() const { return tween_type_; } |
| 187 void set_tween_type(gfx::Tween::Type tween_type) { tween_type_ = tween_type; } | 192 void set_tween_type(gfx::Tween::Type tween_type) { tween_type_ = tween_type; } |
| 188 | 193 |
| 189 // Each LayerAnimationElement has a unique animation_id. Elements belonging | 194 // Each LayerAnimationElement has a unique animation_id. Elements belonging |
| 190 // to sequences that are supposed to start together have the same | 195 // to sequences that are supposed to start together have the same |
| 191 // animation_group_id. | 196 // animation_group_id. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 double last_progressed_fraction_; | 238 double last_progressed_fraction_; |
| 234 | 239 |
| 235 base::WeakPtrFactory<LayerAnimationElement> weak_ptr_factory_; | 240 base::WeakPtrFactory<LayerAnimationElement> weak_ptr_factory_; |
| 236 | 241 |
| 237 DISALLOW_ASSIGN(LayerAnimationElement); | 242 DISALLOW_ASSIGN(LayerAnimationElement); |
| 238 }; | 243 }; |
| 239 | 244 |
| 240 } // namespace ui | 245 } // namespace ui |
| 241 | 246 |
| 242 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ | 247 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ |
| OLD | NEW |