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