@@ -31,6 +31,19 @@ public static SKVertices CreateCopy (SKVertexMode vmode, SKPoint[] positions, SK
31
31
}
32
32
33
33
public static SKVertices CreateCopy ( SKVertexMode vmode , SKPoint [ ] positions , SKPoint [ ] texs , SKColor [ ] colors , UInt16 [ ] indices )
34
+ {
35
+ var vertexCount = positions . Length ;
36
+ var indexCount = indices ? . Length ?? 0 ;
37
+
38
+ return CreateCopy ( vmode , vertexCount , positions , texs , colors , indexCount , indices ) ;
39
+ }
40
+
41
+ public static SKVertices CreateCopy ( SKVertexMode vmode , int vertexCount , SKPoint [ ] positions , SKPoint [ ] texs , SKColor [ ] colors , int indexCount , UInt16 [ ] indices )
42
+ {
43
+ return CreateCopy ( vmode , 0 , vertexCount , positions , texs , colors , 0 , indexCount , indices ) ;
44
+ }
45
+
46
+ public static SKVertices CreateCopy ( SKVertexMode vmode , int vertexOffset , int vertexCount , SKPoint [ ] positions , SKPoint [ ] texs , SKColor [ ] colors , int indexOffset , int indexCount , UInt16 [ ] indices )
34
47
{
35
48
if ( positions == null )
36
49
throw new ArgumentNullException ( nameof ( positions ) ) ;
@@ -40,14 +53,23 @@ public static SKVertices CreateCopy (SKVertexMode vmode, SKPoint[] positions, SK
40
53
if ( colors != null && positions . Length != colors . Length )
41
54
throw new ArgumentException ( "The number of colors must match the number of vertices." , nameof ( colors ) ) ;
42
55
43
- var vertexCount = positions . Length ;
44
- var indexCount = indices ? . Length ?? 0 ;
56
+ if ( vertexOffset >= positions . Length )
57
+ throw new ArgumentException ( "The vertex offset should be in bounds of vertex array." , nameof ( vertexOffset ) ) ;
58
+
59
+ if ( vertexOffset + vertexCount >= positions . Length )
60
+ throw new ArgumentException ( "The vertex count should be in bounds of vertex array." , nameof ( vertexOffset ) ) ;
61
+
62
+ if ( indexOffset >= indices . Length )
63
+ throw new ArgumentException ( "The index offset should be in bounds of index array." , nameof ( vertexOffset ) ) ;
64
+
65
+ if ( indexOffset + indexCount >= indices . Length )
66
+ throw new ArgumentException ( "The vertex count should be in bounds of vertex array." , nameof ( vertexOffset ) ) ;
45
67
46
68
fixed ( SKPoint * p = positions )
47
69
fixed ( SKPoint * t = texs )
48
70
fixed ( SKColor * c = colors )
49
71
fixed ( UInt16 * i = indices ) {
50
- return GetObject ( SkiaApi . sk_vertices_make_copy ( vmode , vertexCount , p , t , ( uint * ) c , indexCount , i ) ) ;
72
+ return GetObject ( SkiaApi . sk_vertices_make_copy ( vmode , vertexCount , p + vertexOffset , t + vertexOffset , ( uint * ) c + vertexOffset , indexCount , i + indexOffset ) ) ;
51
73
}
52
74
}
53
75
0 commit comments