drawAtlas vs drawVertices

86 views
Skip to first unread message

Ats

unread,
Dec 20, 2022, 10:03:41 AM12/20/22
to skia-discuss
Hi,

I'm using drawAtlas to draw a lot of textured sprites, but I noticed it only supports uniform scaling. For my use case, I need to scale the sprites by different factors along the x and y axes. To achieve that I'm considering changing to drawVertices and doing vertex position calculations manually.

Does anyone know if there are any drawbacks to using darwVertices over drawAtlas? F.e  performance, texturing issues etc.

Another thing I noticed is drawVertices does not take an Image as a param, but requires a shader created from the image to be bound to the paint object beforehand. Is there a reason for that?

Thanks,
Ats

Brian Osman

unread,
Dec 20, 2022, 10:10:41 AM12/20/22
to skia-d...@googlegroups.com
Hi,
As long as you're using the GPU backend, the behavior and performance should be very similar -- they both use the GPU in a fairly similar way. The CPU backend is probably faster with drawAtlas than it is with drawVertices, but I can't really say by how much (you'd have to measure to be sure). As for image vs. shader: this is mostly because taking SkShader is more versatile. It still allows you to specify an SkImage (with full control of tile modes and filtering when you create the image shader), but also lets you specify a gradient, SkSL shader, etc.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/c1e6a50d-b8c8-4995-b0c2-63adab39fce9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages