OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "core/animation/Interpolation.h" | 5 #include "core/animation/StyleInterpolation.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) | 13 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
14 { | 14 { |
15 if (start == end) | 15 if (start == end) |
(...skipping 12 matching lines...) Expand all Loading... |
28 return false; | 28 return false; |
29 for (size_t i = 0; i < startList->length(); ++i) { | 29 for (size_t i = 0; i < startList->length(); ++i) { |
30 if (!typesMatch(startList->get(i), endList->get(i))) | 30 if (!typesMatch(startList->get(i), endList->get(i))) |
31 return false; | 31 return false; |
32 } | 32 } |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 Interpolation::Interpolation(std::unique_ptr<InterpolableValue> start, std::uniq
ue_ptr<InterpolableValue> end) | 38 StyleInterpolation::StyleInterpolation(std::unique_ptr<InterpolableValue> start,
std::unique_ptr<InterpolableValue> end, CSSPropertyID id) |
39 : m_start(std::move(start)) | 39 : m_start(std::move(start)) |
40 , m_end(std::move(end)) | 40 , m_end(std::move(end)) |
41 , m_cachedFraction(0) | 41 , m_id(id) |
42 , m_cachedIteration(0) | |
43 , m_cachedValue(m_start ? m_start->clone() : nullptr) | 42 , m_cachedValue(m_start ? m_start->clone() : nullptr) |
44 { | 43 { |
45 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); | 44 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
46 } | 45 } |
47 | 46 |
48 Interpolation::~Interpolation() | 47 void StyleInterpolation::interpolateImpl() |
49 { | 48 { |
50 } | 49 m_start->interpolate(*m_end, m_currentFraction, *m_cachedValue); |
51 | |
52 void Interpolation::interpolate(int iteration, double fraction) | |
53 { | |
54 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { | |
55 m_start->interpolate(*m_end, fraction, *m_cachedValue); | |
56 m_cachedIteration = iteration; | |
57 m_cachedFraction = fraction; | |
58 } | |
59 } | 50 } |
60 | 51 |
61 } // namespace blink | 52 } // namespace blink |
OLD | NEW |