/src/skia/src/gpu/geometry/GrInnerFanTriangulator.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2021 Google LLC |
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 GrInnerFanTriangulator_DEFINED |
9 | | #define GrInnerFanTriangulator_DEFINED |
10 | | |
11 | | #include "src/gpu/geometry/GrTriangulator.h" |
12 | | |
13 | | // Triangulates the inner polygon(s) of a path (i.e., the triangle fan for a Redbook rendering |
14 | | // method). When combined with the outer curves and breadcrumb triangles, these produce a complete |
15 | | // path. If a breadcrumbCollector is not provided, pathToPolys fails upon self intersection. |
16 | | class GrInnerFanTriangulator : private GrTriangulator { |
17 | | public: |
18 | | using GrTriangulator::BreadcrumbTriangleList; |
19 | | |
20 | | GrInnerFanTriangulator(const SkPath& path, SkArenaAlloc* alloc) |
21 | 0 | : GrTriangulator(path, alloc) { |
22 | 0 | fPreserveCollinearVertices = true; |
23 | 0 | fCollectBreadcrumbTriangles = true; |
24 | 0 | } |
25 | | |
26 | | int pathToTriangles(GrEagerVertexAllocator* vertexAlloc, BreadcrumbTriangleList* breadcrumbList, |
27 | 0 | bool* isLinear) const { |
28 | 0 | Poly* polys = this->pathToPolys(breadcrumbList, isLinear); |
29 | 0 | return this->polysToTriangles(polys, vertexAlloc, breadcrumbList); |
30 | 0 | } |
31 | | |
32 | 0 | Poly* pathToPolys(BreadcrumbTriangleList* breadcrumbList, bool* isLinear) const { |
33 | 0 | Poly* polys = this->GrTriangulator::pathToPolys(0, SkRect::MakeEmpty(), isLinear); |
34 | 0 | breadcrumbList->concat(std::move(fBreadcrumbList)); |
35 | 0 | return polys; |
36 | 0 | } |
37 | | |
38 | | int polysToTriangles(Poly* polys, GrEagerVertexAllocator* vertexAlloc, |
39 | 0 | BreadcrumbTriangleList* breadcrumbList) const { |
40 | 0 | int vertexCount = this->GrTriangulator::polysToTriangles(polys, vertexAlloc); |
41 | 0 | breadcrumbList->concat(std::move(fBreadcrumbList)); |
42 | 0 | return vertexCount; |
43 | 0 | } |
44 | | }; |
45 | | |
46 | | #endif |