Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / browser / android / animation_utils.h
blobe20d2eb9e5021843792d2f2b242b09a5f4a99ef4
1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_
6 #define CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_
8 namespace content {
10 template <typename T>
11 T Lerp(T a, T b, T t) {
12 return a + (b - a) * t;
15 template <typename T>
16 T Clamp(T value, T low, T high) {
17 return value < low ? low : (value > high ? high : value);
20 template <typename T>
21 T Damp(T input, T factor) {
22 T result;
23 if (factor == 1) {
24 result = 1 - (1 - input) * (1 - input);
25 } else {
26 result = 1 - std::pow(1 - input, 2 * factor);
28 return result;
31 } // namespace content
33 #endif // CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_