主权项 |
1. A method comprising:
receiving, with a graphics processing unit (GPU), data indicative of a first path segment of a first path to be rendered and a second path segment of a second path to be rendered, the first path segment and the second path segment comprising respective two-dimensional vector graphics paths; tessellating, with the GPU, the first path segment into a first plurality of primitives and the second path segment into a second plurality of primitives; rendering, with the GPU, a fill area for the first path segment based on the first plurality of primitives, wherein the first plurality of primitives comprises a first plurality of line segments, and wherein rendering the fill area comprises:
generating, with the GPU, a first plurality of triangle primitives based on the first plurality of line segments, each of the first plurality of triangle primitives being generated based on a respective one of the first plurality of line segments;rendering, with the GPU, each of the first plurality of triangle primitives into a common stencil buffer such that the common stencil buffer stores data indicative of which pixels are inside of the fill area for the first path segment; andrendering, with the GPU, one or more first primitives that encompass the pixels that are inside of the fill area based on the data stored in the common stencil buffer and a fill color to generate a rasterized version of the fill area for the first path segment; and rendering, with the GPU, a stroke area for the second path segment based on the second plurality of primitives comprises a second plurality of line segments, and wherein rendering the stroke area comprises:
fattening, with a geometry shader of the GPU, the second plurality of line segments by shifting endpoints of the second plurality of line segments in positive and negative normal directions;generating, with the geometry shader of the GPU, a triangulation of the stroke area creating a second plurality of triangle primitives; andrendering, with the GPU, the second plurality of triangle primitives, wherein rendering comprises correcting overlapping portions of rendered second plurality of triangle primitives using a depth test, and the depth test configured to use data stored in the common stencil buffer without allocating a separate depth buffer. |