Skip to content

Conversation

@seclerp
Copy link

@seclerp seclerp commented Mar 29, 2023

Description of Change

Add the ability to pass offsets and counts to the SKVertices struct for passing them to the DrawVertices call.

Features Resolved

API Changes

Added:

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

Behavioral Changes

None.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation

Regarding tests - I can't find any tests related to SKVertices class usage at all.

The documentation PR is in progress.

@seclerp
Copy link
Author

seclerp commented Mar 29, 2023

@dotnet-policy-service agree

@mattleibow
Copy link
Contributor

mattleibow commented Jun 12, 2023

Thanks for this PR. Not copying things to get a shorter array is a good thing.

For these types of things, maybe we can use ReadOnlySpan<T>?

Not only do we get performance benefits of not having to create arrays just to pass in, but we can make use of all the index/range features of spans.

An example of where I did this would is here:

public static SKMask Create (byte[] image, SKRectI bounds, UInt32 rowBytes, SKMaskFormat format) =>
Create (image.AsSpan (), bounds, rowBytes, format);
public static SKMask Create (ReadOnlySpan<byte> image, SKRectI bounds, UInt32 rowBytes, SKMaskFormat format)

@seclerp seclerp closed this by deleting the head repository Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

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

2 participants