| 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/time.h" | 10 #include "base/time.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/base/animation/tween.h" | 12 #include "ui/base/animation/tween.h" |
| 13 #include "ui/compositor/compositor_export.h" | 13 #include "ui/compositor/compositor_export.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 class InterpolatedTransform; | 19 class InterpolatedTransform; |
| 20 class LayerAnimationDelegate; | 20 class LayerAnimationDelegate; |
| 21 class Transform; | |
| 22 | 21 |
| 23 // LayerAnimationElements represent one segment of an animation between two | 22 // LayerAnimationElements represent one segment of an animation between two |
| 24 // keyframes. They know how to update a LayerAnimationDelegate given a value | 23 // keyframes. They know how to update a LayerAnimationDelegate given a value |
| 25 // between 0 and 1 (0 for initial, and 1 for final). | 24 // between 0 and 1 (0 for initial, and 1 for final). |
| 26 class COMPOSITOR_EXPORT LayerAnimationElement { | 25 class COMPOSITOR_EXPORT LayerAnimationElement { |
| 27 public: | 26 public: |
| 28 enum AnimatableProperty { | 27 enum AnimatableProperty { |
| 29 TRANSFORM = 0, | 28 TRANSFORM = 0, |
| 30 BOUNDS, | 29 BOUNDS, |
| 31 OPACITY, | 30 OPACITY, |
| 32 VISIBILITY, | 31 VISIBILITY, |
| 33 BRIGHTNESS, | 32 BRIGHTNESS, |
| 34 GRAYSCALE, | 33 GRAYSCALE, |
| 35 COLOR, | 34 COLOR, |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 struct COMPOSITOR_EXPORT TargetValue { | 37 struct COMPOSITOR_EXPORT TargetValue { |
| 39 TargetValue(); | 38 TargetValue(); |
| 40 // Initializes the target value to match the delegate. NULL may be supplied. | 39 // Initializes the target value to match the delegate. NULL may be supplied. |
| 41 explicit TargetValue(const LayerAnimationDelegate* delegate); | 40 explicit TargetValue(const LayerAnimationDelegate* delegate); |
| 42 | 41 |
| 43 gfx::Rect bounds; | 42 gfx::Rect bounds; |
| 44 Transform transform; | 43 gfx::Transform transform; |
| 45 float opacity; | 44 float opacity; |
| 46 bool visibility; | 45 bool visibility; |
| 47 float brightness; | 46 float brightness; |
| 48 float grayscale; | 47 float grayscale; |
| 49 SkColor color; | 48 SkColor color; |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 typedef std::set<AnimatableProperty> AnimatableProperties; | 51 typedef std::set<AnimatableProperty> AnimatableProperties; |
| 53 | 52 |
| 54 LayerAnimationElement(const AnimatableProperties& properties, | 53 LayerAnimationElement(const AnimatableProperties& properties, |
| 55 base::TimeDelta duration); | 54 base::TimeDelta duration); |
| 56 virtual ~LayerAnimationElement(); | 55 virtual ~LayerAnimationElement(); |
| 57 | 56 |
| 58 // Creates an element that transitions to the given transform. The caller owns | 57 // Creates an element that transitions to the given transform. The caller owns |
| 59 // the return value. | 58 // the return value. |
| 60 static LayerAnimationElement* CreateTransformElement( | 59 static LayerAnimationElement* CreateTransformElement( |
| 61 const Transform& transform, | 60 const gfx::Transform& transform, |
| 62 base::TimeDelta duration); | 61 base::TimeDelta duration); |
| 63 | 62 |
| 64 // Creates an element that transitions to another in a way determined by an | 63 // Creates an element that transitions to another in a way determined by an |
| 65 // interpolated transform. The element accepts ownership of the interpolated | 64 // interpolated transform. The element accepts ownership of the interpolated |
| 66 // transform. NB: at every step, the interpolated transform clobbers the | 65 // transform. NB: at every step, the interpolated transform clobbers the |
| 67 // existing transform. That is, it does not interpolate between the existing | 66 // existing transform. That is, it does not interpolate between the existing |
| 68 // transform and the last value the interpolated transform will assume. It is | 67 // transform and the last value the interpolated transform will assume. It is |
| 69 // therefore important that the value of the interpolated at time 0 matches | 68 // therefore important that the value of the interpolated at time 0 matches |
| 70 // the current transform. | 69 // the current transform. |
| 71 static LayerAnimationElement* CreateInterpolatedTransformElement( | 70 static LayerAnimationElement* CreateInterpolatedTransformElement( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 const AnimatableProperties properties_; | 153 const AnimatableProperties properties_; |
| 155 const base::TimeDelta duration_; | 154 const base::TimeDelta duration_; |
| 156 Tween::Type tween_type_; | 155 Tween::Type tween_type_; |
| 157 | 156 |
| 158 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement); | 157 DISALLOW_COPY_AND_ASSIGN(LayerAnimationElement); |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 } // namespace ui | 160 } // namespace ui |
| 162 | 161 |
| 163 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ | 162 #endif // UI_COMPOSITOR_LAYER_ANIMATION_ELEMENT_H_ |
| OLD | NEW |