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

Side by Side Diff: tests/PathOpsCubicQuadIntersectionTest.cpp

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build Created 5 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "PathOpsTestCommon.h" 7 #include "PathOpsTestCommon.h"
8 #include "SkIntersections.h" 8 #include "SkIntersections.h"
9 #include "SkPathOpsCubic.h" 9 #include "SkPathOpsCubic.h"
10 #include "SkPathOpsQuad.h" 10 #include "SkPathOpsQuad.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkReduceOrder.h" 12 #include "SkReduceOrder.h"
13 #include "Test.h" 13 #include "Test.h"
14 14
15 static struct quadCubic { 15 static struct quadCubic {
16 SkDCubic cubic; 16 SkDCubic cubic;
17 SkDQuad quad; 17 SkDQuad quad;
18 } quadCubicTests[] = { 18 } quadCubicTests[] = {
19 {{{{778, 14089}, {778, 14091.208984375}, {776.20916748046875, 14093}, {774, 14093}}},
20 {{{778, 14089}, {777.99957275390625, 14090.65625}, {776.82843017578125, 1409 1.828125}}}},
21
19 {{{{1020.08099,672.161987}, {1020.08002,630.73999}, {986.502014,597.161987}, {945.080994,597.161987}}}, 22 {{{{1020.08099,672.161987}, {1020.08002,630.73999}, {986.502014,597.161987}, {945.080994,597.161987}}},
20 {{{1020,672}, {1020,640.93396}, {998.03302,618.96698}}}}, 23 {{{1020,672}, {1020,640.93396}, {998.03302,618.96698}}}},
21 24
22 {{{{778, 14089}, {778, 14091.208984375}, {776.20916748046875, 14093}, {774, 14093}}}, 25 {{{{778, 14089}, {778, 14091.208984375}, {776.20916748046875, 14093}, {774, 14093}}},
23 {{{778, 14089}, {777.99957275390625, 14090.65625}, {776.82843017578125, 140 91.828125}}}}, 26 {{{778, 14089}, {777.99957275390625, 14090.65625}, {776.82843017578125, 140 91.828125}}}},
24 27
25 {{{{1110, 817}, {1110.55225f, 817}, {1111, 817.447693f}, {1111, 818}}}, 28 {{{{1110, 817}, {1110.55225f, 817}, {1111, 817.447693f}, {1111, 818}}},
26 {{{1110.70715f, 817.292908f}, {1110.41406f, 817.000122f}, {1110, 817}}}}, 29 {{{1110.70715f, 817.292908f}, {1110.41406f, 817.000122f}, {1110, 817}}}},
27 30
28 {{{{1110, 817}, {1110.55225f, 817}, {1111, 817.447693f}, {1111, 818}}}, 31 {{{{1110, 817}, {1110.55225f, 817}, {1111, 817.447693f}, {1111, 818}}},
(...skipping 27 matching lines...) Expand all
56 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); 59 int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
57 int order2 = reduce2.reduce(quad); 60 int order2 = reduce2.reduce(quad);
58 if (order1 != 4) { 61 if (order1 != 4) {
59 SkDebugf("[%d] cubic order=%d\n", iIndex, order1); 62 SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
60 REPORTER_ASSERT(reporter, 0); 63 REPORTER_ASSERT(reporter, 0);
61 } 64 }
62 if (order2 != 3) { 65 if (order2 != 3) {
63 SkDebugf("[%d] quad order=%d\n", iIndex, order2); 66 SkDebugf("[%d] quad order=%d\n", iIndex, order2);
64 REPORTER_ASSERT(reporter, 0); 67 REPORTER_ASSERT(reporter, 0);
65 } 68 }
66 SkDCubic quadToCubic = quad.toCubic();
67 SkIntersections i; 69 SkIntersections i;
68 int roots = i.intersect(cubic, quadToCubic); 70 int roots = i.intersect(cubic, quad);
69 for (int pt = 0; pt < roots; ++pt) { 71 for (int pt = 0; pt < roots; ++pt) {
70 double tt1 = i[0][pt]; 72 double tt1 = i[0][pt];
71 SkDPoint xy1 = cubic.ptAtT(tt1); 73 SkDPoint xy1 = cubic.ptAtT(tt1);
72 double tt2 = i[1][pt]; 74 double tt2 = i[1][pt];
73 SkDPoint xy2 = quad.ptAtT(tt2); 75 SkDPoint xy2 = quad.ptAtT(tt2);
74 if (!xy1.approximatelyEqual(xy2)) { 76 if (!xy1.approximatelyEqual(xy2)) {
75 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", 77 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
76 __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2. fY); 78 __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2. fY);
77 } 79 }
78 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); 80 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
79 } 81 }
80 reporter->bumpTestCount(); 82 reporter->bumpTestCount();
81 } 83 }
82 84
83 DEF_TEST(PathOpsCubicQuadIntersection, reporter) { 85 DEF_TEST(PathOpsCubicQuadIntersection, reporter) {
84 for (int index = 0; index < quadCubicTests_count; ++index) { 86 for (int index = 0; index < quadCubicTests_count; ++index) {
85 cubicQuadIntersection(reporter, index); 87 cubicQuadIntersection(reporter, index);
86 reporter->bumpTestCount(); 88 reporter->bumpTestCount();
87 } 89 }
88 } 90 }
89 91
90 DEF_TEST(PathOpsCubicQuadIntersectionOneOff, reporter) { 92 DEF_TEST(PathOpsCubicQuadIntersectionOneOff, reporter) {
91 cubicQuadIntersection(reporter, 0); 93 cubicQuadIntersection(reporter, 0);
92 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698