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 #include "config.h" | |
6 #include "core/animation/animatable/AnimatablePath.h" | |
7 | |
8 #include "core/svg/SVGPathBlender.h" | |
9 #include "core/svg/SVGPathByteStreamBuilder.h" | |
10 #include "core/svg/SVGPathByteStreamSource.h" | |
11 #include "core/svg/SVGPathUtilities.h" | |
12 | |
13 namespace blink { | |
14 | |
15 bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value) const | |
16 { | |
17 // Default interpolation is used if the paths have different lengths, | |
18 // or the paths have a segment with different types (ignoring "relativeness" ). | |
19 | |
20 SVGPathByteStreamSource fromSource(pathValue()->byteStream()); | |
21 SVGPathByteStreamSource toSource(toAnimatablePath(value)->pathValue()->byteS tream()); | |
22 | |
23 while (fromSource.hasMoreData()) { | |
24 if (!toSource.hasMoreData()) | |
25 return true; | |
26 | |
27 PathSegmentData fromSeg = fromSource.parseSegment(); | |
28 PathSegmentData toSeg = toSource.parseSegment(); | |
29 if (fromSeg.command == PathSegUnknown || toSeg.command == PathSegUnknown ) | |
fs
2015/12/15 11:52:52
'PathSegUnknown' should never be stored in an SVGP
Eric Willigers
2015/12/15 22:33:55
Replaced with assert.
| |
30 return true; | |
31 | |
32 if (toAbsolutePathSegType(fromSeg.command) != toAbsolutePathSegType(toSe g.command)) | |
33 return true; | |
34 } | |
35 | |
36 return toSource.hasMoreData(); | |
37 } | |
38 | |
39 PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const | |
40 { | |
41 if (usesDefaultInterpolationWith(value)) | |
42 return defaultInterpolateTo(this, value, fraction); | |
43 | |
44 OwnPtr<SVGPathByteStream> byteStream; | |
45 byteStream = SVGPathByteStream::create(); | |
fs
2015/12/15 11:52:52
These two lines could be merged.
Eric Willigers
2015/12/15 22:33:55
Done.
| |
46 SVGPathByteStreamBuilder builder(*byteStream); | |
47 | |
48 SVGPathByteStreamSource fromSource(pathValue()->byteStream()); | |
49 SVGPathByteStreamSource toSource(toAnimatablePath(value)->pathValue()->byteS tream()); | |
50 | |
51 SVGPathBlender blender(&fromSource, &toSource, &builder); | |
52 bool ok = blender.blendAnimatedPath(fraction); | |
53 ASSERT_UNUSED(ok, ok); | |
54 return AnimatablePath::create(CSSPathValue::create(byteStream.release())); | |
55 } | |
56 | |
57 bool AnimatablePath::equalTo(const AnimatableValue* value) const | |
58 { | |
59 return pathValue()->equals(*toAnimatablePath(value)->pathValue()); | |
60 } | |
61 | |
62 } // namespace blink | |
OLD | NEW |