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 "cc/base/cc_export.h"
10 #include "cc/output/filter_operations.h"
11 #include "ui/gfx/transform.h"
19 class ColorAnimationCurve
;
20 class FilterAnimationCurve
;
21 class FloatAnimationCurve
;
22 class ScrollOffsetAnimationCurve
;
23 class TransformAnimationCurve
;
24 class TransformOperations
;
26 // An animation curve is a function that returns a value given a time.
27 class CC_EXPORT AnimationCurve
{
29 enum CurveType
{ Color
, Float
, Transform
, Filter
, ScrollOffset
};
31 virtual ~AnimationCurve() {}
33 virtual double Duration() const = 0;
34 virtual CurveType
Type() const = 0;
35 virtual scoped_ptr
<AnimationCurve
> Clone() const = 0;
37 const ColorAnimationCurve
* ToColorAnimationCurve() const;
38 const FloatAnimationCurve
* ToFloatAnimationCurve() const;
39 const TransformAnimationCurve
* ToTransformAnimationCurve() const;
40 const FilterAnimationCurve
* ToFilterAnimationCurve() const;
41 const ScrollOffsetAnimationCurve
* ToScrollOffsetAnimationCurve() const;
43 ScrollOffsetAnimationCurve
* ToScrollOffsetAnimationCurve();
46 class CC_EXPORT ColorAnimationCurve
: public AnimationCurve
{
48 virtual ~ColorAnimationCurve() {}
50 virtual SkColor
GetValue(double t
) const = 0;
52 // Partial Animation implementation.
53 virtual CurveType
Type() const OVERRIDE
;
56 class CC_EXPORT FloatAnimationCurve
: public AnimationCurve
{
58 virtual ~FloatAnimationCurve() {}
60 virtual float GetValue(double t
) const = 0;
62 // Partial Animation implementation.
63 virtual CurveType
Type() const OVERRIDE
;
66 class CC_EXPORT TransformAnimationCurve
: public AnimationCurve
{
68 virtual ~TransformAnimationCurve() {}
70 virtual gfx::Transform
GetValue(double t
) const = 0;
72 // Sets |bounds| to be the bounding box for the region within which |box|
73 // will move during this animation. If this region cannot be computed,
75 virtual bool AnimatedBoundsForBox(const gfx::BoxF
& box
,
76 gfx::BoxF
* bounds
) const = 0;
78 // Partial Animation implementation.
79 virtual CurveType
Type() const OVERRIDE
;
82 class CC_EXPORT FilterAnimationCurve
: public AnimationCurve
{
84 virtual ~FilterAnimationCurve() {}
86 virtual FilterOperations
GetValue(double t
) const = 0;
88 // Partial Animation implementation.
89 virtual CurveType
Type() const OVERRIDE
;
94 #endif // CC_ANIMATION_ANIMATION_CURVE_H_