Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2605)

Side by Side Diff: tests/PathOpsCubicConicIntersectionTest.cpp

Issue 1394503003: fix some pathops bugs found in 1M skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: init to avoid warning Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkPathOpsTypes.cpp ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 */
7 #include "PathOpsTestCommon.h"
8 #include "SkIntersections.h"
9 #include "SkPathOpsConic.h"
10 #include "SkPathOpsCubic.h"
11 #include "SkReduceOrder.h"
12 #include "Test.h"
13
14 static struct cubicConic {
15 SkDCubic cubic;
16 SkDConic conic;
17 } cubicConicTests[] = {
18 {{{{188.60000610351562, 2041.5999755859375}, {188.60000610351562, 2065.39990 234375},
19 {208, 2084.800048828125}, {231.80000305175781, 2084.800048828125}}},
20 {{{{231.80000305175781, 2084.800048828125}, {188.60000610351562, 2084.800048 828125},
21 {188.60000610351562, 2041.5999755859375}}}, 0.707107008f}},
22
23 {{{{231.80000305175781, 2084.800048828125}, {255.60000610351562, 2084.800048 828125},
24 {275, 2065.39990234375}, {275, 2041.5999755859375}}},
25 {{{{275, 2041.5999755859375}, {275, 2084.800048828125},
26 {231.80000305175781, 2084.800048828125}}}, 0.707107008f}},
27 };
28
29 static const int cubicConicTests_count = (int) SK_ARRAY_COUNT(cubicConicTests);
30
31 static void cubicConicIntersection(skiatest::Reporter* reporter, int index) {
32 const SkDCubic& cubic = cubicConicTests[index].cubic;
33 SkASSERT(ValidCubic(cubic));
34 const SkDConic& conic = cubicConicTests[index].conic;
35 SkASSERT(ValidConic(conic));
36 SkReduceOrder reduce1;
37 SkReduceOrder reduce2;
38 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
39 int order2 = reduce2.reduce(conic.fPts);
40 if (order1 != 4) {
41 SkDebugf("[%d] cubic order=%d\n", index, order1);
42 REPORTER_ASSERT(reporter, 0);
43 }
44 if (order2 != 3) {
45 SkDebugf("[%d] conic order=%d\n", index, order2);
46 REPORTER_ASSERT(reporter, 0);
47 }
48 SkIntersections i;
49 int roots = i.intersect(cubic, conic);
50 for (int pt = 0; pt < roots; ++pt) {
51 double tt1 = i[0][pt];
52 SkDPoint xy1 = cubic.ptAtT(tt1);
53 double tt2 = i[1][pt];
54 SkDPoint xy2 = conic.ptAtT(tt2);
55 if (!xy1.approximatelyEqual(xy2)) {
56 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
57 __FUNCTION__, index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.f Y);
58 }
59 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
60 }
61 reporter->bumpTestCount();
62 }
63
64 DEF_TEST(PathOpsCubicConicIntersection, reporter) {
65 for (int index = 0; index < cubicConicTests_count; ++index) {
66 cubicConicIntersection(reporter, index);
67 reporter->bumpTestCount();
68 }
69 }
70
71 DEF_TEST(PathOpsCubicConicIntersectionOneOff, reporter) {
72 cubicConicIntersection(reporter, 1);
73 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsTypes.cpp ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698