Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKVertices: CreateCopy is missing overload to pass vertices' and indexes' offset + count #2432

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix validation and pointer arithmetics
seclerp committed Mar 29, 2023
commit 684c46532a867382ccc18dd2c8bfd452cf4f0be0
6 changes: 3 additions & 3 deletions binding/Binding/SKVertices.cs
Original file line number Diff line number Diff line change
@@ -56,20 +56,20 @@ public static SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int v
if (vertexOffset >= positions.Length)
throw new ArgumentException ("The vertex offset should be in bounds of vertex array.", nameof (vertexOffset));

if (vertexOffset + vertexCount >= positions.Length)
if (vertexOffset + vertexCount > positions.Length)
throw new ArgumentException ("The vertex count should be in bounds of vertex array.", nameof (vertexOffset));

if (indexOffset >= indices.Length)
throw new ArgumentException ("The index offset should be in bounds of index array.", nameof (vertexOffset));

if (indexOffset + indexCount >= indices.Length)
if (indexOffset + indexCount > indices.Length)
throw new ArgumentException ("The vertex count should be in bounds of vertex array.", nameof (vertexOffset));

fixed (SKPoint* p = positions)
fixed (SKPoint* t = texs)
fixed (SKColor* c = colors)
fixed (UInt16* i = indices) {
return GetObject (SkiaApi.sk_vertices_make_copy (vmode, vertexCount, p + vertexOffset, t + vertexOffset, (uint*)c + vertexOffset, indexCount, i + indexOffset));
return GetObject (SkiaApi.sk_vertices_make_copy (vmode, vertexCount, p + vertexOffset * sizeof(SKPoint), t + vertexOffset * sizeof(SKPoint), (uint*)c + vertexOffset * sizeof(uint), indexCount, i + indexOffset * sizeof(ushort)));
}
}