I'm trying to figure out how to make Skia produce mesh from path geometry. I've checked SkPath::dump
, SkPath::writeToMemory
, SkPath::serialize
, however all of them seem to output path content rather than mesh.
Note: by mesh i mean triangle mesh produced by tessellation of path shape that can be later used to be rendered with non-vector graphical APIs, such as OpenGL / Vulkan. Something similar to output of ID2D1Geometry::Tessellate
.
I have extracted this part of the code, exposed the triangulation interface, and then used OpenGL rendering in libpag.
// SkPath.h
int toAATriangles(float tolerance, const SkRect& clipBounds, std::vector<float>* vertex) const;
// SkPath.cpp
int SkPath::toAATriangles(float tolerance,
const SkRect& clipBounds,
std::vector<float>* vertex) const {
return GrAATriangulator::PathToAATriangles(*this, tolerance, clipBounds, vertex);
}
https://github.com/libpag/pathkit/blob/5bf0bc2acf8dbd74efb5713627de144a8f1ef2b1/include/core/SkPath.h#L898 https://github.com/libpag/pathkit/blob/5bf0bc2acf8dbd74efb5713627de144a8f1ef2b1/src/core/SkPath.cpp#L2453
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With