Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrInnerFanTriangulator.h
Go to the documentation of this file.
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 "include/core/SkRect.h"
13
14#include <utility>
15
17class SkArenaAlloc;
18class SkPath;
19
20#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
21
22// Triangulates the inner polygon(s) of a path (i.e., the triangle fan for a Redbook rendering
23// method). When combined with the outer curves and breadcrumb triangles, these produce a complete
24// path. If a breadcrumbCollector is not provided, pathToPolys fails upon self intersection.
26public:
28
30 : GrTriangulator(path, alloc) {
33 }
34
36 bool* isLinear) {
37 Poly* polys = this->pathToPolys(breadcrumbList, isLinear);
38 return this->polysToTriangles(polys, vertexAlloc, breadcrumbList);
39 }
40
41 Poly* pathToPolys(BreadcrumbTriangleList* breadcrumbList, bool* isLinear) {
42 auto [ polys, success ] = this->GrTriangulator::pathToPolys(0, SkRect::MakeEmpty(),
43 isLinear);
44 if (!success) {
45 return nullptr;
46 }
47 breadcrumbList->concat(std::move(fBreadcrumbList));
48 return polys;
49 }
50
52 BreadcrumbTriangleList* breadcrumbList) const {
53 int vertexCount = this->GrTriangulator::polysToTriangles(polys, vertexAlloc);
54 breadcrumbList->concat(std::move(fBreadcrumbList));
55 return vertexCount;
56 }
57};
58
59#else
60
61// Stub out GrInnerFanTriangulator::BreadcrumbTriangleList for function declarations.
62namespace GrInnerFanTriangulator {
63 struct BreadcrumbTriangleList {
64 BreadcrumbTriangleList() = delete;
65 };
66};
67
68#endif // SK_ENABLE_OPTIMIZE_SIZE
69
70#endif // GrInnerFanTriangulator_DEFINED
int pathToTriangles(GrEagerVertexAllocator *vertexAlloc, BreadcrumbTriangleList *breadcrumbList, bool *isLinear)
Poly * pathToPolys(BreadcrumbTriangleList *breadcrumbList, bool *isLinear)
GrInnerFanTriangulator(const SkPath &path, SkArenaAlloc *alloc)
int polysToTriangles(Poly *polys, GrEagerVertexAllocator *vertexAlloc, BreadcrumbTriangleList *breadcrumbList) const
void concat(BreadcrumbTriangleList &&list)
std::tuple< Poly *, bool > pathToPolys(float tolerance, const SkRect &clipBounds, bool *isLinear)
bool fPreserveCollinearVertices
bool fCollectBreadcrumbTriangles
BreadcrumbTriangleList fBreadcrumbList
skgpu::VertexWriter polysToTriangles(Poly *polys, SkPathFillType overrideFillType, skgpu::VertexWriter data) const
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595