From 96bb0b8e2e62c0384cf1fb83939326380e2b9458 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 18 Mar 2023 01:59:38 +0100 Subject: [PATCH] avm2: Lazily create commands and data in GraphicsPath --- .../globals/flash/display/GraphicsPath.as | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/core/src/avm2/globals/flash/display/GraphicsPath.as b/core/src/avm2/globals/flash/display/GraphicsPath.as index 3d1f73afa..77f5b3e5b 100644 --- a/core/src/avm2/globals/flash/display/GraphicsPath.as +++ b/core/src/avm2/globals/flash/display/GraphicsPath.as @@ -6,38 +6,62 @@ package flash.display { public var winding : String; public function GraphicsPath(commands:Vector. = null, data:Vector. = null, winding:String = "evenOdd") { - if (commands == null) { - commands = new Vector.(); - } - if (data == null) { - data = new Vector.(); - } this.commands = commands; this.data = data; this.winding = winding; } public function cubicCurveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX:Number, anchorY:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } commands.push(GraphicsPathCommand.CUBIC_CURVE_TO); data.push(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); } public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } commands.push(GraphicsPathCommand.CURVE_TO); data.push(controlX, controlY, anchorX, anchorY); } public function lineTo(x:Number, y:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } commands.push(GraphicsPathCommand.LINE_TO); data.push(x, y); } public function moveTo(x:Number, y:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } commands.push(GraphicsPathCommand.MOVE_TO); data.push(x, y); } public function wideLineTo(x:Number, y:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } // "Wide" variant seems to literally just exist to use the same amount of data values as curveTo // The first two values are arbitrary. When consuming, they are ignored. // https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_LINE_TO @@ -46,6 +70,12 @@ package flash.display { } public function wideMoveTo(x:Number, y:Number):void { + if (commands == null) { + commands = new Vector.(); + } + if (data == null) { + data = new Vector.(); + } // "Wide" variant seems to literally just exist to use the same amount of data values as curveTo // The first two values are arbitrary. When consuming, they are ignored. // https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/GraphicsPathCommand.html#WIDE_MOVE_TO