Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | Private Member Functions | List of all members
GrAATriangulator Class Reference

#include <GrAATriangulator.h>

Inheritance diagram for GrAATriangulator:
GrTriangulator

Classes

struct  Event
 
struct  EventComparator
 
struct  EventList
 
struct  SSEdge
 

Static Public Member Functions

static int PathToAATriangles (const SkPath &path, SkScalar tolerance, const SkRect &clipBounds, GrEagerVertexAllocator *vertexAllocator)
 

Private Member Functions

std::tuple< Poly *, bool > tessellate (const VertexList &mesh, const Comparator &) override
 

Detailed Description

Definition at line 27 of file GrAATriangulator.h.

Member Function Documentation

◆ PathToAATriangles()

static int GrAATriangulator::PathToAATriangles ( const SkPath path,
SkScalar  tolerance,
const SkRect clipBounds,
GrEagerVertexAllocator vertexAllocator 
)
inlinestatic

Definition at line 29 of file GrAATriangulator.h.

30 {
32 GrAATriangulator aaTriangulator(path, &alloc);
33 aaTriangulator.fRoundVerticesToQuarterPixel = true;
34 aaTriangulator.fEmitCoverage = true;
35 bool isLinear;
36 auto [ polys, success ] = aaTriangulator.pathToPolys(tolerance, clipBounds, &isLinear);
37 if (!success) {
38 return 0;
39 }
40 return aaTriangulator.polysToAATriangles(polys, vertexAllocator);
41 }
static constexpr int kArenaDefaultChunkSize

◆ tessellate()

std::tuple< Poly *, bool > GrAATriangulator::tessellate ( const VertexList mesh,
const Comparator c 
)
overrideprivatevirtual

Reimplemented from GrTriangulator.

Definition at line 627 of file GrAATriangulator.cpp.

627 {
628 VertexList innerMesh;
629 this->extractBoundaries(mesh, &innerMesh, c);
630 SortMesh(&innerMesh, c);
631 SortMesh(&fOuterMesh, c);
632 this->mergeCoincidentVertices(&innerMesh, c);
633 bool was_complex = this->mergeCoincidentVertices(&fOuterMesh, c);
634 auto result = this->simplify(&innerMesh, c);
635 if (result == SimplifyResult::kFailed) {
636 return { nullptr, false };
637 }
638 was_complex = (SimplifyResult::kFoundSelfIntersection == result) || was_complex;
639 result = this->simplify(&fOuterMesh, c);
640 if (result == SimplifyResult::kFailed) {
641 return { nullptr, false };
642 }
643 was_complex = (SimplifyResult::kFoundSelfIntersection == result) || was_complex;
644 TESS_LOG("\ninner mesh before:\n");
645 DUMP_MESH(innerMesh);
646 TESS_LOG("\nouter mesh before:\n");
647 DUMP_MESH(fOuterMesh);
650 was_complex = this->collapseOverlapRegions(&innerMesh, c, eventLT) || was_complex;
651 was_complex = this->collapseOverlapRegions(&fOuterMesh, c, eventGT) || was_complex;
652 if (was_complex) {
653 TESS_LOG("found complex mesh; taking slow path\n");
654 VertexList aaMesh;
655 TESS_LOG("\ninner mesh after:\n");
656 DUMP_MESH(innerMesh);
657 TESS_LOG("\nouter mesh after:\n");
658 DUMP_MESH(fOuterMesh);
659 this->connectPartners(&fOuterMesh, c);
660 this->connectPartners(&innerMesh, c);
661 SortedMerge(&innerMesh, &fOuterMesh, &aaMesh, c);
662 TESS_LOG("\nmerged mesh:\n");
663 DUMP_MESH(aaMesh);
664 this->mergeCoincidentVertices(&aaMesh, c);
665 result = this->simplify(&aaMesh, c);
666 if (result == SimplifyResult::kFailed) {
667 return { nullptr, false };
668 }
669 TESS_LOG("combined and simplified mesh:\n");
670 DUMP_MESH(aaMesh);
671 fOuterMesh.fHead = fOuterMesh.fTail = nullptr;
672 return this->GrTriangulator::tessellate(aaMesh, c);
673 } else {
674 TESS_LOG("no complex polygons; taking fast path\n");
675 return this->GrTriangulator::tessellate(innerMesh, c);
676 }
677}
#define DUMP_MESH(MESH)
#define TESS_LOG(...)
static void SortMesh(VertexList *vertices, const Comparator &)
SimplifyResult simplify(VertexList *mesh, const Comparator &)
virtual std::tuple< Poly *, bool > tessellate(const VertexList &vertices, const Comparator &)
static void SortedMerge(VertexList *front, VertexList *back, VertexList *result, const Comparator &)
bool mergeCoincidentVertices(VertexList *mesh, const Comparator &) const
GAsyncResult * result

The documentation for this class was generated from the following files: