Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
PathOpsConicQuadIntersectionTest.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/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  conicQuad
 

Functions

static void conicQuadIntersection (skiatest::Reporter *reporter, int index)
 
 DEF_TEST (PathOpsConicQuadIntersection, reporter)
 
 DEF_TEST (PathOpsConicQuadIntersectionOneOff, reporter)
 

Variables

static struct conicQuad conicQuadTests []
 
static const int conicQuadTests_count = (int) std::size(conicQuadTests)
 

Function Documentation

◆ conicQuadIntersection()

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

Definition at line 39 of file PathOpsConicQuadIntersectionTest.cpp.

39 {
40 const ConicPts& c = conicQuadTests[index].conic;
42 conic.debugSet(c.fPts.fPts, c.fWeight);
43 SkASSERT(ValidConic(conic));
44 const QuadPts& q = conicQuadTests[index].quad;
45 SkDQuad quad;
46 quad.debugSet(q.fPts);
47 SkASSERT(ValidQuad(quad));
48 SkReduceOrder reduce1;
49 SkReduceOrder reduce2;
50 int order1 = reduce2.reduce(conic.fPts);
51 int order2 = reduce1.reduce(quad);
52 if (order2 != 3) {
53 SkDebugf("[%d] conic order=%d\n", index, order1);
55 }
56 if (order1 != 3) {
57 SkDebugf("[%d] quad order=%d\n", index, order2);
59 }
61 int roots = i.intersect(conic, quad);
62 for (int pt = 0; pt < roots; ++pt) {
63 double tt1 = i[0][pt];
64 SkDPoint xy1 = conic.ptAtT(tt1);
65 double tt2 = i[1][pt];
66 SkDPoint xy2 = quad.ptAtT(tt2);
67 if (!xy1.approximatelyEqual(xy2)) {
68 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
69 __FUNCTION__, index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
70 }
72 }
73 reporter->bumpTestCount();
74}
reporter
static struct conicQuad conicQuadTests[]
bool ValidConic(const SkDConic &conic)
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 conic(float tolerance, const SkPoint pts[], float w, const VectorXform &vectorXform=VectorXform())
SkScalar fWeight
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 ( PathOpsConicQuadIntersection  ,
reporter   
)

Definition at line 76 of file PathOpsConicQuadIntersectionTest.cpp.

76 {
77 for (int index = 0; index < conicQuadTests_count; ++index) {
79 reporter->bumpTestCount();
80 }
81}
static const int conicQuadTests_count
static void conicQuadIntersection(skiatest::Reporter *reporter, int index)

◆ DEF_TEST() [2/2]

DEF_TEST ( PathOpsConicQuadIntersectionOneOff  ,
reporter   
)

Definition at line 83 of file PathOpsConicQuadIntersectionTest.cpp.

83 {
85}

Variable Documentation

◆ conicQuadTests

struct conicQuad conicQuadTests[]
static
Initial value:
= {
{{{{{0.00000000000000000, -1.8135968446731567 },
{0.00000000000000000, -1.0033817291259766 },
{-0.0073835160583257675, 0.00000000000000000 }}}, 2.26585215e+11f},
{{{0.00000000000000000, -1.0000113248825073 },
{-2.4824290449032560e-05, -1.0000115633010864 },
{-0.0073835160583257675, 0.00000000000000000 }}}},
{{{{{494.348663,224.583771}, {494.365143,224.633194}, {494.376404,224.684067}}}, 0.998645842f},
{{{494.30481,224.474213}, {494.334961,224.538284}, {494.355774,224.605927}}}},
{{{{{494.348663,224.583771}, {494.365143,224.633194}, {494.376404,224.684067}}}, 0.998645842f},
{{{494.355774f, 224.605927f}, {494.363708f, 224.631714f}, {494.370148f, 224.657471f}}}},
}

◆ conicQuadTests_count

const int conicQuadTests_count = (int) std::size(conicQuadTests)
static

Definition at line 37 of file PathOpsConicQuadIntersectionTest.cpp.