Skip to content

Commit

Permalink
avm2: Use slot access in native code for Graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Dec 10, 2024
1 parent 2b74c70 commit be9110c
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 50 deletions.
9 changes: 8 additions & 1 deletion core/src/avm2/globals/flash/display/GraphicsBitmapFill.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ package flash.display {
import flash.geom.Matrix;

public final class GraphicsBitmapFill implements IGraphicsFill, IGraphicsData {
[Ruffle(InternalSlot)]
public var bitmapData : BitmapData;

[Ruffle(InternalSlot)]
public var matrix : Matrix;

[Ruffle(InternalSlot)]
public var repeat : Boolean;

[Ruffle(InternalSlot)]
public var smooth : Boolean;

public function GraphicsBitmapFill(bitmapData:BitmapData = null, matrix:Matrix = null, repeat:Boolean = true, smooth:Boolean = false) {
Expand All @@ -15,4 +22,4 @@ import flash.geom.Matrix;
this.smooth = smooth;
}
}
}
}
17 changes: 16 additions & 1 deletion core/src/avm2/globals/flash/display/GraphicsGradientFill.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@ package flash.display {
import flash.geom.Matrix;

public final class GraphicsGradientFill implements IGraphicsFill, IGraphicsData {
[Ruffle(InternalSlot)]
public var alphas : Array;

[Ruffle(InternalSlot)]
public var colors : Array;

[Ruffle(InternalSlot)]
public var focalPointRatio : Number;

[Ruffle(InternalSlot)]
public var interpolationMethod : String;

[Ruffle(InternalSlot)]
public var matrix : Matrix;

[Ruffle(InternalSlot)]
public var ratios : Array;

[Ruffle(InternalSlot)]
public var spreadMethod : String;

[Ruffle(InternalSlot)]
public var type : String;

public function GraphicsGradientFill(
Expand All @@ -32,4 +47,4 @@ import flash.geom.Matrix;
this.type = type;
}
}
}
}
21 changes: 19 additions & 2 deletions core/src/avm2/globals/flash/display/GraphicsPath.as
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
package flash.display {

public final class GraphicsPath implements IGraphicsPath, IGraphicsData {
[Ruffle(InternalSlot)]
public var commands : Vector.<int>;

[Ruffle(InternalSlot)]
public var data : Vector.<Number>;
public var winding : String;

[Ruffle(InternalSlot)]
private var _winding : String;

public function GraphicsPath(commands:Vector.<int> = null, data:Vector.<Number> = null, winding:String = "evenOdd") {
this.commands = commands;
this.data = data;
this.winding = winding;
}

public function get winding():String {
return this._winding;
}

public function set winding(value:String):void {
if (value != "evenOdd" && value != "nonZero") {
throw new ArgumentError("Error #2008: Parameter winding must be one of the accepted values.", 2008);
} else {
this._winding = value;
}
}

[API("674")] // The online docs say 694, but that's a lie. This is the correct number from playerglobal.swc.
public function cubicCurveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX:Number, anchorY:Number):void {
if (commands == null) {
Expand Down Expand Up @@ -85,4 +102,4 @@ package flash.display {
}
}

}
}
5 changes: 4 additions & 1 deletion core/src/avm2/globals/flash/display/GraphicsSolidFill.as
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package flash.display {

public final class GraphicsSolidFill implements IGraphicsFill, IGraphicsData {
[Ruffle(InternalSlot)]
public var alpha : Number = 1.0;

[Ruffle(InternalSlot)]
public var color : uint = 0;

public function GraphicsSolidFill(color:uint = 0, alpha:Number = 1.0) {
Expand All @@ -10,4 +13,4 @@ package flash.display {
}
}

}
}
15 changes: 14 additions & 1 deletion core/src/avm2/globals/flash/display/GraphicsStroke.as
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
package flash.display {

public final class GraphicsStroke implements IGraphicsStroke, IGraphicsData {
[Ruffle(InternalSlot)]
public var caps : String;

[Ruffle(InternalSlot)]
public var fill : IGraphicsFill;

[Ruffle(InternalSlot)]
public var joints : String;

[Ruffle(InternalSlot)]
public var miterLimit : Number;

[Ruffle(InternalSlot)]
public var pixelHinting : Boolean;

[Ruffle(InternalSlot)]
public var scaleMode : String;

[Ruffle(InternalSlot)]
public var thickness : Number;

public function GraphicsStroke(
Expand All @@ -28,4 +41,4 @@ package flash.display {
}
}

}
}
9 changes: 8 additions & 1 deletion core/src/avm2/globals/flash/display/GraphicsTrianglePath.as
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package flash.display {

public final class GraphicsTrianglePath implements IGraphicsPath, IGraphicsData {
[Ruffle(InternalSlot)]
public var culling : String;

[Ruffle(InternalSlot)]
public var indices : Vector.<int>;

[Ruffle(InternalSlot)]
public var uvtData : Vector.<Number>;

[Ruffle(InternalSlot)]
public var vertices : Vector.<Number>;

public function GraphicsTrianglePath(vertices:Vector.<Number> = null, indices:Vector.<int> = null, uvtData:Vector.<Number> = null, culling:String = "none") {
Expand All @@ -14,4 +21,4 @@ package flash.display {
}
}

}
}
Loading

0 comments on commit be9110c

Please sign in to comment.