Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
PathOpsCubicQuadIntersectionTest.cpp File Reference
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include "src/pathops/SkIntersections.h"
#include "src/pathops/SkPathOpsCubic.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkPathOpsQuad.h"
#include "src/pathops/SkReduceOrder.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/Test.h"
#include <array>

Go to the source code of this file.

Classes

struct  quadCubic
 

Functions

static void cubicQuadIntersection (skiatest::Reporter *reporter, int index)
 
 DEF_TEST (PathOpsCubicQuadIntersection, reporter)
 
 DEF_TEST (PathOpsCubicQuadIntersectionOneOff, reporter)
 

Variables

static struct quadCubic quadCubicTests []
 
static const int quadCubicTests_count = (int) std::size(quadCubicTests)
 

Function Documentation

◆ cubicQuadIntersection()

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

Definition at line 58 of file PathOpsCubicQuadIntersectionTest.cpp.

58 {
59 int iIndex = static_cast<int>(index);
60 const CubicPts& c = quadCubicTests[index].cubic;
62 cubic.debugSet(c.fPts);
63 SkASSERT(ValidCubic(cubic));
64 const QuadPts& q = quadCubicTests[index].quad;
65 SkDQuad quad;
66 quad.debugSet(q.fPts);
67 SkASSERT(ValidQuad(quad));
68 SkReduceOrder reduce1;
69 SkReduceOrder reduce2;
70 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
71 int order2 = reduce2.reduce(quad);
72 if (order1 != 4) {
73 SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
75 }
76 if (order2 != 3) {
77 SkDebugf("[%d] quad order=%d\n", iIndex, order2);
79 }
81 int roots = i.intersect(cubic, quad);
82 for (int pt = 0; pt < roots; ++pt) {
83 double tt1 = i[0][pt];
84 SkDPoint xy1 = cubic.ptAtT(tt1);
85 double tt2 = i[1][pt];
86 SkDPoint xy2 = quad.ptAtT(tt2);
87 if (!xy1.approximatelyEqual(xy2)) {
88 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
89 __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
90 }
92 }
93 reporter->bumpTestCount();
94}
reporter
static struct quadCubic quadCubicTests[]
bool ValidCubic(const SkDCubic &cubic)
bool ValidQuad(const SkDQuad &quad)
#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
int intersect(const SkDLine &, const SkDLine &)
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
bool approximatelyEqual(const SkDPoint &a) const
void debugSet(const SkDPoint *pts)
SkDPoint ptAtT(double t) const
int reduce(const SkDCubic &cubic, Quadratics)

◆ DEF_TEST() [1/2]

DEF_TEST ( PathOpsCubicQuadIntersection  ,
reporter   
)

Definition at line 96 of file PathOpsCubicQuadIntersectionTest.cpp.

96 {
97 for (int index = 0; index < quadCubicTests_count; ++index) {
99 reporter->bumpTestCount();
100 }
101}
static const int quadCubicTests_count
static void cubicQuadIntersection(skiatest::Reporter *reporter, int index)

◆ DEF_TEST() [2/2]

DEF_TEST ( PathOpsCubicQuadIntersectionOneOff  ,
reporter   
)

Definition at line 103 of file PathOpsCubicQuadIntersectionTest.cpp.

103 {
105}

Variable Documentation

◆ quadCubicTests

struct quadCubic quadCubicTests[]
static

◆ quadCubicTests_count

const int quadCubicTests_count = (int) std::size(quadCubicTests)
static

Definition at line 56 of file PathOpsCubicQuadIntersectionTest.cpp.