Add ICU message format support
[chromium-blink-merge.git] / cc / animation / animation_curve.h
blob68bad3ba3b55d5b21699c38d7d9cc14eb70f53c4
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.
5 #ifndef CC_ANIMATION_ANIMATION_CURVE_H_
6 #define CC_ANIMATION_ANIMATION_CURVE_H_
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"
14 namespace gfx {
15 class BoxF;
18 namespace cc {
20 class ColorAnimationCurve;
21 class FilterAnimationCurve;
22 class FloatAnimationCurve;
23 class ScrollOffsetAnimationCurve;
24 class TransformAnimationCurve;
25 class TransformOperations;
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 };
32 virtual ~AnimationCurve() {}
34 virtual base::TimeDelta Duration() const = 0;
35 virtual CurveType Type() const = 0;
36 virtual scoped_ptr<AnimationCurve> Clone() const = 0;
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;
44 ScrollOffsetAnimationCurve* ToScrollOffsetAnimationCurve();
47 class CC_EXPORT ColorAnimationCurve : public AnimationCurve {
48 public:
49 ~ColorAnimationCurve() override {}
51 virtual SkColor GetValue(base::TimeDelta t) const = 0;
53 // Partial Animation implementation.
54 CurveType Type() const override;
57 class CC_EXPORT FloatAnimationCurve : public AnimationCurve {
58 public:
59 ~FloatAnimationCurve() override {}
61 virtual float GetValue(base::TimeDelta t) const = 0;
63 // Partial Animation implementation.
64 CurveType Type() const override;
67 class CC_EXPORT TransformAnimationCurve : public AnimationCurve {
68 public:
69 ~TransformAnimationCurve() override {}
71 virtual gfx::Transform GetValue(base::TimeDelta t) const = 0;
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;
79 // Returns true if this animation affects scale.
80 virtual bool AffectsScale() const = 0;
82 // Returns true if this animation is a translation.
83 virtual bool IsTranslation() const = 0;
85 // Returns true if this animation preserves axis alignment.
86 virtual bool PreservesAxisAlignment() const = 0;
88 // Animation start scale
89 virtual bool AnimationStartScale(bool forward_direction,
90 float* start_scale) const = 0;
92 // Set |max_scale| to the maximum scale along any dimension at the end of
93 // intermediate animation target points (eg keyframe end points). When
94 // |forward_direction| is true, the animation curve assumes it plays from
95 // the first keyframe to the last, otherwise it assumes the opposite. Returns
96 // false if the maximum scale cannot be computed.
97 virtual bool MaximumTargetScale(bool forward_direction,
98 float* max_scale) const = 0;
100 // Partial Animation implementation.
101 CurveType Type() const override;
104 class CC_EXPORT FilterAnimationCurve : public AnimationCurve {
105 public:
106 ~FilterAnimationCurve() override {}
108 virtual FilterOperations GetValue(base::TimeDelta t) const = 0;
109 virtual bool HasFilterThatMovesPixels() const = 0;
111 // Partial Animation implementation.
112 CurveType Type() const override;
115 } // namespace cc
117 #endif // CC_ANIMATION_ANIMATION_CURVE_H_