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 IntegerSVGInterpolation_h | 5 #ifndef IntegerSVGInterpolation_h |
6 #define IntegerSVGInterpolation_h | 6 #define IntegerSVGInterpolation_h |
7 | 7 |
8 #include "core/animation/SVGInterpolation.h" | 8 #include "core/animation/SVGInterpolation.h" |
9 #include "core/svg/SVGInteger.h" | 9 #include "core/svg/SVGInteger.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class IntegerSVGInterpolation : public SVGInterpolation { | 13 class IntegerSVGInterpolation : public SVGInterpolation { |
14 public: | 14 public: |
15 static PassRefPtrWillBeRawPtr<IntegerSVGInterpolation> create(SVGPropertyBas
e* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase>
attribute) | 15 static PassRefPtr<IntegerSVGInterpolation> create(SVGPropertyBase* start, SV
GPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
16 { | 16 { |
17 return adoptRefWillBeNoop(new IntegerSVGInterpolation(toInterpolableValu
e(start), toInterpolableValue(end), attribute)); | 17 return adoptRef(new IntegerSVGInterpolation(toInterpolableValue(start),
toInterpolableValue(end), attribute)); |
18 } | 18 } |
19 | 19 |
20 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final | 20 PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement&) const
final |
21 { | 21 { |
22 return fromInterpolableValue(*m_cachedValue); | 22 return fromInterpolableValue(*m_cachedValue); |
23 } | 23 } |
24 | 24 |
25 DEFINE_INLINE_VIRTUAL_TRACE() | |
26 { | |
27 SVGInterpolation::trace(visitor); | |
28 } | |
29 | |
30 private: | 25 private: |
31 IntegerSVGInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pas
sOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPr
opertyBase> attribute) | 26 IntegerSVGInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Inte
rpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
32 : SVGInterpolation(start, end, attribute) | 27 : SVGInterpolation(start, end, attribute) |
33 { | 28 { |
34 } | 29 } |
35 | 30 |
36 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(SVGProp
ertyBase* value) | 31 static PassOwnPtr<InterpolableValue> toInterpolableValue(SVGPropertyBase* va
lue) |
37 { | 32 { |
38 return InterpolableNumber::create(toSVGInteger(value)->value()); | 33 return InterpolableNumber::create(toSVGInteger(value)->value()); |
39 } | 34 } |
40 | 35 |
41 static PassRefPtrWillBeRawPtr<SVGInteger> fromInterpolableValue(const Interp
olableValue& value) | 36 static PassRefPtrWillBeRawPtr<SVGInteger> fromInterpolableValue(const Interp
olableValue& value) |
42 { | 37 { |
43 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(value
).value()))); | 38 return SVGInteger::create(clampTo<int>(roundf(toInterpolableNumber(value
).value()))); |
44 } | 39 } |
45 }; | 40 }; |
46 | 41 |
47 } | 42 } |
48 | 43 |
49 #endif // IntegerSVGInterpolation_h | 44 #endif // IntegerSVGInterpolation_h |
OLD | NEW |