'How to obtain mesh from Skia path geometry?

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.



Solution 1:[1]

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/main/include/core/SkPath.h#L898 https://github.com/libpag/pathkit/blob/main/src/core/SkPath.cpp#L2453

Solution 2:[2]

As I've checked into Skia source tesselation from path into triangles goes on automatically in the rendering step, before pushing video buffer into GPU pipeline. So you don't need to worry about that, library takes care itself. Unless you want explicitly get the output of tessellation step, but I doubt that this API is exported for the user. Probably it is hidden from the library user.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ???
Solution 2 Agnius Vasiliauskas