107 int last = fIntersections->
used() - 1;
108 for (
int index = 0; index < last; ) {
109 double cubicMidT = ((*fIntersections)[0][index] + (*fIntersections)[0][index + 1]) / 2;
111 double t = fLine.
nearPoint(cubicMidPt,
nullptr);
131 double adj = fLine[1].fX - fLine[0].fX;
132 double opp = fLine[1].fY - fLine[0].fY;
134 SkDEBUGCODE(c.fDebugGlobalState = fIntersections->globalState());
135 for (
int n = 0; n < 4; ++n) {
136 c[n].fX = (fCubic[n].fY - fLine[0].fY) * adj - (fCubic[n].fX - fLine[0].fX) * opp;
141 for (
int index = 0; index <
count; ++index) {
144 for (
int n = 0; n < 4; ++n) {
145 c[n].fY = (fCubic[n].fY - fLine[0].fY) * opp
146 + (fCubic[n].fX - fLine[0].fX) * adj;
164 for (
int index = 0; index <
roots; ++index) {
165 double cubicT = rootVals[index];
169 fIntersections->
insert(cubicT, lineT, pt);
173 return fIntersections->
used();
181 for (
int index = 0; index <
count; ++index) {
200 for (
int index = 0; index <
count; ++index) {
201 double cubicT =
roots[index];
205 fIntersections->
insert(cubicT, lineT, pt);
209 fIntersections->
flip();
212 return fIntersections->
used();
216 for (
int inner = 0; inner < fIntersections->
used(); ++inner) {
217 if (fIntersections->
pt(inner) != pt) {
220 double existingCubicT = (*fIntersections)[0][inner];
221 if (cubicT == existingCubicT) {
225 double cubicMidT = (existingCubicT + cubicT) / 2;
233 SkDebugf(
"%s pt=(%1.9g,%1.9g) cPt=(%1.9g,%1.9g)\n", __FUNCTION__, pt.
fX, pt.
fY,
244 for (
int index = 0; index <
count; ++index) {
263 for (
int index = 0; index <
count; ++index) {
264 double cubicT =
roots[index];
266 double lineT = (pt.
fY - top) / (bottom - top);
268 fIntersections->
insert(cubicT, lineT, pt);
272 fIntersections->
flip();
275 return fIntersections->
used();
281 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
282 double lineT = fLine.
exactPoint(fCubic[cIndex]);
286 double cubicT = (double) (cIndex >> 1);
287 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
294 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
295 double cubicT = (double) (cIndex >> 1);
296 if (fIntersections->
hasT(cubicT)) {
299 double lineT = fLine.
nearPoint(fCubic[cIndex],
nullptr);
303 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
309 for (
int lIndex = 0; lIndex < 2; ++lIndex) {
310 double lineT = (double) lIndex;
311 if (fIntersections->
hasOppT(lineT)) {
314 double cubicT = ((
const SkDCurve*)&fCubic)
319 fIntersections->
insert(cubicT, lineT, fLine[lIndex]);
324 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
329 double cubicT = (double) (cIndex >> 1);
330 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
335 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
336 double cubicT = (double) (cIndex >> 1);
337 if (fIntersections->
hasT(cubicT)) {
344 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
350 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
355 double cubicT = (double) (cIndex >> 1);
356 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
361 for (
int cIndex = 0; cIndex < 4; cIndex += 3) {
362 double cubicT = (double) (cIndex >> 1);
363 if (fIntersections->
hasT(cubicT)) {
370 fIntersections->
insert(cubicT, lineT, fCubic[cIndex]);
377 double dx = fLine[1].fX - fLine[0].fX;
378 double dy = fLine[1].fY - fLine[0].fY;
379 if (fabs(
dx) > fabs(dy)) {
380 return (xy.
fX - fLine[0].fX) /
dx;
382 return (xy.
fY - fLine[0].fY) / dy;
392 double cT = *cubicT =
SkPinT(*cubicT);
393 double lT = *lineT =
SkPinT(*lineT);
407 if (gridPt == fLine[0].asSkPoint()) {
409 }
else if (gridPt == fLine[1].asSkPoint()) {
450 for (
int index = 0; index < fUsed; ++index) {
451 fPt[index] =
cubic.ptAtT(fT[0][index]);
static bool approximately_zero(double x)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool approximately_equal(double x, double y)
bool approximately_one_or_less(double x)
bool approximately_zero_or_more(double x)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
void addExactVerticalEndPoints(double top, double bottom, double x)
void addNearHorizontalEndPoints(double left, double right, double y)
void addLineNearEndPoints()
void addNearVerticalEndPoints(double top, double bottom, double x)
bool pinTs(double *cubicT, double *lineT, SkDPoint *pt, PinTPoint ptSet)
int intersectRay(double roots[3])
LineCubicIntersections(const SkDCubic &c, const SkDLine &l, SkIntersections *i)
static int VerticalIntersect(const SkDCubic &c, double axisIntercept, double roots[3])
static int HorizontalIntersect(const SkDCubic &c, double axisIntercept, double roots[3])
void addExactHorizontalEndPoints(double left, double right, double y)
int horizontalIntersect(double axisIntercept, double left, double right, bool flipped)
int verticalIntersect(double axisIntercept, double top, double bottom, bool flipped)
bool uniqueAnswer(double cubicT, const SkDPoint &pt)
double findLineT(double t)
void allowNear(bool allow)
int intersectRay(const SkDLine &, const SkDLine &)
int insert(double one, double two, const SkDPoint &pt)
int intersect(const SkDLine &, const SkDLine &)
void removeOne(int index)
const SkDPoint & pt(int index) const
int vertical(const SkDLine &, double top, double bottom, double x, bool flipped)
bool hasOppT(double t) const
bool hasT(double t) const
void setCoincident(int index)
int horizontal(const SkDLine &, double left, double right, double y, bool flipped)
bool isCoincident(int index)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
int horizontalIntersect(double yIntercept, double roots[3]) const
int verticalIntersect(double xIntercept, double roots[3]) const
static int FindExtrema(const double src[], double tValue[2])
static void Coefficients(const double *cubic, double *A, double *B, double *C, double *D)
int searchRoots(double extremes[6], int extrema, double axisIntercept, SearchAxis xAxis, double *validRoots) const
static int RootsValidT(const double A, const double B, const double C, double D, double s[3])
SkDPoint ptAtT(double t) const
double exactPoint(const SkDPoint &xy) const
static double ExactPointV(const SkDPoint &xy, double top, double bottom, double x)
SkDPoint ptAtT(double t) const
static double NearPointH(const SkDPoint &xy, double left, double right, double y)
static double NearPointV(const SkDPoint &xy, double top, double bottom, double x)
static double ExactPointH(const SkDPoint &xy, double left, double right, double y)
double nearPoint(const SkDPoint &xy, bool *unequal) const
bool approximatelyEqual(const SkDPoint &a) const
SkPoint asSkPoint() const
bool roughlyEqual(const SkDPoint &a) const