Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: cc/animation/timing_function.h

Issue 2775143002: Implement frames() timing function (Closed)
Patch Set: Fix behaviour outside input range [0,1] Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/keyframed_animation_curve_unittest.cc ('k') | cc/animation/timing_function.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_ 5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_
6 #define CC_ANIMATION_TIMING_FUNCTION_H_ 6 #define CC_ANIMATION_TIMING_FUNCTION_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "cc/animation/animation_export.h" 11 #include "cc/animation/animation_export.h"
12 #include "ui/gfx/geometry/cubic_bezier.h" 12 #include "ui/gfx/geometry/cubic_bezier.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 // See http://www.w3.org/TR/css3-transitions/. 16 // See http://www.w3.org/TR/css3-transitions/.
17 class CC_ANIMATION_EXPORT TimingFunction { 17 class CC_ANIMATION_EXPORT TimingFunction {
18 public: 18 public:
19 virtual ~TimingFunction(); 19 virtual ~TimingFunction();
20 20
21 // Note that LINEAR is a nullptr TimingFunction (for now). 21 // Note that LINEAR is a nullptr TimingFunction (for now).
22 enum class Type { LINEAR, CUBIC_BEZIER, STEPS }; 22 enum class Type { LINEAR, CUBIC_BEZIER, STEPS, FRAMES };
23 23
24 virtual Type GetType() const = 0; 24 virtual Type GetType() const = 0;
25 virtual float GetValue(double t) const = 0; 25 virtual float GetValue(double t) const = 0;
26 virtual float Velocity(double time) const = 0; 26 virtual float Velocity(double time) const = 0;
27 // The smallest and largest values returned by GetValue for inputs in [0, 1]. 27 // The smallest and largest values returned by GetValue for inputs in [0, 1].
28 virtual void Range(float* min, float* max) const = 0; 28 virtual void Range(float* min, float* max) const = 0;
29 virtual std::unique_ptr<TimingFunction> Clone() const = 0; 29 virtual std::unique_ptr<TimingFunction> Clone() const = 0;
30 30
31 protected: 31 protected:
32 TimingFunction(); 32 TimingFunction();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 StepsTimingFunction(int steps, StepPosition step_position); 94 StepsTimingFunction(int steps, StepPosition step_position);
95 95
96 float GetStepsStartOffset() const; 96 float GetStepsStartOffset() const;
97 97
98 int steps_; 98 int steps_;
99 StepPosition step_position_; 99 StepPosition step_position_;
100 100
101 DISALLOW_ASSIGN(StepsTimingFunction); 101 DISALLOW_ASSIGN(StepsTimingFunction);
102 }; 102 };
103 103
104 class CC_ANIMATION_EXPORT FramesTimingFunction : public TimingFunction {
105 public:
106 static std::unique_ptr<FramesTimingFunction> Create(int frames);
107 ~FramesTimingFunction() override;
108
109 // TimingFunction implementation.
110 Type GetType() const override;
111 float GetValue(double t) const override;
112 std::unique_ptr<TimingFunction> Clone() const override;
113 void Range(float* min, float* max) const override;
114 float Velocity(double time) const override;
115
116 int frames() const { return frames_; }
117 double GetPreciseValue(double t) const;
118
119 private:
120 explicit FramesTimingFunction(int frames);
121
122 int frames_;
123
124 DISALLOW_ASSIGN(FramesTimingFunction);
125 };
126
104 } // namespace cc 127 } // namespace cc
105 128
106 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ 129 #endif // CC_ANIMATION_TIMING_FUNCTION_H_
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve_unittest.cc ('k') | cc/animation/timing_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698