Home | History | Annotate | Download | only in animation
      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 "cc/base/cc_export.h"
     10 #include "cc/output/filter_operations.h"
     11 #include "ui/gfx/transform.h"
     12 
     13 namespace cc {
     14 
     15 class FilterAnimationCurve;
     16 class FloatAnimationCurve;
     17 class TransformAnimationCurve;
     18 class TransformOperations;
     19 
     20 // An animation curve is a function that returns a value given a time.
     21 class CC_EXPORT AnimationCurve {
     22  public:
     23   enum CurveType { Float, Transform, Filter };
     24 
     25   virtual ~AnimationCurve() {}
     26 
     27   virtual double Duration() const = 0;
     28   virtual CurveType Type() const = 0;
     29   virtual scoped_ptr<AnimationCurve> Clone() const = 0;
     30 
     31   const FloatAnimationCurve* ToFloatAnimationCurve() const;
     32   const TransformAnimationCurve* ToTransformAnimationCurve() const;
     33   const FilterAnimationCurve* ToFilterAnimationCurve() const;
     34 };
     35 
     36 class CC_EXPORT FloatAnimationCurve : public AnimationCurve {
     37  public:
     38   virtual ~FloatAnimationCurve() {}
     39 
     40   virtual float GetValue(double t) const = 0;
     41 
     42   // Partial Animation implementation.
     43   virtual CurveType Type() const OVERRIDE;
     44 };
     45 
     46 class CC_EXPORT TransformAnimationCurve : public AnimationCurve {
     47  public:
     48   virtual ~TransformAnimationCurve() {}
     49 
     50   virtual gfx::Transform GetValue(double t) const = 0;
     51 
     52   // Partial Animation implementation.
     53   virtual CurveType Type() const OVERRIDE;
     54 };
     55 
     56 class CC_EXPORT FilterAnimationCurve : public AnimationCurve {
     57  public:
     58   virtual ~FilterAnimationCurve() {}
     59 
     60   virtual FilterOperations GetValue(double t) const = 0;
     61 
     62   // Partial Animation implementation.
     63   virtual CurveType Type() const OVERRIDE;
     64 };
     65 
     66 }  // namespace cc
     67 
     68 #endif  // CC_ANIMATION_ANIMATION_CURVE_H_
     69