Searched defs:approximately_equal (Results 1 - 8 of 8) sorted by relevance

/external/chromium_org/third_party/skia/src/utils/win/
H A DSkDWriteGeometrySink.cpp80 static bool approximately_equal(float a, float b) { function
94 //NOTE: !approximately_equal(midX - cubic[3].x, dx23 * 3 / 2)
96 if (!approximately_equal(midX, (dx23 * 3 / 2) + cubic[3].x)) {
102 if (!approximately_equal(midY, (dy23 * 3 / 2) + cubic[3].y)) {
/external/skia/src/utils/win/
H A DSkDWriteGeometrySink.cpp80 static bool approximately_equal(float a, float b) { function
94 //NOTE: !approximately_equal(midX - cubic[3].x, dx23 * 3 / 2)
96 if (!approximately_equal(midX, (dx23 * 3 / 2) + cubic[3].x)) {
102 if (!approximately_equal(midY, (dy23 * 3 / 2) + cubic[3].y)) {
/external/chromium_org/third_party/skia/experimental/Intersection/
H A DDataTypes.h88 inline bool approximately_equal(double x, double y) { function
119 return approximately_equal(x, y);
280 // return approximately_equal(a.y, y) && approximately_equal(a.x, x);
288 return approximately_equal(x * inv, a.x * inv) && approximately_equal(y * inv, a.y * inv);
297 return approximately_equal(x * inv, a.fX * inv) && approximately_equal(y * inv, a.fY * inv);
/external/chromium_org/third_party/skia/src/pathops/
H A DSkPathOpsTypes.h155 inline bool approximately_equal(double x, double y) { function
180 return approximately_equal(x, y);
H A DSkOpAngle.cpp309 if (!approximately_equal(oSpan.fOtherT, span.fT)) {
146 SkASSERT(trOrder < 0); SkDEBUGCODE(bool lrOpposite = lh.oppositePlanes(rh)); bool ltOpposite = lh.oppositePlanes(*this); SkASSERT(lrOpposite != ltOpposite); return COMPARE_RESULT(8, ltOpposite); } else if (ltOrder == 1 && trOrder == 0) { SkASSERT(lrOrder < 0); SkDEBUGCODE(bool ltOpposite = lh.oppositePlanes(*this)); bool trOpposite = oppositePlanes(rh); SkASSERT(ltOpposite != trOpposite); return COMPARE_RESULT(9, trOpposite); } else if (lrOrder == 1 && trOrder == 1) { SkASSERT(ltOrder < 0); SkDEBUGCODE(bool trOpposite = oppositePlanes(rh)); bool lrOpposite = lh.oppositePlanes(rh); SkASSERT(lrOpposite != trOpposite); return COMPARE_RESULT(10, lrOpposite); } if (lrOrder < 0) { if (ltOrder < 0) { return COMPARE_RESULT(11, trOrder); } return COMPARE_RESULT(12, ltOrder); } return COMPARE_RESULT(13, !lrOrder); } int SkOpAngle::allOnOneSide(const SkOpAngle& test) const { SkASSERT(!fIsCurve); SkASSERT(test.fIsCurve); const SkDPoint& origin = test.fCurvePart[0]; SkVector line; if (fSegment->verb() == SkPath::kLine_Verb) { const SkPoint* linePts = fSegment->pts(); int lineStart = fStart < fEnd ? 0 : 1; line = linePts[lineStart ^ 1] - linePts[lineStart]; } else { SkPoint shortPts[2] = { fCurvePart[0].asSkPoint(), fCurvePart[1].asSkPoint() }; line = shortPts[1] - shortPts[0]; } float crosses[3]; SkPath::Verb testVerb = test.fSegment->verb(); int iMax = SkPathOpsVerbToPoints(testVerb); const SkDCubic& testCurve = test.fCurvePart; for (int index = 1; index <= iMax; ++index) { float xy1 = (float) (line.fX * (testCurve[index].fY - origin.fY)); float xy2 = (float) (line.fY * (testCurve[index].fX - origin.fX)); crosses[index - 1] = AlmostEqualUlps(xy1, xy2) ? 0 : xy1 - xy2; } if (crosses[0] * crosses[1] < 0) { return -1; } if (SkPath::kCubic_Verb == testVerb) { if (crosses[0] * crosses[2] < 0 || crosses[1] * crosses[2] < 0) { return -1; } } if (crosses[0]) { return crosses[0] < 0; } if (crosses[1]) { return crosses[1] < 0; } if (SkPath::kCubic_Verb == testVerb && crosses[2]) { return crosses[2] < 0; } fUnorderable = true; return -1; } bool SkOpAngle::calcSlop(double x, double y, double rx, double ry, bool* result) const { double absX = fabs(x); double absY = fabs(y); double length = absX < absY ? absX / 2 + absY : absX + absY / 2; int exponent; (void) frexp(length, &exponent); double epsilon = ldexp(FLT_EPSILON, exponent); SkPath::Verb verb = fSegment->verb(); SkASSERT(verb == SkPath::kQuad_Verb || verb == SkPath::kCubic_Verb); double slop = verb == SkPath::kQuad_Verb ? 4 * epsilon : 512 * epsilon; double xSlop = slop; double ySlop = x * y < 0 ? -xSlop : xSlop; double x1 = x - xSlop; double y1 = y + ySlop; double x_ry1 = x1 * ry; double rx_y1 = rx * y1; *result = x_ry1 < rx_y1; double x2 = x + xSlop; double y2 = y - ySlop; double x_ry2 = x2 * ry; double rx_y2 = rx * y2; bool less2 = x_ry2 < rx_y2; return *result == less2; } bool SkOpAngle::checkCrossesZero() const { int start = SkTMin(fSectorStart, fSectorEnd); int end = SkTMax(fSectorStart, fSectorEnd); bool crossesZero = end - start > 16; return crossesZero; } bool SkOpAngle::checkParallel(const SkOpAngle& rh) const { SkDVector scratch[2]; const SkDVector* sweep, * tweep; if (!fUnorderedSweep) { sweep = fSweep; } else { scratch[0] = fCurvePart[1] - fCurvePart[0]; sweep = &scratch[0]; } if (!rh.fUnorderedSweep) { tweep = rh.fSweep; } else { scratch[1] = rh.fCurvePart[1] - rh.fCurvePart[0]; tweep = &scratch[1]; } double s0xt0 = sweep->crossCheck(*tweep); if (tangentsDiverge(rh, s0xt0)) { return s0xt0 < 0; } SkDVector m0 = fSegment->dPtAtT(midT()) - fCurvePart[0]; SkDVector m1 = rh.fSegment->dPtAtT(rh.midT()) - rh.fCurvePart[0]; double m0xm1 = m0.crossCheck(m1); if (m0xm1 == 0) { fUnorderable = true; rh.fUnorderable = true; return true; } return m0xm1 < 0; } bool SkOpAngle::computeSector() { if (fComputedSector) { return !fUnorderable; } fComputedSector = true; int step = fStart < fEnd ? 1 : -1; int limit = step > 0 ? fSegment->count() : -1; int checkEnd = fEnd; do { const SkOpSpan& span = fSegment->span(checkEnd); const SkOpSegment* other = span.fOther; int oCount = other->count(); for (int oIndex = 0; oIndex < oCount; ++oIndex) { const SkOpSpan& oSpan = other->span(oIndex); if (oSpan.fOther != fSegment) { continue; } if (oSpan.fOtherIndex == checkEnd) { continue; } if (!approximately_equal(oSpan.fOtherT, span.fT)) { continue; } goto recomputeSector; } checkEnd += step; } while (checkEnd != limit); recomputeSector: if (checkEnd == fEnd || checkEnd - step == fEnd) { fUnorderable = true; return false; } int saveEnd = fEnd; fComputedEnd = fEnd = checkEnd - step; setSpans(); setSector(); fEnd = saveEnd; return !fUnorderable; } int SkOpAngle::convexHullOverlaps(const SkOpAngle& rh) const { const SkDVector* sweep = fSweep; const SkDVector* tweep = rh.fSweep; double s0xs1 = sweep[0].crossCheck(sweep[1]); double s0xt0 = sweep[0].crossCheck(tweep[0]); double s1xt0 = sweep[1].crossCheck(tweep[0]); bool tBetweenS = s0xs1 > 0 ? s0xt0 > 0 && s1xt0 < 0 : s0xt0 < 0 && s1xt0 > 0; double s0xt1 = sweep[0].crossCheck(tweep[1]); double s1xt1 = sweep[1].crossCheck(tweep[1]); tBetweenS |= s0xs1 > 0 ? s0xt1 > 0 && s1xt1 < 0 : s0xt1 < 0 && s1xt1 > 0; double t0xt1 = tweep[0].crossCheck(tweep[1]); if (tBetweenS) { return -1; } if ((s0xt0 == 0 && s1xt1 == 0) || (s1xt0 == 0 && s0xt1 == 0)) { return -1; } bool sBetweenT = t0xt1 > 0 ? s0xt0 < 0 && s0xt1 > 0 : s0xt0 > 0 && s0xt1 < 0; sBetweenT |= t0xt1 > 0 ? s1xt0 < 0 && s1xt1 > 0 : s1xt0 > 0 && s1xt1 < 0; if (sBetweenT) { return -1; } if (s0xt0 >= 0 && s0xt1 >= 0 && s1xt0 >= 0 && s1xt1 >= 0) argument
/external/skia/experimental/Intersection/
H A DDataTypes.h88 inline bool approximately_equal(double x, double y) { function
119 return approximately_equal(x, y);
280 // return approximately_equal(a.y, y) && approximately_equal(a.x, x);
288 return approximately_equal(x * inv, a.x * inv) && approximately_equal(y * inv, a.y * inv);
297 return approximately_equal(x * inv, a.fX * inv) && approximately_equal(y * inv, a.fY * inv);
/external/skia/src/pathops/
H A DSkPathOpsTypes.h155 inline bool approximately_equal(double x, double y) { function
180 return approximately_equal(x, y);
H A DSkOpAngle.cpp312 if (!approximately_equal(oSpan.fOtherT, span.fT)) {
146 SkASSERT(trOrder < 0); SkDEBUGCODE(bool lrOpposite = lh.oppositePlanes(rh)); bool ltOpposite = lh.oppositePlanes(*this); SkASSERT(lrOpposite != ltOpposite); return COMPARE_RESULT(8, ltOpposite); } else if (ltOrder == 1 && trOrder == 0) { SkASSERT(lrOrder < 0); SkDEBUGCODE(bool ltOpposite = lh.oppositePlanes(*this)); bool trOpposite = oppositePlanes(rh); SkASSERT(ltOpposite != trOpposite); return COMPARE_RESULT(9, trOpposite); } else if (lrOrder == 1 && trOrder == 1) { SkASSERT(ltOrder < 0); SkDEBUGCODE(bool trOpposite = oppositePlanes(rh)); bool lrOpposite = lh.oppositePlanes(rh); SkASSERT(lrOpposite != trOpposite); return COMPARE_RESULT(10, lrOpposite); } if (lrOrder < 0) { if (ltOrder < 0) { return COMPARE_RESULT(11, trOrder); } return COMPARE_RESULT(12, ltOrder); } return COMPARE_RESULT(13, !lrOrder); } int SkOpAngle::allOnOneSide(const SkOpAngle& test) const { SkASSERT(!fIsCurve); SkASSERT(test.fIsCurve); const SkDPoint& origin = test.fCurvePart[0]; SkVector line; if (fSegment->verb() == SkPath::kLine_Verb) { const SkPoint* linePts = fSegment->pts(); int lineStart = fStart < fEnd ? 0 : 1; line = linePts[lineStart ^ 1] - linePts[lineStart]; } else { SkPoint shortPts[2] = { fCurvePart[0].asSkPoint(), fCurvePart[1].asSkPoint() }; line = shortPts[1] - shortPts[0]; } float crosses[3]; SkPath::Verb testVerb = test.fSegment->verb(); int iMax = SkPathOpsVerbToPoints(testVerb); const SkDCubic& testCurve = test.fCurvePart; for (int index = 1; index <= iMax; ++index) { float xy1 = (float) (line.fX * (testCurve[index].fY - origin.fY)); float xy2 = (float) (line.fY * (testCurve[index].fX - origin.fX)); crosses[index - 1] = AlmostEqualUlps(xy1, xy2) ? 0 : xy1 - xy2; } if (crosses[0] * crosses[1] < 0) { return -1; } if (SkPath::kCubic_Verb == testVerb) { if (crosses[0] * crosses[2] < 0 || crosses[1] * crosses[2] < 0) { return -1; } } if (crosses[0]) { return crosses[0] < 0; } if (crosses[1]) { return crosses[1] < 0; } if (SkPath::kCubic_Verb == testVerb && crosses[2]) { return crosses[2] < 0; } fUnorderable = true; return -1; } bool SkOpAngle::calcSlop(double x, double y, double rx, double ry, bool* result) const { double absX = fabs(x); double absY = fabs(y); double length = absX < absY ? absX / 2 + absY : absX + absY / 2; int exponent; (void) frexp(length, &exponent); double epsilon = ldexp(FLT_EPSILON, exponent); SkPath::Verb verb = fSegment->verb(); SkASSERT(verb == SkPath::kQuad_Verb || verb == SkPath::kCubic_Verb); double slop = verb == SkPath::kQuad_Verb ? 4 * epsilon : 512 * epsilon; double xSlop = slop; double ySlop = x * y < 0 ? -xSlop : xSlop; double x1 = x - xSlop; double y1 = y + ySlop; double x_ry1 = x1 * ry; double rx_y1 = rx * y1; *result = x_ry1 < rx_y1; double x2 = x + xSlop; double y2 = y - ySlop; double x_ry2 = x2 * ry; double rx_y2 = rx * y2; bool less2 = x_ry2 < rx_y2; return *result == less2; } bool SkOpAngle::checkCrossesZero() const { int start = SkTMin(fSectorStart, fSectorEnd); int end = SkTMax(fSectorStart, fSectorEnd); bool crossesZero = end - start > 16; return crossesZero; } bool SkOpAngle::checkParallel(const SkOpAngle& rh) const { SkDVector scratch[2]; const SkDVector* sweep, * tweep; if (!fUnorderedSweep) { sweep = fSweep; } else { scratch[0] = fCurvePart[1] - fCurvePart[0]; sweep = &scratch[0]; } if (!rh.fUnorderedSweep) { tweep = rh.fSweep; } else { scratch[1] = rh.fCurvePart[1] - rh.fCurvePart[0]; tweep = &scratch[1]; } double s0xt0 = sweep->crossCheck(*tweep); if (tangentsDiverge(rh, s0xt0)) { return s0xt0 < 0; } SkDVector m0 = fSegment->dPtAtT(midT()) - fCurvePart[0]; SkDVector m1 = rh.fSegment->dPtAtT(rh.midT()) - rh.fCurvePart[0]; double m0xm1 = m0.crossCheck(m1); if (m0xm1 == 0) { fUnorderable = true; rh.fUnorderable = true; return true; } return m0xm1 < 0; } bool SkOpAngle::computeSector() { if (fComputedSector) { return !fUnorderable; } SkASSERT(fSegment->verb() != SkPath::kLine_Verb && small()); fComputedSector = true; int step = fStart < fEnd ? 1 : -1; int limit = step > 0 ? fSegment->count() : -1; int checkEnd = fEnd; do { const SkOpSpan& span = fSegment->span(checkEnd); const SkOpSegment* other = span.fOther; int oCount = other->count(); for (int oIndex = 0; oIndex < oCount; ++oIndex) { const SkOpSpan& oSpan = other->span(oIndex); if (oSpan.fOther != fSegment) { continue; } if (oSpan.fOtherIndex == checkEnd) { continue; } if (!approximately_equal(oSpan.fOtherT, span.fT)) { continue; } goto recomputeSector; } checkEnd += step; } while (checkEnd != limit); recomputeSector: if (checkEnd == fEnd || checkEnd - step == fEnd) { fUnorderable = true; return false; } int saveEnd = fEnd; fComputedEnd = fEnd = checkEnd - step; setSpans(); setSector(); fEnd = saveEnd; return !fUnorderable; } int SkOpAngle::convexHullOverlaps(const SkOpAngle& rh) const { const SkDVector* sweep = fSweep; const SkDVector* tweep = rh.fSweep; double s0xs1 = sweep[0].crossCheck(sweep[1]); double s0xt0 = sweep[0].crossCheck(tweep[0]); double s1xt0 = sweep[1].crossCheck(tweep[0]); bool tBetweenS = s0xs1 > 0 ? s0xt0 > 0 && s1xt0 < 0 : s0xt0 < 0 && s1xt0 > 0; double s0xt1 = sweep[0].crossCheck(tweep[1]); double s1xt1 = sweep[1].crossCheck(tweep[1]); tBetweenS |= s0xs1 > 0 ? s0xt1 > 0 && s1xt1 < 0 : s0xt1 < 0 && s1xt1 > 0; double t0xt1 = tweep[0].crossCheck(tweep[1]); if (tBetweenS) { return -1; } if ((s0xt0 == 0 && s1xt1 == 0) || (s1xt0 == 0 && s0xt1 == 0)) { return -1; } bool sBetweenT = t0xt1 > 0 ? s0xt0 < 0 && s0xt1 > 0 : s0xt0 > 0 && s0xt1 < 0; sBetweenT |= t0xt1 > 0 ? s1xt0 < 0 && s1xt1 > 0 : s1xt0 > 0 && s1xt1 < 0; if (sBetweenT) { return -1; } if (s0xt0 >= 0 && s0xt1 >= 0 && s1xt0 >= 0 && s1xt1 >= 0) argument

Completed in 234 milliseconds