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 #ifndef InterpolableValue_h | 5 #ifndef InterpolableValue_h |
6 #define InterpolableValue_h | 6 #define InterpolableValue_h |
7 | 7 |
8 #include "core/CoreExport.h" | |
8 #include "core/animation/animatable/AnimatableValue.h" | 9 #include "core/animation/animatable/AnimatableValue.h" |
9 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
10 #include "wtf/OwnPtr.h" | 11 #include "wtf/OwnPtr.h" |
11 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
12 #include "wtf/Vector.h" | 13 #include "wtf/Vector.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue> { | 17 class CORE_EXPORT InterpolableValue : public NoBaseWillBeGarbageCollected<Interp olableValue> { |
17 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); | 18 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); |
18 public: | 19 public: |
19 virtual bool isNumber() const { return false; } | 20 virtual bool isNumber() const { return false; } |
20 virtual bool isBool() const { return false; } | 21 virtual bool isBool() const { return false; } |
21 virtual bool isList() const { return false; } | 22 virtual bool isList() const { return false; } |
22 virtual bool isAnimatableValue() const { return false; } | 23 virtual bool isAnimatableValue() const { return false; } |
23 | 24 |
24 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; | 25 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; |
25 | 26 |
26 DEFINE_INLINE_VIRTUAL_TRACE() { } | 27 DEFINE_INLINE_VIRTUAL_TRACE() { } |
27 | 28 |
28 private: | 29 private: |
29 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0; | 30 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0; |
30 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst = 0; | 31 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst = 0; |
31 virtual void multiply(double scalar, InterpolableValue& result) const = 0; | 32 virtual void multiply(double scalar, InterpolableValue& result) const = 0; |
32 | 33 |
33 friend class Interpolation; | 34 friend class Interpolation; |
34 | 35 |
35 // Keep interpolate private, but allow calls within the hierarchy without | 36 // Keep interpolate private, but allow calls within the hierarchy without |
36 // knowledge of type. | 37 // knowledge of type. |
37 friend class DeferredLegacyStyleInterpolation; | 38 friend class DeferredLegacyStyleInterpolation; |
38 friend class InterpolableNumber; | 39 friend class InterpolableNumber; |
39 friend class InterpolableBool; | 40 friend class InterpolableBool; |
40 friend class InterpolableList; | 41 friend class InterpolableList; |
41 | 42 |
42 friend class AnimationInterpolableValueTest; | 43 friend class AnimationInterpolableValueTest; |
43 }; | 44 }; |
44 | 45 |
45 class InterpolableNumber final : public InterpolableValue { | 46 class CORE_EXPORT InterpolableNumber final : public InterpolableValue { |
46 public: | 47 public: |
47 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) | 48 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) |
48 { | 49 { |
49 return adoptPtrWillBeNoop(new InterpolableNumber(value)); | 50 return adoptPtrWillBeNoop(new InterpolableNumber(value)); |
50 } | 51 } |
51 | 52 |
52 virtual bool isNumber() const override final { return true; } | 53 virtual bool isNumber() const override final { return true; } |
53 double value() const { return m_value; } | 54 double value() const { return m_value; } |
54 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } | 55 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } |
55 | 56 |
56 private: | 57 private: |
57 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; | 58 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; |
58 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; | 59 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; |
59 virtual void multiply(double scalar, InterpolableValue& result) const overri de final; | 60 virtual void multiply(double scalar, InterpolableValue& result) const overri de final; |
60 double m_value; | 61 double m_value; |
61 | 62 |
62 explicit InterpolableNumber(double value) | 63 explicit InterpolableNumber(double value) |
63 : m_value(value) | 64 : m_value(value) |
64 { | 65 { |
65 } | 66 } |
66 | 67 |
67 }; | 68 }; |
68 | 69 |
69 class InterpolableBool final : public InterpolableValue { | 70 class CORE_EXPORT InterpolableBool final : public InterpolableValue { |
70 public: | 71 public: |
71 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) | 72 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) |
72 { | 73 { |
73 return adoptPtrWillBeNoop(new InterpolableBool(value)); | 74 return adoptPtrWillBeNoop(new InterpolableBool(value)); |
74 } | 75 } |
75 | 76 |
76 virtual bool isBool() const override final { return true; } | 77 virtual bool isBool() const override final { return true; } |
77 bool value() const { return m_value; } | 78 bool value() const { return m_value; } |
78 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } | 79 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } |
79 | 80 |
80 private: | 81 private: |
81 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; | 82 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; |
82 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; | 83 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; |
83 virtual void multiply(double scalar, InterpolableValue& result) const overri de final { ASSERT_NOT_REACHED(); } | 84 virtual void multiply(double scalar, InterpolableValue& result) const overri de final { ASSERT_NOT_REACHED(); } |
84 bool m_value; | 85 bool m_value; |
85 | 86 |
86 explicit InterpolableBool(bool value) | 87 explicit InterpolableBool(bool value) |
87 : m_value(value) | 88 : m_value(value) |
88 { | 89 { |
89 } | 90 } |
90 | 91 |
91 }; | 92 }; |
92 | 93 |
93 class InterpolableList : public InterpolableValue { | 94 class CORE_EXPORT InterpolableList : public InterpolableValue { |
94 public: | 95 public: |
96 InterpolableList& operator=(const InterpolableList&) = delete; | |
haraken
2015/04/15 09:35:19
Why do we need this? It looks a bit strange that o
tasak
2015/04/16 01:28:42
The operator= is compiler-generated one. As far as
haraken
2015/04/16 03:35:10
Alternatively, would it be possible to add WTF_NON
tasak
2015/04/16 05:39:07
Unfortunately InterpolableList has its own copy co
| |
97 | |
95 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other) | 98 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other) |
96 { | 99 { |
97 return adoptPtrWillBeNoop(new InterpolableList(other)); | 100 return adoptPtrWillBeNoop(new InterpolableList(other)); |
98 } | 101 } |
99 | 102 |
100 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size) | 103 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size) |
101 { | 104 { |
102 return adoptPtrWillBeNoop(new InterpolableList(size)); | 105 return adoptPtrWillBeNoop(new InterpolableList(size)); |
103 } | 106 } |
104 | 107 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 }; | 170 }; |
168 | 171 |
169 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber()); | 172 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber()); |
170 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool()); | 173 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool()); |
171 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList()); | 174 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList()); |
172 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue()); | 175 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue()); |
173 | 176 |
174 } | 177 } |
175 | 178 |
176 #endif | 179 #endif |
OLD | NEW |