Flutter Engine
The Flutter Engine
Classes | Functions | Variables
PathOpsCubicConicIntersectionTest.cpp File Reference
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include "src/pathops/SkIntersections.h"
#include "src/pathops/SkPathOpsConic.h"
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkReduceOrder.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/Test.h"
#include <iterator>

Go to the source code of this file.

Classes

struct  cubicConic
 

Functions

static void cubicConicIntersection (skiatest::Reporter *reporter, int index)
 
 DEF_TEST (PathOpsCubicConicIntersection, reporter)
 
 DEF_TEST (PathOpsCubicConicIntersectionOneOff, reporter)
 

Variables

static struct cubicConic cubicConicTests []
 
static const int cubicConicTests_count = (int) std::size(cubicConicTests)
 

Function Documentation

◆ cubicConicIntersection()

static void cubicConicIntersection ( skiatest::Reporter reporter,
int  index 
)
static

Definition at line 50 of file PathOpsCubicConicIntersectionTest.cpp.

50 {
51 const CubicPts& cu = cubicConicTests[index].cubic;
53 cubic.debugSet(cu.fPts);
55 const ConicPts& co = cubicConicTests[index].conic;
57 conic.debugSet(co.fPts.fPts, co.fWeight);
59 SkReduceOrder reduce1;
60 SkReduceOrder reduce2;
61 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
62 int order2 = reduce2.reduce(conic.fPts);
63 if (order1 != 4) {
64 SkDebugf("[%d] cubic order=%d\n", index, order1);
66 }
67 if (order2 != 3) {
68 SkDebugf("[%d] conic order=%d\n", index, order2);
70 }
72 int roots = i.intersect(cubic, conic);
73 for (int pt = 0; pt < roots; ++pt) {
74 double tt1 = i[0][pt];
75 SkDPoint xy1 = cubic.ptAtT(tt1);
76 double tt2 = i[1][pt];
77 SkDPoint xy2 = conic.ptAtT(tt2);
78 if (!xy1.approximatelyEqual(xy2)) {
79 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
80 __FUNCTION__, index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
81 }
83 }
84 reporter->bumpTestCount();
85}
reporter
Definition: FontMgrTest.cpp:39
static struct cubicConic cubicConicTests[]
bool ValidCubic(const SkDCubic &cubic)
bool ValidConic(const SkDConic &conic)
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
AI float conic(float tolerance, const SkPoint pts[], float w, const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:287
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:195
SkScalar fWeight
QuadPts fPts
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
bool approximatelyEqual(const SkDPoint &a) const
int reduce(const SkDCubic &cubic, Quadratics)

◆ DEF_TEST() [1/2]

DEF_TEST ( PathOpsCubicConicIntersection  ,
reporter   
)

Definition at line 87 of file PathOpsCubicConicIntersectionTest.cpp.

87 {
88 for (int index = 0; index < cubicConicTests_count; ++index) {
90 reporter->bumpTestCount();
91 }
92}
static const int cubicConicTests_count
static void cubicConicIntersection(skiatest::Reporter *reporter, int index)

◆ DEF_TEST() [2/2]

DEF_TEST ( PathOpsCubicConicIntersectionOneOff  ,
reporter   
)

Definition at line 94 of file PathOpsCubicConicIntersectionTest.cpp.

94 {
96}

Variable Documentation

◆ cubicConicTests

struct cubicConic cubicConicTests[]
static
Initial value:
= {
{{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990234375},
{208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}},
{{{{231.80000305175781, 2084.800048828125}, {188.60000610351562, 2084.800048828125},
{188.60000610351562, 2041.5999755859375}}}, 0.707107008f}},
{{{{231.80000305175781, 2084.800048828125}, {255.60000610351562, 2084.800048828125},
{275, 2065.39990234375}, {275, 2041.5999755859375}}},
{{{{275, 2041.5999755859375}, {275, 2084.800048828125},
{231.80000305175781, 2084.800048828125}}}, 0.707107008f}},
}

◆ cubicConicTests_count

const int cubicConicTests_count = (int) std::size(cubicConicTests)
static

Definition at line 48 of file PathOpsCubicConicIntersectionTest.cpp.