OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 TypedInterpolationValue_h | 5 #ifndef TypedInterpolationValue_h |
6 #define TypedInterpolationValue_h | 6 #define TypedInterpolationValue_h |
7 | 7 |
8 #include "core/animation/InterpolationValue.h" | 8 #include "core/animation/InterpolationValue.h" |
9 #include "wtf/PtrUtil.h" | 9 #include "wtf/PtrUtil.h" |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class InterpolationType; | 14 class InterpolationType; |
15 | 15 |
16 // Represents an interpolated value between an adjacent pair of PropertySpecific
Keyframes. | 16 // Represents an interpolated value between an adjacent pair of PropertySpecific
Keyframes. |
17 class TypedInterpolationValue { | 17 class TypedInterpolationValue { |
18 public: | 18 public: |
19 static std::unique_ptr<TypedInterpolationValue> create(const InterpolationTy
pe& type, std::unique_ptr<InterpolableValue> interpolableValue, PassRefPtr<NonIn
terpolableValue> nonInterpolableValue = nullptr) | 19 static std::unique_ptr<TypedInterpolationValue> create(const InterpolationTy
pe& type, InterpolationValue&& value) |
20 { | 20 { |
21 return wrapUnique(new TypedInterpolationValue(type, std::move(interpolab
leValue), nonInterpolableValue)); | 21 return wrapUnique(new TypedInterpolationValue(type, std::move(value))); |
22 } | 22 } |
23 | 23 |
24 std::unique_ptr<TypedInterpolationValue> clone() const | 24 std::unique_ptr<TypedInterpolationValue> clone() const |
25 { | 25 { |
26 InterpolationValue copy = m_value.clone(); | 26 return create(m_type, m_value.clone()); |
27 return create(m_type, std::move(copy.interpolableValue), copy.nonInterpo
lableValue.release()); | |
28 } | 27 } |
29 | 28 |
30 const InterpolationType& type() const { return m_type; } | 29 const InterpolationType& type() const { return m_type; } |
31 const InterpolableValue& interpolableValue() const { return *m_value.interpo
lableValue; } | 30 const InterpolableValue& interpolableValue() const { return *m_value.interpo
lableValue; } |
32 const NonInterpolableValue* getNonInterpolableValue() const { return m_value
.nonInterpolableValue.get(); } | 31 const NonInterpolableValue* getNonInterpolableValue() const { return m_value
.nonInterpolableValue.get(); } |
33 const InterpolationValue& value() const { return m_value; } | 32 const InterpolationValue& value() const { return m_value; } |
34 | 33 |
35 InterpolationValue& mutableValue() { return m_value; } | 34 InterpolationValue& mutableValue() { return m_value; } |
36 | 35 |
37 private: | 36 private: |
38 TypedInterpolationValue(const InterpolationType& type, std::unique_ptr<Inter
polableValue> interpolableValue, PassRefPtr<NonInterpolableValue> nonInterpolabl
eValue) | 37 TypedInterpolationValue(const InterpolationType& type, InterpolationValue&&
value) |
39 : m_type(type) | 38 : m_type(type) |
40 , m_value(std::move(interpolableValue), nonInterpolableValue) | 39 , m_value(std::move(value)) |
41 { | 40 { |
42 ASSERT(m_value.interpolableValue); | 41 DCHECK(m_value.interpolableValue); |
43 } | 42 } |
44 | 43 |
45 const InterpolationType& m_type; | 44 const InterpolationType& m_type; |
46 InterpolationValue m_value; | 45 InterpolationValue m_value; |
47 }; | 46 }; |
48 | 47 |
49 } // namespace blink | 48 } // namespace blink |
50 | 49 |
51 #endif // TypedInterpolationValue_h | 50 #endif // TypedInterpolationValue_h |
OLD | NEW |