| 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/CoreExport.h" |
| 9 #include "core/animation/animatable/AnimatableValue.h" | 9 #include "core/animation/animatable/AnimatableValue.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 virtual bool isBool() const { return false; } | 21 virtual bool isBool() const { return false; } |
| 22 virtual bool isList() const { return false; } | 22 virtual bool isList() const { return false; } |
| 23 virtual bool isAnimatableValue() const { return false; } | 23 virtual bool isAnimatableValue() const { return false; } |
| 24 | 24 |
| 25 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; | 25 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; |
| 26 | 26 |
| 27 DEFINE_INLINE_VIRTUAL_TRACE() { } | 27 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 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; |
| 31 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co
nst = 0; | 31 virtual void scaleAndAdd(double scale, const InterpolableValue& other) = 0; |
| 32 virtual void multiply(double scalar, InterpolableValue& result) const = 0; | |
| 33 | 32 |
| 34 friend class Interpolation; | 33 friend class Interpolation; |
| 35 friend class PairwisePrimitiveInterpolation; | 34 friend class PairwisePrimitiveInterpolation; |
| 35 friend class InvalidatableStyleInterpolation; |
| 36 | 36 |
| 37 // Keep interpolate private, but allow calls within the hierarchy without | 37 // Keep interpolate private, but allow calls within the hierarchy without |
| 38 // knowledge of type. | 38 // knowledge of type. |
| 39 friend class DeferredLegacyStyleInterpolation; | 39 friend class DeferredLegacyStyleInterpolation; |
| 40 friend class InterpolableNumber; | 40 friend class InterpolableNumber; |
| 41 friend class InterpolableBool; | 41 friend class InterpolableBool; |
| 42 friend class InterpolableList; | 42 friend class InterpolableList; |
| 43 | 43 |
| 44 friend class AnimationInterpolableValueTest; | 44 friend class AnimationInterpolableValueTest; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class CORE_EXPORT InterpolableNumber final : public InterpolableValue { | 47 class CORE_EXPORT InterpolableNumber final : public InterpolableValue { |
| 48 public: | 48 public: |
| 49 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) | 49 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) |
| 50 { | 50 { |
| 51 return adoptPtrWillBeNoop(new InterpolableNumber(value)); | 51 return adoptPtrWillBeNoop(new InterpolableNumber(value)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual bool isNumber() const override final { return true; } | 54 virtual bool isNumber() const override final { return true; } |
| 55 double value() const { return m_value; } | 55 double value() const { return m_value; } |
| 56 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } | 56 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; | 59 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; |
| 60 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co
nst override final; | 60 virtual void scaleAndAdd(double scale, const InterpolableValue& other) overr
ide final; |
| 61 virtual void multiply(double scalar, InterpolableValue& result) const overri
de final; | |
| 62 double m_value; | 61 double m_value; |
| 63 | 62 |
| 64 explicit InterpolableNumber(double value) | 63 explicit InterpolableNumber(double value) |
| 65 : m_value(value) | 64 : m_value(value) |
| 66 { | 65 { |
| 67 } | 66 } |
| 68 | 67 |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 class CORE_EXPORT InterpolableBool final : public InterpolableValue { | 70 class CORE_EXPORT InterpolableBool final : public InterpolableValue { |
| 72 public: | 71 public: |
| 73 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) | 72 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) |
| 74 { | 73 { |
| 75 return adoptPtrWillBeNoop(new InterpolableBool(value)); | 74 return adoptPtrWillBeNoop(new InterpolableBool(value)); |
| 76 } | 75 } |
| 77 | 76 |
| 78 virtual bool isBool() const override final { return true; } | 77 virtual bool isBool() const override final { return true; } |
| 79 bool value() const { return m_value; } | 78 bool value() const { return m_value; } |
| 80 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); } |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 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; |
| 84 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co
nst override final; | 83 virtual void scaleAndAdd(double scale, const InterpolableValue& other) overr
ide final { ASSERT_NOT_REACHED(); } |
| 85 virtual void multiply(double scalar, InterpolableValue& result) const overri
de final { ASSERT_NOT_REACHED(); } | |
| 86 bool m_value; | 84 bool m_value; |
| 87 | 85 |
| 88 explicit InterpolableBool(bool value) | 86 explicit InterpolableBool(bool value) |
| 89 : m_value(value) | 87 : m_value(value) |
| 90 { | 88 { |
| 91 } | 89 } |
| 92 | 90 |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 class CORE_EXPORT InterpolableList : public InterpolableValue { | 93 class CORE_EXPORT InterpolableList : public InterpolableValue { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 116 void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value) | 114 void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value) |
| 117 { | 115 { |
| 118 ASSERT(position < m_size); | 116 ASSERT(position < m_size); |
| 119 m_values[position] = value; | 117 m_values[position] = value; |
| 120 } | 118 } |
| 121 const InterpolableValue* get(size_t position) const | 119 const InterpolableValue* get(size_t position) const |
| 122 { | 120 { |
| 123 ASSERT(position < m_size); | 121 ASSERT(position < m_size); |
| 124 return m_values[position].get(); | 122 return m_values[position].get(); |
| 125 } | 123 } |
| 124 InterpolableValue* get(size_t position) |
| 125 { |
| 126 ASSERT(position < m_size); |
| 127 return m_values[position].get(); |
| 128 } |
| 126 size_t length() const { return m_size; } | 129 size_t length() const { return m_size; } |
| 127 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(*this); } | 130 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(*this); } |
| 128 | 131 |
| 129 DECLARE_VIRTUAL_TRACE(); | 132 DECLARE_VIRTUAL_TRACE(); |
| 130 | 133 |
| 131 private: | 134 private: |
| 132 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; | 135 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; |
| 133 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co
nst override final; | 136 virtual void scaleAndAdd(double scale, const InterpolableValue& other) overr
ide final; |
| 134 virtual void multiply(double scalar, InterpolableValue& result) const overri
de final; | |
| 135 explicit InterpolableList(size_t size) | 137 explicit InterpolableList(size_t size) |
| 136 : m_size(size) | 138 : m_size(size) |
| 137 , m_values(m_size) | 139 , m_values(m_size) |
| 138 { | 140 { |
| 139 } | 141 } |
| 140 | 142 |
| 141 InterpolableList(const InterpolableList& other) | 143 InterpolableList(const InterpolableList& other) |
| 142 : m_size(other.m_size) | 144 : m_size(other.m_size) |
| 143 , m_values(m_size) | 145 , m_values(m_size) |
| 144 { | 146 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 159 } | 161 } |
| 160 | 162 |
| 161 virtual bool isAnimatableValue() const override final { return true; } | 163 virtual bool isAnimatableValue() const override final { return true; } |
| 162 AnimatableValue* value() const { return m_value.get(); } | 164 AnimatableValue* value() const { return m_value.get(); } |
| 163 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } | 165 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } |
| 164 | 166 |
| 165 DECLARE_VIRTUAL_TRACE(); | 167 DECLARE_VIRTUAL_TRACE(); |
| 166 | 168 |
| 167 private: | 169 private: |
| 168 virtual void interpolate(const InterpolableValue &to, const double progress,
InterpolableValue& result) const override final; | 170 virtual void interpolate(const InterpolableValue &to, const double progress,
InterpolableValue& result) const override final; |
| 169 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co
nst override final { ASSERT_NOT_REACHED(); } | 171 virtual void scaleAndAdd(double scale, const InterpolableValue& other) overr
ide final { ASSERT_NOT_REACHED(); } |
| 170 virtual void multiply(double scalar, InterpolableValue& result) const overri
de final { ASSERT_NOT_REACHED(); } | |
| 171 RefPtrWillBeMember<AnimatableValue> m_value; | 172 RefPtrWillBeMember<AnimatableValue> m_value; |
| 172 | 173 |
| 173 InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) | 174 InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) |
| 174 : m_value(value) | 175 : m_value(value) |
| 175 { | 176 { |
| 176 } | 177 } |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber(
), value.isNumber()); | 180 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber(
), value.isNumber()); |
| 180 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v
alue.isBool()); | 181 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v
alue.isBool()); |
| 181 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v
alue.isList()); | 182 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v
alue.isList()); |
| 182 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value->
isAnimatableValue(), value.isAnimatableValue()); | 183 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value->
isAnimatableValue(), value.isAnimatableValue()); |
| 183 | 184 |
| 184 } | 185 } |
| 185 | 186 |
| 186 #endif | 187 #endif |
| OLD | NEW |