@@ -17,6 +17,8 @@ import java.util.HashMap
17
17
* Created by cuiminghui on 2017/2/22.
18
18
*/
19
19
20
+ val sharedPath = Path ()
21
+
20
22
class SVGAVideoShapeEntity {
21
23
22
24
enum class Type {
@@ -76,7 +78,6 @@ class SVGAVideoShapeEntity {
76
78
parseArgs(obj)
77
79
parseStyles(obj)
78
80
parseTransform(obj)
79
- buildPath()
80
81
}
81
82
82
83
val isKeep: Boolean
@@ -247,11 +248,15 @@ class SVGAVideoShapeEntity {
247
248
}
248
249
}
249
250
250
- private fun buildPath () {
251
- val aPath = Path ()
251
+
252
+ fun buildPath () {
253
+ if (this .shapePath != null ) {
254
+ return
255
+ }
256
+ sharedPath.reset()
252
257
if (this .type == SVGAVideoShapeEntity .Type .shape) {
253
258
(this .args?.get(" d" ) as ? String )?.let {
254
- SVGAPath (it).buildPath(aPath )
259
+ SVGAPath (it).buildPath(sharedPath )
255
260
}
256
261
}
257
262
else if (this .type == SVGAVideoShapeEntity .Type .ellipse) {
@@ -263,7 +268,7 @@ class SVGAVideoShapeEntity {
263
268
val y = yv.toFloat()
264
269
val rx = rxv.toFloat()
265
270
val ry = ryv.toFloat()
266
- aPath .addOval(RectF (x - rx, y - ry, x + rx, y + ry), Path .Direction .CW )
271
+ sharedPath .addOval(RectF (x - rx, y - ry, x + rx, y + ry), Path .Direction .CW )
267
272
}
268
273
else if (this .type == SVGAVideoShapeEntity .Type .rect) {
269
274
val xv = this .args?.get(" x" ) as ? Number ? : return
@@ -276,9 +281,10 @@ class SVGAVideoShapeEntity {
276
281
val width = wv.toFloat()
277
282
val height = hv.toFloat()
278
283
val cornerRadius = crv.toFloat()
279
- aPath .addRoundRect(RectF (x, y, x + width, y + height), cornerRadius, cornerRadius, Path .Direction .CW )
284
+ sharedPath .addRoundRect(RectF (x, y, x + width, y + height), cornerRadius, cornerRadius, Path .Direction .CW )
280
285
}
281
- this .shapePath = aPath
286
+ this .shapePath = Path ()
287
+ this .shapePath?.addPath(sharedPath)
282
288
}
283
289
284
290
}
0 commit comments