Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SkDCurve Struct Reference

#include <SkPathOpsCurve.h>

Public Member Functions

 SkDEBUGCODE (SkPath::Verb fVerb;) const SkDPoint &operator[](int n) const
 
SkDPointoperator[] (int n)
 
SkDPoint conicTop (const SkPoint curve[3], SkScalar curveWeight, double s, double e, double *topT)
 
SkDPoint cubicTop (const SkPoint curve[4], SkScalar, double s, double e, double *topT)
 
void dump () const
 
void dumpID (int) const
 
SkDPoint lineTop (const SkPoint[2], SkScalar, double, double, double *topT)
 
double nearPoint (SkPath::Verb verb, const SkDPoint &xy, const SkDPoint &opp) const
 
SkDPoint quadTop (const SkPoint curve[3], SkScalar, double s, double e, double *topT)
 
void setConicBounds (const SkPoint curve[3], SkScalar curveWeight, double s, double e, SkPathOpsBounds *)
 
void setCubicBounds (const SkPoint curve[4], SkScalar, double s, double e, SkPathOpsBounds *)
 
void setQuadBounds (const SkPoint curve[3], SkScalar, double s, double e, SkPathOpsBounds *)
 

Public Attributes

union { 
 
   SkDLine   fLine 
 
   SkDQuad   fQuad 
 
   SkDConic   fConic 
 
   SkDCubic   fCubic 
 
};  
 

Detailed Description

Definition at line 55 of file SkPathOpsCurve.h.

Member Function Documentation

◆ conicTop()

SkDPoint SkDCurve::conicTop ( const SkPoint  curve[3],
SkScalar  curveWeight,
double  s,
double  e,
double *  topT 
)

◆ cubicTop()

SkDPoint SkDCurve::cubicTop ( const SkPoint  curve[4],
SkScalar  ,
double  s,
double  e,
double *  topT 
)

◆ dump()

void SkDCurve::dump ( ) const

Definition at line 136 of file PathOpsDebug.cpp.

136 {
137 dumpID(-1);
138}
void dumpID(int) const

◆ dumpID()

void SkDCurve::dumpID ( int  id) const

Definition at line 140 of file PathOpsDebug.cpp.

140 {
141#ifndef SK_RELEASE
142 switch(fVerb) {
144 fLine.dumpID(id);
145 break;
147 fQuad.dumpID(id);
148 break;
150 fConic.dumpID(id);
151 break;
153 fCubic.dumpID(id);
154 break;
155 default:
156 SkASSERT(0);
157 }
158#else
159 fCubic.dumpID(id);
160#endif
161}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kConic_Verb
Definition SkPath.h:1461
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459
void dumpID(int id) const
void dumpID(int id) const
SkDQuad fQuad
SkDConic fConic
SkDLine fLine
SkDCubic fCubic
void dumpID(int) const
void dumpID(int id) const

◆ lineTop()

SkDPoint SkDCurve::lineTop ( const SkPoint  [2],
SkScalar  ,
double  ,
double  ,
double *  topT 
)

◆ nearPoint()

double SkDCurve::nearPoint ( SkPath::Verb  verb,
const SkDPoint xy,
const SkDPoint opp 
) const

Definition at line 18 of file SkPathOpsCurve.cpp.

18 {
19 int count = SkPathOpsVerbToPoints(verb);
20 double minX = fCubic.fPts[0].fX;
21 double maxX = minX;
22 for (int index = 1; index <= count; ++index) {
23 minX = std::min(minX, fCubic.fPts[index].fX);
24 maxX = std::max(maxX, fCubic.fPts[index].fX);
25 }
26 if (!AlmostBetweenUlps(minX, xy.fX, maxX)) {
27 return -1;
28 }
29 double minY = fCubic.fPts[0].fY;
30 double maxY = minY;
31 for (int index = 1; index <= count; ++index) {
32 minY = std::min(minY, fCubic.fPts[index].fY);
33 maxY = std::max(maxY, fCubic.fPts[index].fY);
34 }
35 if (!AlmostBetweenUlps(minY, xy.fY, maxY)) {
36 return -1;
37 }
39 SkDLine perp = {{ xy, { xy.fX + opp.fY - xy.fY, xy.fY + xy.fX - opp.fX }}};
40 (*CurveDIntersectRay[verb])(*this, perp, &i);
41 int minIndex = -1;
42 double minDist = FLT_MAX;
43 for (int index = 0; index < i.used(); ++index) {
44 double dist = xy.distance(i.pt(index));
45 if (minDist > dist) {
46 minDist = dist;
47 minIndex = index;
48 }
49 }
50 if (minIndex < 0) {
51 return -1;
52 }
53 double largest = std::max(std::max(maxX, maxY), -std::min(minX, minY));
54 if (!AlmostEqualUlps_Pin(largest, largest + minDist)) { // is distance within ULPS tolerance?
55 return -1;
56 }
57 return SkPinT(i[0][minIndex]);
58}
int count
static void(*const CurveDIntersectRay[])(const SkDCurve &, const SkDLine &, SkIntersections *)
bool AlmostEqualUlps_Pin(float a, float b)
bool AlmostBetweenUlps(float a, float b, float c)
double SkPinT(double t)
int SkPathOpsVerbToPoints(SkPath::Verb verb)
const SkDPoint & pt(int index) const
SkDPoint fPts[kPointCount]
double distance(const SkDPoint &a) const

