tests/WangsFormulaTest.cpp
DEF_TEST(wangs_formula_vectorXforms, r) {
    auto check_cubic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m){
        SkPoint ptsXformed[4];
        m.mapPoints(ptsXformed, pts, 4);
        int expected = wangs_formula::cubic_log2(kPrecision, ptsXformed);
        int actual = wangs_formula::cubic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
        REPORTER_ASSERT(r, actual == expected);
    };

    auto check_quadratic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m) {
        SkPoint ptsXformed[3];
        m.mapPoints(ptsXformed, pts, 3);
        int expected = wangs_formula::quadratic_log2(kPrecision, ptsXformed);
        int actual = wangs_formula::quadratic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
        REPORTER_ASSERT(r, actual == expected);
    };

    SkRandom rand;

    for_random_matrices(&rand, [&](const SkMatrix& m) {
        check_cubic_log2_with_transform(kSerp, m);
        check_cubic_log2_with_transform(kLoop, m);
        check_quadratic_log2_with_transform(kQuad, m);

        for_random_beziers(4, &rand, [&](const SkPoint pts[]) {
            check_cubic_log2_with_transform(pts, m);
        });

        for_random_beziers(3, &rand, [&](const SkPoint pts[]) {
            check_quadratic_log2_with_transform(pts, m);
        });
    });
}
// Ensure using transformations gives the same result as pre-transforming all points.
Ensure using transformations gives the same result as pre-transforming all points.
Ensure using transformations gives the same result as pre - transforming all points .
DEF_TEST(wangs_formula_vectorXforms, r) {
    auto check_cubic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m){
        SkPoint ptsXformed[4];
        m.mapPoints(ptsXformed, pts, 4);
        int expected = wangs_formula::cubic_log2(kPrecision, ptsXformed);
        int actual = wangs_formula::cubic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
        REPORTER_ASSERT(r, actual == expected);
    };
    auto check_quadratic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m) {
        SkPoint ptsXformed[3];
        m.mapPoints(ptsXformed, pts, 3);
        int expected = wangs_formula::quadratic_log2(kPrecision, ptsXformed);
        int actual = wangs_formula::quadratic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
        REPORTER_ASSERT(r, actual == expected);
    };
    SkRandom rand;
    for_random_matrices(&rand, [&](const SkMatrix& m) {
        check_cubic_log2_with_transform(kSerp, m);
        check_cubic_log2_with_transform(kLoop, m);
        check_quadratic_log2_with_transform(kQuad, m);
        for_random_beziers(4, &rand, [&](const SkPoint pts[]) {
            check_cubic_log2_with_transform(pts, m);
        });
        for_random_beziers(3, &rand, [&](const SkPoint pts[]) {
            check_quadratic_log2_with_transform(pts, m);
        });
    });
}
DEF_TEST ( wangs_formula_vectorXforms , r ) { auto check_cubic_log2_with_transform = [ & ] ( const SkPoint * pts , const SkMatrix & m ) { SkPoint ptsXformed [ 4 ] ; m . mapPoints ( ptsXformed , pts , 4 ) ; int expected = wangs_formula :: cubic_log2 ( kPrecision , ptsXformed ) ; int actual = wangs_formula :: cubic_log2 ( kPrecision , pts , wangs_formula :: VectorXform ( m ) ) ; REPORTER_ASSERT ( r , actual == expected ) ; } ; auto check_quadratic_log2_with_transform = [ & ] ( const SkPoint * pts , const SkMatrix & m ) { SkPoint ptsXformed [ 3 ] ; m . mapPoints ( ptsXformed , pts , 3 ) ; int expected = wangs_formula :: quadratic_log2 ( kPrecision , ptsXformed ) ; int actual = wangs_formula :: quadratic_log2 ( kPrecision , pts , wangs_formula :: VectorXform ( m ) ) ; REPORTER_ASSERT ( r , actual == expected ) ; } ; SkRandom rand ; for_random_matrices ( & rand , [ & ] ( const SkMatrix & m ) { check_cubic_log2_with_transform ( kSerp , m ) ; check_cubic_log2_with_transform ( kLoop , m ) ; check_quadratic_log2_with_transform ( kQuad , m ) ; for_random_beziers ( 4 , & rand , [ & ] ( const SkPoint pts [ ] ) { check_cubic_log2_with_transform ( pts , m ) ; } ) ; for_random_beziers ( 3 , & rand , [ & ] ( const SkPoint pts [ ] ) { check_quadratic_log2_with_transform ( pts , m ) ; } ) ; } ) ; }
Ensure using transformations gives the same result as pre-transforming all points.
Ensure using transformations gives the same result as pre - transforming all points .