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

Side by Side Diff: chrome/browser/android/vr_shell/easing.h

Issue 2335643002: Add VR Shell animation classes and unit test. (Closed)
Patch Set: Add VR Shell animation classes and unit test. Created 4 years, 3 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 | « chrome/browser/android/vr_shell/animation.cc ('k') | chrome/browser/android/vr_shell/easing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
7
8 #include "ui/gfx/geometry/cubic_bezier.h"
9
10 namespace vr_shell {
11 namespace easing {
12
13 // Abstract base class for custom interpolators, mapping linear input between
14 // 0 and 1 to custom values between those two points.
15 class Easing {
16 public:
17 // Compute an output value, given an input between 0 and 1. Output will
18 // equal input at (at least) points 0 and 1.
19 double CalculateValue(double input);
20 virtual ~Easing() {}
21
22 protected:
23 Easing() {}
24 virtual double CalculateValueImpl(double input) = 0;
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(Easing);
28 };
29
30 // Linear interpolation generates output equal to input.
31 class Linear : public Easing {
32 public:
33 Linear() = default;
34 double CalculateValueImpl(double input) override;
35
36 private:
37 DISALLOW_COPY_AND_ASSIGN(Linear);
38 };
39
40 // Computes a cubic-bezier transition based on two control points.
41 class CubicBezier : public Easing {
42 public:
43 CubicBezier(double p1x, double p1y, double p2x, double p2y);
44 double CalculateValueImpl(double input) override;
45
46 private:
47 gfx::CubicBezier bezier_;
48 DISALLOW_COPY_AND_ASSIGN(CubicBezier);
49 };
50
51 // Computes |input|^|power|.
52 class EaseIn : public Easing {
53 public:
54 explicit EaseIn(double power);
55 double CalculateValueImpl(double input) override;
56
57 private:
58 double power_;
59 DISALLOW_COPY_AND_ASSIGN(EaseIn);
60 };
61
62 // Computes 1 - |input|^|power|.
63 class EaseOut : public Easing {
64 public:
65 explicit EaseOut(double power);
66 double CalculateValueImpl(double input) override;
67
68 private:
69 double power_;
70 DISALLOW_COPY_AND_ASSIGN(EaseOut);
71 };
72
73 } // namespace easing
74 } // namespace vr_shell
75
76 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/animation.cc ('k') | chrome/browser/android/vr_shell/easing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698