◆ operator[]()

SkDPoint & SkDCurve::operator[] ( int  n)
inline

Definition at line 69 of file SkPathOpsCurve.h.

69 {
70 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
71 return fCubic[n];
72 }

◆ quadTop()

SkDPoint SkDCurve::quadTop ( const SkPoint  curve[3],
SkScalar  ,
double  s,
double  e,
double *  topT 
)

◆ setConicBounds()

void SkDCurve::setConicBounds ( const SkPoint  curve[3],
SkScalar  curveWeight,
double  s,
double  e,
SkPathOpsBounds bounds 
)

Definition at line 60 of file SkPathOpsCurve.cpp.

61 {
62 SkDConic dCurve;
63 dCurve.set(curve, curveWeight);
64 SkDRect dRect;
65 dRect.setBounds(dCurve, fConic, tStart, tEnd);
66 bounds->setLTRB(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop),
68}
#define SkDoubleToScalar(x)
Definition SkScalar.h:64
Optional< SkRect > bounds
Definition SkRecords.h:189
const SkDConic & set(const SkPoint pts[kPointCount], SkScalar weight SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))
double fTop
double fRight
double fBottom
void setBounds(const SkDConic &curve)
double fLeft

◆ setCubicBounds()

void SkDCurve::setCubicBounds ( const SkPoint  curve[4],
SkScalar  ,
double  s,
double  e,
SkPathOpsBounds bounds 
)

Definition at line 70 of file SkPathOpsCurve.cpp.

71 {
72 SkDCubic dCurve;
73 dCurve.set(curve);
74 SkDRect dRect;
75 dRect.setBounds(dCurve, fCubic, tStart, tEnd);
76 bounds->setLTRB(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop),
78}
const SkDCubic & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))

◆ setQuadBounds()

void SkDCurve::setQuadBounds ( const SkPoint  curve[3],
SkScalar  ,
double  s,
double  e,
SkPathOpsBounds bounds 
)

Definition at line 80 of file SkPathOpsCurve.cpp.

81 {
82 SkDQuad dCurve;
83 dCurve.set(curve);
84 SkDRect dRect;
85 dRect.setBounds(dCurve, fQuad, tStart, tEnd);
86 bounds->setLTRB(SkDoubleToScalar(dRect.fLeft), SkDoubleToScalar(dRect.fTop),
88}
const SkDQuad & set(const SkPoint pts[kPointCount] SkDEBUGPARAMS(SkOpGlobalState *state=nullptr))

◆ SkDEBUGCODE()

SkDCurve::SkDEBUGCODE ( SkPath::Verb fVerb;  ) const &
inline

Definition at line 62 of file SkPathOpsCurve.h.

64 {
65 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
66 return fCubic[n];
67 }

Member Data Documentation

◆ [union]

union { ... } SkDCurve

◆ fConic

SkDConic SkDCurve::fConic

Definition at line 59 of file SkPathOpsCurve.h.

◆ fCubic

SkDCubic SkDCurve::fCubic

Definition at line 60 of file SkPathOpsCurve.h.

◆ fLine

SkDLine SkDCurve::fLine

Definition at line 57 of file SkPathOpsCurve.h.

◆ fQuad

SkDQuad SkDCurve::fQuad

Definition at line 58 of file SkPathOpsCurve.h.


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