Skip to content

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

Open
@seclerp

Description

@seclerp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/SkiaSharpIssues that relate to the C# binding of SkiaSharp.tenet/performancePerformance related issues

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions