OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/svg/SVGPathByteStream.h" | 28 #include "core/svg/SVGPathByteStream.h" |
29 #include "core/svg/SVGPathByteStreamBuilder.h" | 29 #include "core/svg/SVGPathByteStreamBuilder.h" |
30 #include "core/svg/SVGPathByteStreamSource.h" | 30 #include "core/svg/SVGPathByteStreamSource.h" |
31 #include "core/svg/SVGPathUtilities.h" | 31 #include "core/svg/SVGPathUtilities.h" |
32 #include "platform/graphics/Path.h" | 32 #include "platform/graphics/Path.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 PassOwnPtr<SVGPathByteStream> blendPathByteStreams(const SVGPathByteStream& from
Stream, const SVGPathByteStream& toStream, float progress) | 38 PassRefPtr<SVGPathByteStream> blendPathByteStreams(const SVGPathByteStream& from
Stream, const SVGPathByteStream& toStream, float progress) |
39 { | 39 { |
40 OwnPtr<SVGPathByteStream> resultStream = SVGPathByteStream::create(); | 40 RefPtr<SVGPathByteStream> resultStream = SVGPathByteStream::create(); |
41 SVGPathByteStreamBuilder builder(*resultStream); | 41 SVGPathByteStreamBuilder builder(*resultStream); |
42 SVGPathByteStreamSource fromSource(fromStream); | 42 SVGPathByteStreamSource fromSource(fromStream); |
43 SVGPathByteStreamSource toSource(toStream); | 43 SVGPathByteStreamSource toSource(toStream); |
44 SVGPathBlender blender(&fromSource, &toSource, &builder); | 44 SVGPathBlender blender(&fromSource, &toSource, &builder); |
45 blender.blendAnimatedPath(progress); | 45 blender.blendAnimatedPath(progress); |
46 return resultStream.release(); | 46 return resultStream.release(); |
47 } | 47 } |
48 | 48 |
49 PassOwnPtr<SVGPathByteStream> addPathByteStreams(const SVGPathByteStream& fromSt
ream, const SVGPathByteStream& byStream, unsigned repeatCount = 1) | 49 PassRefPtr<SVGPathByteStream> addPathByteStreams(const SVGPathByteStream& fromSt
ream, const SVGPathByteStream& byStream, unsigned repeatCount = 1) |
50 { | 50 { |
51 OwnPtr<SVGPathByteStream> resultStream = SVGPathByteStream::create(); | 51 RefPtr<SVGPathByteStream> resultStream = SVGPathByteStream::create(); |
52 SVGPathByteStreamBuilder builder(*resultStream); | 52 SVGPathByteStreamBuilder builder(*resultStream); |
53 SVGPathByteStreamSource fromSource(fromStream); | 53 SVGPathByteStreamSource fromSource(fromStream); |
54 SVGPathByteStreamSource bySource(byStream); | 54 SVGPathByteStreamSource bySource(byStream); |
55 SVGPathBlender blender(&fromSource, &bySource, &builder); | 55 SVGPathBlender blender(&fromSource, &bySource, &builder); |
56 blender.addAnimatedPath(repeatCount); | 56 blender.addAnimatedPath(repeatCount); |
57 return resultStream.release(); | 57 return resultStream.release(); |
58 } | 58 } |
59 | 59 |
60 PassOwnPtr<SVGPathByteStream> conditionallyAddPathByteStreams(PassOwnPtr<SVGPath
ByteStream> fromStream, const SVGPathByteStream& byStream, unsigned repeatCount
= 1) | 60 PassRefPtr<SVGPathByteStream> conditionallyAddPathByteStreams(PassRefPtr<SVGPath
ByteStream> fromStream, const SVGPathByteStream& byStream, unsigned repeatCount
= 1) |
61 { | 61 { |
62 if (fromStream->isEmpty() || byStream.isEmpty()) | 62 if (fromStream->isEmpty() || byStream.isEmpty()) |
63 return fromStream; | 63 return fromStream; |
64 return addPathByteStreams(*fromStream, byStream, repeatCount); | 64 return addPathByteStreams(*fromStream, byStream, repeatCount); |
65 } | 65 } |
66 | 66 |
67 } | 67 } |
68 | 68 |
69 SVGPath::SVGPath() | 69 SVGPath::SVGPath() |
70 : SVGPropertyBase(classType()) | 70 : SVGPropertyBase(classType()) |
(...skipping 18 matching lines...) Expand all Loading... |
89 | 89 |
90 | 90 |
91 PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const | 91 PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const |
92 { | 92 { |
93 return SVGPath::create(m_pathValue); | 93 return SVGPath::create(m_pathValue); |
94 } | 94 } |
95 | 95 |
96 SVGParsingError SVGPath::setValueAsString(const String& string) | 96 SVGParsingError SVGPath::setValueAsString(const String& string) |
97 { | 97 { |
98 SVGParsingError parseStatus = NoError; | 98 SVGParsingError parseStatus = NoError; |
99 OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); | 99 RefPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); |
100 if (!buildByteStreamFromString(string, *byteStream)) | 100 if (!buildByteStreamFromString(string, *byteStream)) |
101 parseStatus = ParsingAttributeFailedError; | 101 parseStatus = ParsingAttributeFailedError; |
102 m_pathValue = CSSPathValue::create(byteStream.release()); | 102 m_pathValue = CSSPathValue::create(byteStream.release()); |
103 return parseStatus; | 103 return parseStatus; |
104 } | 104 } |
105 | 105 |
106 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String&
value) const | 106 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String&
value) const |
107 { | 107 { |
108 return SVGPath::create(CSSPathValue::create(value)); | 108 return SVGPath::create(CSSPathValue::create(value)); |
109 } | 109 } |
(...skipping 17 matching lines...) Expand all Loading... |
127 const RefPtrWillBeRawPtr<SVGPath> to = toSVGPath(toValue); | 127 const RefPtrWillBeRawPtr<SVGPath> to = toSVGPath(toValue); |
128 const SVGPathByteStream& toStream = to->byteStream(); | 128 const SVGPathByteStream& toStream = to->byteStream(); |
129 | 129 |
130 // If no 'to' value is given, nothing to animate. | 130 // If no 'to' value is given, nothing to animate. |
131 if (!toStream.size()) | 131 if (!toStream.size()) |
132 return; | 132 return; |
133 | 133 |
134 const RefPtrWillBeRawPtr<SVGPath> from = toSVGPath(fromValue); | 134 const RefPtrWillBeRawPtr<SVGPath> from = toSVGPath(fromValue); |
135 const SVGPathByteStream* fromStream = &from->byteStream(); | 135 const SVGPathByteStream* fromStream = &from->byteStream(); |
136 | 136 |
137 OwnPtr<SVGPathByteStream> copy; | 137 RefPtr<SVGPathByteStream> copy; |
138 if (isToAnimation) { | 138 if (isToAnimation) { |
139 copy = byteStream().copy(); | 139 copy = byteStream().clone(); |
140 fromStream = copy.get(); | 140 fromStream = copy.get(); |
141 } | 141 } |
142 | 142 |
143 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. | 143 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. |
144 if (fromStream->size() != toStream.size() && fromStream->size()) { | 144 if (fromStream->size() != toStream.size() && fromStream->size()) { |
145 if (percentage < 0.5) { | 145 if (percentage < 0.5) { |
146 if (!isToAnimation) { | 146 if (!isToAnimation) { |
147 m_pathValue = from->pathValue(); | 147 m_pathValue = from->pathValue(); |
148 return; | 148 return; |
149 } | 149 } |
150 } else { | 150 } else { |
151 m_pathValue = to->pathValue(); | 151 m_pathValue = to->pathValue(); |
152 return; | 152 return; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 OwnPtr<SVGPathByteStream> newStream = blendPathByteStreams(*fromStream, toSt
ream, percentage); | 156 RefPtr<SVGPathByteStream> newStream = blendPathByteStreams(*fromStream, toSt
ream, percentage); |
157 | 157 |
158 // Handle additive='sum'. | 158 // Handle additive='sum'. |
159 if (animationElement->isAdditive() && !isToAnimation) | 159 if (animationElement->isAdditive() && !isToAnimation) |
160 newStream = conditionallyAddPathByteStreams(newStream.release(), byteStr
eam()); | 160 newStream = conditionallyAddPathByteStreams(newStream.release(), byteStr
eam()); |
161 | 161 |
162 // Handle accumulate='sum'. | 162 // Handle accumulate='sum'. |
163 if (animationElement->isAccumulated() && repeatCount) | 163 if (animationElement->isAccumulated() && repeatCount) |
164 newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPa
th(toAtEndOfDurationValue)->byteStream(), repeatCount); | 164 newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPa
th(toAtEndOfDurationValue)->byteStream(), repeatCount); |
165 | 165 |
166 m_pathValue = CSSPathValue::create(newStream.release()); | 166 m_pathValue = CSSPathValue::create(newStream.release()); |
167 } | 167 } |
168 | 168 |
169 float SVGPath::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVG
Element*) | 169 float SVGPath::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVG
Element*) |
170 { | 170 { |
171 // FIXME: Support paced animations. | 171 // FIXME: Support paced animations. |
172 return -1; | 172 return -1; |
173 } | 173 } |
174 | 174 |
175 DEFINE_TRACE(SVGPath) | 175 DEFINE_TRACE(SVGPath) |
176 { | 176 { |
177 visitor->trace(m_pathValue); | 177 visitor->trace(m_pathValue); |
178 SVGPropertyBase::trace(visitor); | 178 SVGPropertyBase::trace(visitor); |
179 } | 179 } |
180 | 180 |
181 } | 181 } |
OLD | NEW |