@@ -16,6 +16,8 @@ import java.util.HashMap
16
16
* Created by cuiminghui on 2017/2/22.
17
17
*/
18
18
19
+ val sharedPath = Path ()
20
+
19
21
class SVGAVideoShapeEntity (obj : JSONObject ) {
20
22
21
23
enum class Type {
@@ -67,7 +69,6 @@ class SVGAVideoShapeEntity(obj: JSONObject) {
67
69
parseArgs(obj)
68
70
parseStyles(obj)
69
71
parseTransform(obj)
70
- buildPath()
71
72
}
72
73
73
74
val isKeep: Boolean
@@ -155,10 +156,13 @@ class SVGAVideoShapeEntity(obj: JSONObject) {
155
156
}
156
157
157
158
fun buildPath () {
158
- val aPath = Path ()
159
+ if (this .shapePath != null ) {
160
+ return
161
+ }
162
+ sharedPath.reset()
159
163
if (this .type == SVGAVideoShapeEntity .Type .shape) {
160
164
(this .args?.get(" d" ) as ? String )?.let {
161
- SVGAPath (it).buildPath(aPath )
165
+ SVGAPath (it).buildPath(sharedPath )
162
166
}
163
167
}
164
168
else if (this .type == SVGAVideoShapeEntity .Type .ellipse) {
@@ -170,7 +174,7 @@ class SVGAVideoShapeEntity(obj: JSONObject) {
170
174
val y = yv.toFloat()
171
175
val rx = rxv.toFloat()
172
176
val ry = ryv.toFloat()
173
- aPath .addOval(RectF (x - rx, y - ry, x + rx, y + ry), Path .Direction .CW )
177
+ sharedPath .addOval(RectF (x - rx, y - ry, x + rx, y + ry), Path .Direction .CW )
174
178
}
175
179
else if (this .type == SVGAVideoShapeEntity .Type .rect) {
176
180
val xv = this .args?.get(" x" ) as ? Number ? : return
@@ -183,9 +187,10 @@ class SVGAVideoShapeEntity(obj: JSONObject) {
183
187
val width = wv.toFloat()
184
188
val height = hv.toFloat()
185
189
val cornerRadius = crv.toFloat()
186
- aPath .addRoundRect(RectF (x, y, x + width, y + height), cornerRadius, cornerRadius, Path .Direction .CW )
190
+ sharedPath .addRoundRect(RectF (x, y, x + width, y + height), cornerRadius, cornerRadius, Path .Direction .CW )
187
191
}
188
- this .shapePath = aPath
192
+ this .shapePath = Path ()
193
+ this .shapePath?.addPath(sharedPath)
189
194
}
190
195
191
196
}
0 commit comments