Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsCubicConicIntersectionTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
15#include "tests/Test.h"
16
17#include <iterator>
18
23#if 0
24// FIXME: this triggers an assert in bool SkTSect::extractCoincident() at
25// SkOPASSERT(oppStartT < oppEndT);
26// Throwing an error here breaks one test, but only in release.
27// More work to be done to figure this out.
28 {{{{2.1883804947719909e-05, 3.6366123822517693e-05 },
29 {2.9145950975362211e-05, 2.9117207304807380e-05 },
30 {2.9113532946212217e-05, 2.9173743314458989e-05 },
31 {0.00000000000000000, 5.8282588724978268e-05 }}},
32 {{{{0.00000000000000000, 5.8282581449020654e-05 },
33 {0.00000000000000000, 5.8282563259126619e-05 },
34 {5.8282588724978268e-05, 0.00000000000000000 }}}, 53684.6563f}},
35#endif
36
37 {{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990234375},
38 {208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}},
39 {{{{231.80000305175781, 2084.800048828125}, {188.60000610351562, 2084.800048828125},
40 {188.60000610351562, 2041.5999755859375}}}, 0.707107008f}},
41
42 {{{{231.80000305175781, 2084.800048828125}, {255.60000610351562, 2084.800048828125},
43 {275, 2065.39990234375}, {275, 2041.5999755859375}}},
44 {{{{275, 2041.5999755859375}, {275, 2084.800048828125},
45 {231.80000305175781, 2084.800048828125}}}, 0.707107008f}},
46};
47
48static const int cubicConicTests_count = (int) std::size(cubicConicTests);
49
51 const CubicPts& cu = cubicConicTests[index].cubic;
52 SkDCubic cubic;
53 cubic.debugSet(cu.fPts);
54 SkASSERT(ValidCubic(cubic));
55 const ConicPts& co = cubicConicTests[index].conic;
56 SkDConic conic;
57 conic.debugSet(co.fPts.fPts, co.fWeight);
58 SkASSERT(ValidConic(conic));
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}
86
87DEF_TEST(PathOpsCubicConicIntersection, reporter) {
88 for (int index = 0; index < cubicConicTests_count; ++index) {
90 reporter->bumpTestCount();
91 }
92}
93
94DEF_TEST(PathOpsCubicConicIntersectionOneOff, reporter) {
96}
reporter
static const int cubicConicTests_count
static struct cubicConic cubicConicTests[]
static void cubicConicIntersection(skiatest::Reporter *reporter, int index)
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 DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
Type::kYUV Type::kRGBA() int(0.7 *637)
int intersect(const SkDLine &, const SkDLine &)
SkScalar fWeight
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
bool approximatelyEqual(const SkDPoint &a) const
int reduce(const SkDCubic &cubic, Quadratics)