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

Side by Side Diff: tests/PathOpsThreeWayTest.cpp

Issue 853223002: new files for pathops geometric intersection (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove visualizer tool so cl contains only pure adds Created 5 years, 11 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 | « tests/PathOpsTSectDebug.h ('k') | no next file » | 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 2014 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 "SkIntersections.h"
8 #include "SkTDArray.h"
9 #include "Test.h"
10
11 // check intersections for consistency
12
13 struct Curve {
14 int ptCount;
15 SkDCubic curve; // largest can hold lines / quads/ cubics
16 };
17
18 static const Curve testSet0[] = { // extracted from skpClip2
19 {4, {{{134,11414}, {131.990234,11414}, {130.32666,11415.4824}, {130.042755,1 1417.4131}}} },
20 {4, {{{130.042755,11417.4131}, {130.233124,11418.3193}, {131.037079,11419}, {132,11419}}} },
21 {4, {{{132,11419}, {130.895432,11419}, {130,11418.1045}, {130,11417}}} },
22 };
23
24 static const Curve testSet1[] = { // extracted from cubicOp85i
25 {4, {{{3,4}, {1,5}, {4,3}, {6,4}}} },
26 {1, {{{6,4}, {3,4}}} },
27 {4, {{{3,4}, {4,6}, {4,3}, {5,1}}} },
28 {1, {{{5,1}, {3,4}}} },
29 };
30
31 static const struct TestSet {
32 const Curve* tests;
33 int testCount;
34 } testSets[] = {
35 { testSet0, (int) SK_ARRAY_COUNT(testSet0) },
36 { testSet1, (int) SK_ARRAY_COUNT(testSet1) },
37 };
38
39 static const int testSetsCount = (int) SK_ARRAY_COUNT(testSets);
40
41 static void testSetTest(skiatest::Reporter* reporter, int index) {
42 const TestSet& testSet = testSets[index];
43 int testCount = testSet.testCount;
44 SkASSERT(testCount > 1);
45 SkTDArray<SkIntersections> combos;
46 for (int outer = 0; outer < testCount - 1; ++outer) {
47 const Curve& oTest = testSet.tests[outer];
48 for (int inner = outer + 1; inner < testCount; ++inner) {
49 const Curve& iTest = testSet.tests[inner];
50 SkIntersections* i = combos.append();
51 sk_bzero(i, sizeof(SkIntersections));
52 if (oTest.ptCount == 1 && iTest.ptCount == 1) {
53 i->intersect(*(const SkDLine*) &oTest.curve, *(const SkDLine*) & iTest.curve);
54 } else if (oTest.ptCount == 1 && iTest.ptCount == 4) {
55 i->intersect(iTest.curve, *(const SkDLine*) &oTest.curve);
56 } else if (oTest.ptCount == 4 && iTest.ptCount == 1) {
57 i->intersect(oTest.curve, *(const SkDLine*) &oTest.curve);
58 } else if (oTest.ptCount == 4 && iTest.ptCount == 4) {
59 i->intersectB(oTest.curve, iTest.curve);
60 } else {
61 SkASSERT(0);
62 }
63 // i->dump();
64 }
65 }
66 }
67
68 DEF_TEST(PathOpsThreeWay, reporter) {
69 for (int index = 0; index < testSetsCount; ++index) {
70 testSetTest(reporter, index);
71 reporter->bumpTestCount();
72 }
73 }
74
75 DEF_TEST(PathOpsThreeWayOneOff, reporter) {
76 int index = 1;
77 testSetTest(reporter, index);
78 }
OLDNEW
« no previous file with comments | « tests/PathOpsTSectDebug.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698