Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
skiagm::MandolineSlicer Class Reference

Public Member Functions

 MandolineSlicer (SkPoint anchorPt)
 
void reset (SkPoint anchorPt)
 
void sliceLine (SkPoint pt, int numSubdivisions=kDefaultSubdivisions)
 
void sliceQuadratic (SkPoint p1, SkPoint p2, int numSubdivisions=kDefaultSubdivisions)
 
void sliceCubic (SkPoint p1, SkPoint p2, SkPoint p3, int numSubdivisions=kDefaultSubdivisions)
 
void sliceConic (SkPoint p1, SkPoint p2, float w, int numSubdivisions=kDefaultSubdivisions)
 
const SkPathpath () const
 

Static Public Attributes

static constexpr int kDefaultSubdivisions = 10
 

Detailed Description

Definition at line 26 of file mandoline.cpp.

Constructor & Destructor Documentation

◆ MandolineSlicer()

skiagm::MandolineSlicer::MandolineSlicer ( SkPoint  anchorPt)
inline

Definition at line 30 of file mandoline.cpp.

30 {
32 fPath.setIsVolatile(true);
33 this->reset(anchorPt);
34 }
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & setIsVolatile(bool isVolatile)
Definition: SkPath.h:370
void reset(SkPoint anchorPt)
Definition: mandoline.cpp:36

Member Function Documentation

◆ path()

const SkPath & skiagm::MandolineSlicer::path ( ) const
inline

Definition at line 119 of file mandoline.cpp.

119{ return fPath; }

◆ reset()

void skiagm::MandolineSlicer::reset ( SkPoint  anchorPt)
inline

Definition at line 36 of file mandoline.cpp.

36 {
37 fPath.reset();
38 fLastPt = fAnchorPt = anchorPt;
39 }
SkPath & reset()
Definition: SkPath.cpp:370

◆ sliceConic()

void skiagm::MandolineSlicer::sliceConic ( SkPoint  p1,
SkPoint  p2,
float  w,
int  numSubdivisions = kDefaultSubdivisions 
)
inline

Definition at line 98 of file mandoline.cpp.

98 {
99 if (numSubdivisions <= 0) {
100 fPath.moveTo(fAnchorPt);
101 fPath.lineTo(fLastPt);
102 fPath.conicTo(p1, p2, w);
103 fPath.close();
104 fLastPt = p2;
105 return;
106 }
107 float T = this->chooseChopT(numSubdivisions);
108 if (0 == T) {
109 return;
110 }
111 SkConic conic(fLastPt, p1, p2, w), halves[2];
112 if (!conic.chopAt(T, halves)) {
113 SK_ABORT("SkConic::chopAt failed");
114 }
115 this->sliceConic(halves[0].fPts[1], halves[0].fPts[2], halves[0].fW, numSubdivisions - 1);
116 this->sliceConic(halves[1].fPts[1], halves[1].fPts[2], halves[1].fW, numSubdivisions - 1);
117 }
SkPoint fPts[2]
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition: SkPath.cpp:766
SkPath & close()
Definition: SkPath.cpp:823
void sliceConic(SkPoint p1, SkPoint p2, float w, int numSubdivisions=kDefaultSubdivisions)
Definition: mandoline.cpp:98
AI float conic(float tolerance, const SkPoint pts[], float w, const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:287
SkScalar w
#define T
Definition: precompiler.cc:65

◆ sliceCubic()

void skiagm::MandolineSlicer::sliceCubic ( SkPoint  p1,
SkPoint  p2,
SkPoint  p3,
int  numSubdivisions = kDefaultSubdivisions 
)
inline

Definition at line 78 of file mandoline.cpp.

79 {
80 if (numSubdivisions <= 0) {
81 fPath.moveTo(fAnchorPt);
82 fPath.lineTo(fLastPt);
83 fPath.cubicTo(p1, p2, p3);
84 fPath.close();
85 fLastPt = p3;
86 return;
87 }
88 float T = this->chooseChopT(numSubdivisions);
89 if (0 == T) {
90 return;
91 }
92 SkPoint P[4] = {fLastPt, p1, p2, p3}, PP[7];
94 this->sliceCubic(PP[1], PP[2], PP[3], numSubdivisions - 1);
95 this->sliceCubic(PP[4], PP[5], PP[6], numSubdivisions - 1);
96 }
void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t)
Definition: SkGeometry.cpp:473
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799
void sliceCubic(SkPoint p1, SkPoint p2, SkPoint p3, int numSubdivisions=kDefaultSubdivisions)
Definition: mandoline.cpp:78
const Register PP

◆ sliceLine()

void skiagm::MandolineSlicer::sliceLine ( SkPoint  pt,
int  numSubdivisions = kDefaultSubdivisions 
)
inline

Definition at line 41 of file mandoline.cpp.

41 {
42 if (numSubdivisions <= 0) {
43 fPath.moveTo(fAnchorPt);
44 fPath.lineTo(fLastPt);
45 fPath.lineTo(pt);
46 fPath.close();
47 fLastPt = pt;
48 return;
49 }
50 float T = this->chooseChopT(numSubdivisions);
51 if (0 == T) {
52 return;
53 }
54 SkPoint midpt = fLastPt * (1 - T) + pt * T;
55 this->sliceLine(midpt, numSubdivisions - 1);
56 this->sliceLine(pt, numSubdivisions - 1);
57 }
void sliceLine(SkPoint pt, int numSubdivisions=kDefaultSubdivisions)
Definition: mandoline.cpp:41

◆ sliceQuadratic()

void skiagm::MandolineSlicer::sliceQuadratic ( SkPoint  p1,
SkPoint  p2,
int  numSubdivisions = kDefaultSubdivisions 
)
inline

Definition at line 59 of file mandoline.cpp.

59 {
60 if (numSubdivisions <= 0) {
61 fPath.moveTo(fAnchorPt);
62 fPath.lineTo(fLastPt);
63 fPath.quadTo(p1, p2);
64 fPath.close();
65 fLastPt = p2;
66 return;
67 }
68 float T = this->chooseChopT(numSubdivisions);
69 if (0 == T) {
70 return;
71 }
72 SkPoint P[3] = {fLastPt, p1, p2}, PP[5];
73 SkChopQuadAt(P, PP, T);
74 this->sliceQuadratic(PP[1], PP[2], numSubdivisions - 1);
75 this->sliceQuadratic(PP[3], PP[4], numSubdivisions - 1);
76 }
void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t)
Definition: SkGeometry.cpp:175
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746
void sliceQuadratic(SkPoint p1, SkPoint p2, int numSubdivisions=kDefaultSubdivisions)
Definition: mandoline.cpp:59

Member Data Documentation

◆ kDefaultSubdivisions

constexpr int skiagm::MandolineSlicer::kDefaultSubdivisions = 10
inlinestaticconstexpr

Definition at line 28 of file mandoline.cpp.


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