| OLD | NEW |
| (Empty) |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_ANIMATION_ANIMATION_CURVE_H_ | |
| 6 #define CC_ANIMATION_ANIMATION_CURVE_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/time/time.h" | |
| 10 #include "cc/base/cc_export.h" | |
| 11 #include "cc/output/filter_operations.h" | |
| 12 #include "ui/gfx/transform.h" | |
| 13 | |
| 14 namespace gfx { | |
| 15 class BoxF; | |
| 16 } | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 class ColorAnimationCurve; | |
| 21 class FilterAnimationCurve; | |
| 22 class FloatAnimationCurve; | |
| 23 class ScrollOffsetAnimationCurve; | |
| 24 class TransformAnimationCurve; | |
| 25 class TransformOperations; | |
| 26 | |
| 27 // An animation curve is a function that returns a value given a time. | |
| 28 class CC_EXPORT AnimationCurve { | |
| 29 public: | |
| 30 enum CurveType { COLOR, FLOAT, TRANSFORM, FILTER, SCROLL_OFFSET }; | |
| 31 | |
| 32 virtual ~AnimationCurve() {} | |
| 33 | |
| 34 virtual base::TimeDelta Duration() const = 0; | |
| 35 virtual CurveType Type() const = 0; | |
| 36 virtual scoped_ptr<AnimationCurve> Clone() const = 0; | |
| 37 | |
| 38 const ColorAnimationCurve* ToColorAnimationCurve() const; | |
| 39 const FloatAnimationCurve* ToFloatAnimationCurve() const; | |
| 40 const TransformAnimationCurve* ToTransformAnimationCurve() const; | |
| 41 const FilterAnimationCurve* ToFilterAnimationCurve() const; | |
| 42 const ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve() const; | |
| 43 | |
| 44 ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve(); | |
| 45 }; | |
| 46 | |
| 47 class CC_EXPORT ColorAnimationCurve : public AnimationCurve { | |
| 48 public: | |
| 49 ~ColorAnimationCurve() override {} | |
| 50 | |
| 51 virtual SkColor GetValue(base::TimeDelta t) const = 0; | |
| 52 | |
| 53 // Partial Animation implementation. | |
| 54 CurveType Type() const override; | |
| 55 }; | |
| 56 | |
| 57 class CC_EXPORT FloatAnimationCurve : public AnimationCurve { | |
| 58 public: | |
| 59 ~FloatAnimationCurve() override {} | |
| 60 | |
| 61 virtual float GetValue(base::TimeDelta t) const = 0; | |
| 62 | |
| 63 // Partial Animation implementation. | |
| 64 CurveType Type() const override; | |
| 65 }; | |
| 66 | |
| 67 class CC_EXPORT TransformAnimationCurve : public AnimationCurve { | |
| 68 public: | |
| 69 ~TransformAnimationCurve() override {} | |
| 70 | |
| 71 virtual gfx::Transform GetValue(base::TimeDelta t) const = 0; | |
| 72 | |
| 73 // Sets |bounds| to be the bounding box for the region within which |box| | |
| 74 // will move during this animation. If this region cannot be computed, | |
| 75 // returns false. | |
| 76 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, | |
| 77 gfx::BoxF* bounds) const = 0; | |
| 78 | |
| 79 // Returns true if this animation affects scale. | |
| 80 virtual bool AffectsScale() const = 0; | |
| 81 | |
| 82 // Returns true if this animation is a translation. | |
| 83 virtual bool IsTranslation() const = 0; | |
| 84 | |
| 85 // Returns true if this animation preserves axis alignment. | |
| 86 virtual bool PreservesAxisAlignment() const = 0; | |
| 87 | |
| 88 // Set |max_scale| to the maximum scale along any dimension at the end of | |
| 89 // intermediate animation target points (eg keyframe end points). When | |
| 90 // |forward_direction| is true, the animation curve assumes it plays from | |
| 91 // the first keyframe to the last, otherwise it assumes the opposite. Returns | |
| 92 // false if the maximum scale cannot be computed. | |
| 93 virtual bool MaximumTargetScale(bool forward_direction, | |
| 94 float* max_scale) const = 0; | |
| 95 | |
| 96 // Partial Animation implementation. | |
| 97 CurveType Type() const override; | |
| 98 }; | |
| 99 | |
| 100 class CC_EXPORT FilterAnimationCurve : public AnimationCurve { | |
| 101 public: | |
| 102 ~FilterAnimationCurve() override {} | |
| 103 | |
| 104 virtual FilterOperations GetValue(base::TimeDelta t) const = 0; | |
| 105 virtual bool HasFilterThatMovesPixels() const = 0; | |
| 106 | |
| 107 // Partial Animation implementation. | |
| 108 CurveType Type() const override; | |
| 109 }; | |
| 110 | |
| 111 } // namespace cc | |
| 112 | |
| 113 #endif // CC_ANIMATION_ANIMATION_CURVE_H_ | |
| OLD | NEW |