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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/easing.h
diff --git a/chrome/browser/android/vr_shell/easing.h b/chrome/browser/android/vr_shell/easing.h
new file mode 100644
index 0000000000000000000000000000000000000000..e3021ac8c7b07431521a958bccfba87f76d74ebd
--- /dev/null
+++ b/chrome/browser/android/vr_shell/easing.h
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
+#define CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
+
+#include "ui/gfx/geometry/cubic_bezier.h"
+
+namespace vr_shell {
+namespace easing {
+
+// Abstract base class for custom interpolators, mapping linear input between
+// 0 and 1 to custom values between those two points.
+class Easing {
+ public:
+ // Compute an output value, given an input between 0 and 1. Output will
+ // equal input at (at least) points 0 and 1.
+ double CalculateValue(double input);
+ virtual ~Easing() {}
+
+ protected:
+ Easing() {}
+ virtual double CalculateValueImpl(double input) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Easing);
+};
+
+// Linear interpolation generates output equal to input.
+class Linear : public Easing {
+ public:
+ Linear() = default;
+ double CalculateValueImpl(double input) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Linear);
+};
+
+// Computes a cubic-bezier transition based on two control points.
+class CubicBezier : public Easing {
+ public:
+ CubicBezier(double p1x, double p1y, double p2x, double p2y);
+ double CalculateValueImpl(double input) override;
+
+ private:
+ gfx::CubicBezier bezier_;
+ DISALLOW_COPY_AND_ASSIGN(CubicBezier);
+};
+
+// Computes |input|^|power|.
+class EaseIn : public Easing {
+ public:
+ explicit EaseIn(double power);
+ double CalculateValueImpl(double input) override;
+
+ private:
+ double power_;
+ DISALLOW_COPY_AND_ASSIGN(EaseIn);
+};
+
+// Computes 1 - |input|^|power|.
+class EaseOut : public Easing {
+ public:
+ explicit EaseOut(double power);
+ double CalculateValueImpl(double input) override;
+
+ private:
+ double power_;
+ DISALLOW_COPY_AND_ASSIGN(EaseOut);
+};
+
+} // namespace easing
+} // namespace vr_shell
+
+#endif // CHROME_BROWSER_ANDROID_VR_SHELL_EASING_H_
« 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