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

[FEATURE] Add overload for SKVertices.CreateCopy that accepts offset and count for vertices and indexes #2431

Open
seclerp opened this issue Mar 29, 2023 · 0 comments · May be fixed by #2432
Labels
area/SkiaSharp tenet/performance Performance related issues

Comments

@seclerp
Copy link

seclerp commented Mar 29, 2023

Is your feature request related to a problem? Please describe.

Currently, it's impossible to create a copy of SKVertices as a "slice" of original one. It's common practice in low-level graphics to reuse the same array with different "regions" of it determined by offset and count. I have troubles to make it work with SkiaSharp as the third-party API provides me with complete merged array of vertices and indexes that I want to use without additional allocations.

Describe the solution you'd like

An extended main method could look like that (reflects the native call completely):

SKVertices CreateCopy (SKVertexMode vmode, int vertexOffset, int vertexCount, SKPoint[] positions, SKPoint[] texs, SKColor[] colors, int indexOffset, int indexCount, UInt16[] indices)

With the native call inside:

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));
}

Describe alternatives you've considered

Split input arrays into parts manually. Unoptimized solution with additional allocations.


PR: #2432

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/SkiaSharp tenet/performance Performance related issues
Projects
None yet
2 participants