diff options
author | avallee@chromium.org <avallee@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 22:51:36 +0000 |
---|---|---|
committer | avallee@chromium.org <avallee@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-24 22:51:36 +0000 |
commit | 12076fa6270fda6ea535da61cafe7116ec2e6f00 (patch) | |
tree | 4cda7c226d5fbba708df61cdb3c7c517a71f8ee9 /cc/animation/keyframed_animation_curve.h | |
parent | 565f6193e85668f26de953516dbd8a341ae2b457 (diff) | |
download | chromium_src-12076fa6270fda6ea535da61cafe7116ec2e6f00.zip chromium_src-12076fa6270fda6ea535da61cafe7116ec2e6f00.tar.gz chromium_src-12076fa6270fda6ea535da61cafe7116ec2e6f00.tar.bz2 |
Add Color animation curves.
Implement animation curves for colors.
This is the first step towards accelerating background-color animations.
+ Add ColorValueBetween to gfx::Tween.
+ Add test/color_utils which gives EXPECT_COLOR_EQ to check SkColors and
print in a sane format.
~ Fixed discrepancy between two methods of interpolating ints.
~ Factored out GetProgress into template function to simplify code in
the implementations of GetValue(double), there was a lot of duplication
there.
TESTED:
Added tests for the new KeyframedColorAnimations and AnimatedColor classes. Added tests to tweening.
R=ajuma
BUG=290234
Review URL: https://codereview.chromium.org/25901002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation/keyframed_animation_curve.h')
-rw-r--r-- | cc/animation/keyframed_animation_curve.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cc/animation/keyframed_animation_curve.h b/cc/animation/keyframed_animation_curve.h index 5892dc7..4b5ac3b 100644 --- a/cc/animation/keyframed_animation_curve.h +++ b/cc/animation/keyframed_animation_curve.h @@ -31,6 +31,26 @@ class CC_EXPORT Keyframe { DISALLOW_COPY_AND_ASSIGN(Keyframe); }; +class CC_EXPORT ColorKeyframe : public Keyframe { + public: + static scoped_ptr<ColorKeyframe> Create( + double time, + SkColor value, + scoped_ptr<TimingFunction> timing_function); + virtual ~ColorKeyframe(); + + SkColor Value() const; + + scoped_ptr<ColorKeyframe> Clone() const; + + private: + ColorKeyframe(double time, + SkColor value, + scoped_ptr<TimingFunction> timing_function); + + SkColor value_; +}; + class CC_EXPORT FloatKeyframe : public Keyframe { public: static scoped_ptr<FloatKeyframe> Create( @@ -93,6 +113,32 @@ class CC_EXPORT FilterKeyframe : public Keyframe { FilterOperations value_; }; +class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve { + public: + // It is required that the keyframes be sorted by time. + static scoped_ptr<KeyframedColorAnimationCurve> Create(); + + virtual ~KeyframedColorAnimationCurve(); + + void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe); + + // AnimationCurve implementation + virtual double Duration() const OVERRIDE; + virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE; + + // BackgrounColorAnimationCurve implementation + virtual SkColor GetValue(double t) const OVERRIDE; + + private: + KeyframedColorAnimationCurve(); + + // Always sorted in order of increasing time. No two keyframes have the + // same time. + ScopedPtrVector<ColorKeyframe> keyframes_; + + DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); +}; + class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve { public: // It is required that the keyframes be sorted by time. |