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

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

@seclerp seclerp force-pushed the skvertices-create-copy-offsets branch from 6464a5e to 684c465 Compare March 29, 2023 18:01
@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
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