| 1 | /* |
| 2 | * Copyright 2020 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrPathParser_DEFINED |
| 9 | #define GrPathParser_DEFINED |
| 10 | |
| 11 | #include "include/core/SkPath.h" |
| 12 | |
| 13 | class GrEagerVertexAllocator; |
| 14 | |
| 15 | namespace GrPathParser { |
| 16 | |
| 17 | // Writes an array of cubic "wedges" from an SkPath, converting any lines or quadratics to cubics. |
| 18 | // These wedges can then be fed into GrStencilWedgeShader to stencil the path. A wedge is a 5-point |
| 19 | // tessellation patch consisting of 4 cubic control points, plus an anchor point fanning from the |
| 20 | // center of the curve's resident contour. |
| 21 | // |
| 22 | // TODO: Eventually we want to use rational cubic wedges in order to support conics. |
| 23 | // |
| 24 | // Returns the number of vertices written to the array. |
| 25 | int EmitCenterWedgePatches(const SkPath&, GrEagerVertexAllocator*); |
| 26 | |
| 27 | // Triangulates and writes an SkPath's inner polygon(s). The inner polygons connect the endpoints of |
| 28 | // each verb. (i.e., they are the path that would result from collapsing all curves to single |
| 29 | // lines.) |
| 30 | // |
| 31 | // This method works by recursively subdividing the path rather than emitting a linear triangle fan |
| 32 | // or strip. This can reduce the load on the rasterizer by a great deal on complex paths. |
| 33 | // |
| 34 | // Returns the number of vertices written to the array. |
| 35 | int EmitInnerPolygonTriangles(const SkPath&, GrEagerVertexAllocator*); |
| 36 | |
| 37 | // Writes out an array of cubics from an SkPath as 4-point instances, converting any quadratics to |
| 38 | // cubics. |
| 39 | // |
| 40 | // Returns the number of *instances* written to the array. |
| 41 | int EmitCubicInstances(const SkPath&, GrEagerVertexAllocator*); |
| 42 | |
| 43 | } // namespace |
| 44 | |
| 45 | #endif |
| 46 | |