Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
SkDCurveSweep Class Reference

#include <SkPathOpsCurve.h>

Public Member Functions

bool isCurve () const
 
bool isOrdered () const
 
void setCurveHullSweep (SkPath::Verb verb)
 

Public Attributes

SkDCurve fCurve
 
SkDVector fSweep [2]
 

Detailed Description

Definition at line 91 of file SkPathOpsCurve.h.

Member Function Documentation

◆ isCurve()

bool SkDCurveSweep::isCurve ( ) const
inline

Definition at line 93 of file SkPathOpsCurve.h.

93{ return fIsCurve; }

◆ isOrdered()

bool SkDCurveSweep::isOrdered ( ) const
inline

Definition at line 94 of file SkPathOpsCurve.h.

94{ return fOrdered; }

◆ setCurveHullSweep()

void SkDCurveSweep::setCurveHullSweep ( SkPath::Verb  verb)

Definition at line 90 of file SkPathOpsCurve.cpp.

90 {
91 fOrdered = true;
92 fSweep[0] = fCurve[1] - fCurve[0];
93 if (SkPath::kLine_Verb == verb) {
94 fSweep[1] = fSweep[0];
95 fIsCurve = false;
96 return;
97 }
98 fSweep[1] = fCurve[2] - fCurve[0];
99 // OPTIMIZE: I do the following float check a lot -- probably need a
100 // central place for this val-is-small-compared-to-curve check
101 double maxVal = 0;
102 for (int index = 0; index <= SkPathOpsVerbToPoints(verb); ++index) {
103 maxVal = std::max(maxVal, std::max(SkTAbs(fCurve[index].fX),
104 SkTAbs(fCurve[index].fY)));
105 }
106 {
107 if (SkPath::kCubic_Verb != verb) {
108 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal)
109 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) {
110 fSweep[0] = fSweep[1];
111 }
112 goto setIsCurve;
113 }
114 SkDVector thirdSweep = fCurve[3] - fCurve[0];
115 if (fSweep[0].fX == 0 && fSweep[0].fY == 0) {
116 fSweep[0] = fSweep[1];
117 fSweep[1] = thirdSweep;
118 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal)
119 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) {
120 fSweep[0] = fSweep[1];
121 fCurve[1] = fCurve[3];
122 }
123 goto setIsCurve;
124 }
125 double s1x3 = fSweep[0].crossCheck(thirdSweep);
126 double s3x2 = thirdSweep.crossCheck(fSweep[1]);
127 if (s1x3 * s3x2 >= 0) { // if third vector is on or between first two vectors
128 goto setIsCurve;
129 }
130 double s2x1 = fSweep[1].crossCheck(fSweep[0]);
131 // FIXME: If the sweep of the cubic is greater than 180 degrees, we're in trouble
132 // probably such wide sweeps should be artificially subdivided earlier so that never happens
133 SkASSERT(s1x3 * s2x1 < 0 || s1x3 * s3x2 < 0);
134 if (s3x2 * s2x1 < 0) {
135 SkASSERT(s2x1 * s1x3 > 0);
136 fSweep[0] = fSweep[1];
137 fOrdered = false;
138 }
139 fSweep[1] = thirdSweep;
140 }
141setIsCurve:
142 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0;
143}
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool roughly_zero_when_compared_to(double x, double y)
int SkPathOpsVerbToPoints(SkPath::Verb verb)
static T SkTAbs(T value)
Definition: SkTemplates.h:43
SkDVector fSweep[2]
SkDCurve fCurve
@ kCubic_Verb
Definition: SkPath.h:1470
@ kLine_Verb
Definition: SkPath.h:1467
static float max(float r, float g, float b)
Definition: hsl.cpp:49
double crossCheck(const SkDVector &a) const

Member Data Documentation

◆ fCurve

SkDCurve SkDCurveSweep::fCurve

Definition at line 97 of file SkPathOpsCurve.h.

◆ fSweep

SkDVector SkDCurveSweep::fSweep[2]

Definition at line 98 of file SkPathOpsCurve.h.


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