Chromium Code Reviews| 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/style/DataEquivalency.h" | |
| 9 #include "core/svg/SVGPathBlender.h" | |
| 10 #include "core/svg/SVGPathByteStreamBuilder.h" | |
| 11 #include "core/svg/SVGPathByteStreamSource.h" | |
| 12 #include "core/svg/SVGPathUtilities.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value) const | |
| 17 { | |
| 18 // Default interpolation is used if either path is not specified, | |
| 19 // or the paths have different lengths, | |
| 20 // or the paths have a segment with different types (ignoring "relativeness" ). | |
| 21 | |
| 22 const SVGPathByteStream* toByteStream = toAnimatablePath(value)->m_byteStrea m.get(); | |
| 23 if (!m_byteStream || !toByteStream) | |
| 24 return true; | |
| 25 | |
| 26 SVGPathByteStreamSource fromSource(*m_byteStream); | |
| 27 SVGPathByteStreamSource toSource(*toByteStream); | |
| 28 | |
| 29 while (fromSource.hasMoreData()) { | |
| 30 if (!toSource.hasMoreData()) | |
| 31 return true; | |
| 32 | |
| 33 PathSegmentData fromSeg = fromSource.parseSegment(); | |
| 34 PathSegmentData toSeg = toSource.parseSegment(); | |
| 35 if (fromSeg.command == PathSegUnknown || toSeg.command == PathSegUnknown ) | |
| 36 return true; | |
| 37 | |
| 38 if (toAbsolutePathSegType(fromSeg.command) != toAbsolutePathSegType(toSe g.command)) | |
| 39 return true; | |
| 40 } | |
| 41 | |
| 42 return toSource.hasMoreData(); | |
| 43 } | |
| 44 | |
| 45 PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const | |
| 46 { | |
| 47 if (usesDefaultInterpolationWith(value)) | |
| 48 return defaultInterpolateTo(this, value, fraction); | |
| 49 | |
| 50 OwnPtr<SVGPathByteStream> byteStream; | |
| 51 byteStream = SVGPathByteStream::create(); | |
| 52 SVGPathByteStreamBuilder builder(*byteStream); | |
| 53 | |
| 54 SVGPathByteStreamSource fromSource(*m_byteStream); | |
| 55 SVGPathByteStreamSource toSource(*toAnimatablePath(value)->m_byteStream); | |
|
dstockwell
2015/11/26 08:38:40
Is there a representation of paths which is not en
fs
2015/11/26 11:21:38
I believe it's the cheapest representation that re
Eric Willigers
2015/11/26 21:16:33
We will have an InterpolationType. It will fix thi
| |
| 56 | |
| 57 SVGPathBlender blender(&fromSource, &toSource, &builder); | |
| 58 bool ok = blender.blendAnimatedPath(fraction); | |
| 59 ASSERT_UNUSED(ok, ok); | |
| 60 return AnimatablePath::create(byteStream.release()); | |
| 61 } | |
| 62 | |
| 63 bool AnimatablePath::equalTo(const AnimatableValue* value) const | |
| 64 { | |
| 65 return dataEquivalent(m_byteStream, toAnimatablePath(value)->m_byteStream); | |
| 66 } | |
| 67 | |
| 68 } // namespace blink | |
| OLD | NEW |