OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PrimitiveInterpolation_h | 5 #ifndef PrimitiveInterpolation_h |
6 #define PrimitiveInterpolation_h | 6 #define PrimitiveInterpolation_h |
7 | 7 |
8 #include "core/animation/TypedInterpolationValue.h" | 8 #include "core/animation/TypedInterpolationValue.h" |
9 #include "platform/animation/AnimationUtilities.h" | 9 #include "platform/animation/AnimationUtilities.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 89 |
90 private: | 90 private: |
91 FlipPrimitiveInterpolation(std::unique_ptr<TypedInterpolationValue> start, s td::unique_ptr<TypedInterpolationValue> end) | 91 FlipPrimitiveInterpolation(std::unique_ptr<TypedInterpolationValue> start, s td::unique_ptr<TypedInterpolationValue> end) |
92 : m_start(std::move(start)) | 92 : m_start(std::move(start)) |
93 , m_end(std::move(end)) | 93 , m_end(std::move(end)) |
94 , m_lastFraction(std::numeric_limits<double>::quiet_NaN()) | 94 , m_lastFraction(std::numeric_limits<double>::quiet_NaN()) |
95 { } | 95 { } |
96 | 96 |
97 void interpolateValue(double fraction, std::unique_ptr<TypedInterpolationVal ue>& result) const final | 97 void interpolateValue(double fraction, std::unique_ptr<TypedInterpolationVal ue>& result) const final |
98 { | 98 { |
99 // TODO(alancutter): Remove this optimisation once Oilpan is default. | |
alancutter (OOO until 2018)
2016/09/27 01:14:14
InterpolationValues are no longer garbage collecte
| |
100 if (!std::isnan(m_lastFraction) && (fraction < 0.5) == (m_lastFraction < 0.5)) | 99 if (!std::isnan(m_lastFraction) && (fraction < 0.5) == (m_lastFraction < 0.5)) |
101 return; | 100 return; |
102 const TypedInterpolationValue* side = ((fraction < 0.5) ? m_start : m_en d).get(); | 101 const TypedInterpolationValue* side = ((fraction < 0.5) ? m_start : m_en d).get(); |
103 result = side ? side->clone() : nullptr; | 102 result = side ? side->clone() : nullptr; |
104 m_lastFraction = fraction; | 103 m_lastFraction = fraction; |
105 } | 104 } |
106 | 105 |
107 double interpolateUnderlyingFraction(double start, double end, double fracti on) const final { return fraction < 0.5 ? start : end; } | 106 double interpolateUnderlyingFraction(double start, double end, double fracti on) const final { return fraction < 0.5 ? start : end; } |
108 | 107 |
109 bool isFlip() const final { return true; } | 108 bool isFlip() const final { return true; } |
110 | 109 |
111 std::unique_ptr<TypedInterpolationValue> m_start; | 110 std::unique_ptr<TypedInterpolationValue> m_start; |
112 std::unique_ptr<TypedInterpolationValue> m_end; | 111 std::unique_ptr<TypedInterpolationValue> m_end; |
113 mutable double m_lastFraction; | 112 mutable double m_lastFraction; |
114 }; | 113 }; |
115 | 114 |
116 } // namespace blink | 115 } // namespace blink |
117 | 116 |
118 #endif // PrimitiveInterpolation_h | 117 #endif // PrimitiveInterpolation_h |
OLD | NEW |