// FIXME: if flat measure is sufficiently large, then probably the quartic solution failed
static void relaxed_is_linear(const SkDQuad& q1, const SkDQuad& q2, SkIntersections* i) {
    double m1 = flat_measure(q1);
    double m2 = flat_measure(q2);
#if DEBUG_FLAT_QUADS
    double min = SkTMin(m1, m2);
    if (min > 5) {
        SkDebugf("%s maybe not flat enough.. %1.9g\n", __FUNCTION__, min);
    }
#endif
    i->reset();
    const SkDQuad& rounder = m2 < m1 ? q1 : q2;
    const SkDQuad& flatter = m2 < m1 ? q2 : q1;
    bool subDivide = false;
    is_linear_inner(flatter, 0, 1, rounder, 0, 1, i, &subDivide);
    if (subDivide) {
        SkDQuadPair pair = flatter.chopAt(0.5);
        SkIntersections firstI, secondI;
        relaxed_is_linear(pair.first(), rounder, &firstI);
        for (int index = 0; index < firstI.used(); ++index) {
            i->insert(firstI[0][index] * 0.5, firstI[1][index], firstI.pt(index));
        }
        relaxed_is_linear(pair.second(), rounder, &secondI);
        for (int index = 0; index < secondI.used(); ++index) {
            i->insert(0.5 + secondI[0][index] * 0.5, secondI[1][index], secondI.pt(index));
        }
    }
    if (m2 < m1) {
        i->swapPts();
    }
}
コード例 #2
0
ファイル: SkDQuadIntersection.cpp プロジェクト: 3rdexp/soui
// FIXME: if flat measure is sufficiently large, then probably the quartic solution failed
// avoid imprecision incurred with chopAt
static void relaxed_is_linear(const SkDQuad* q1, double s1, double e1, const SkDQuad* q2,
        double s2, double e2, SkIntersections* i) {
    double m1 = flat_measure(*q1);
    double m2 = flat_measure(*q2);
    i->reset();
    const SkDQuad* rounder, *flatter;
    double sf, midf, ef, sr, er;
    if (m2 < m1) {
        rounder = q1;
        sr = s1;
        er = e1;
        flatter = q2;
        sf = s2;
        midf = (s2 + e2) / 2;
        ef = e2;
    } else {
        rounder = q2;
        sr = s2;
        er = e2;
        flatter = q1;
        sf = s1;
        midf = (s1 + e1) / 2;
        ef = e1;
    }
    bool subDivide = false;
    is_linear_inner(*flatter, sf, ef, *rounder, sr, er, i, &subDivide);
    if (subDivide) {
        relaxed_is_linear(flatter, sf, midf, rounder, sr, er, i);
        relaxed_is_linear(flatter, midf, ef, rounder, sr, er, i);
    }
    if (m2 < m1) {
        i->swapPts();
    }
}