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

Side by Side Diff: experimental/Intersection/LineCubicIntersection_Test.cpp

Issue 867213004: remove prototype pathops code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
(Empty)
1 /*
2 * Copyright 2012 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 "CurveIntersection.h"
8 #include "CurveUtilities.h"
9 #include "Intersection_Tests.h"
10 #include "Intersections.h"
11 #include "TestUtilities.h"
12
13 struct lineCubic {
14 Cubic cubic;
15 _Line line;
16 } lineCubicTests[] = {
17 {{{0, 0}, {0, 1}, {0, 1}, {1, 1}}, {{0, 1}, {1, 0}}}
18 };
19
20 size_t lineCubicTests_count = sizeof(lineCubicTests) / sizeof(lineCubicTests[0]) ;
21
22 const int firstLineCubicIntersectionTest = 0;
23
24 void LineCubicIntersection_Test() {
25 for (size_t index = firstLineCubicIntersectionTest; index < lineCubicTests_c ount; ++index) {
26 const Cubic& cubic = lineCubicTests[index].cubic;
27 const _Line& line = lineCubicTests[index].line;
28 Cubic reduce1;
29 _Line reduce2;
30 int order1 = reduceOrder(cubic, reduce1, kReduceOrder_NoQuadraticsAllowe d,
31 kReduceOrder_TreatAsFill);
32 int order2 = reduceOrder(line, reduce2);
33 if (order1 < 4) {
34 printf("[%d] cubic order=%d\n", (int) index, order1);
35 }
36 if (order2 < 2) {
37 printf("[%d] line order=%d\n", (int) index, order2);
38 }
39 if (order1 == 4 && order2 == 2) {
40 Intersections i;
41 double* range1 = i.fT[0];
42 double* range2 = i.fT[1];
43 int roots = intersect(reduce1, reduce2, i);
44 for (int pt = 0; pt < roots; ++pt) {
45 double tt1 = range1[pt];
46 double tx1, ty1;
47 xy_at_t(cubic, tt1, tx1, ty1);
48 double tt2 = range2[pt];
49 double tx2, ty2;
50 xy_at_t(line, tt2, tx2, ty2);
51 if (!AlmostEqualUlps(tx1, tx2)) {
52 printf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
53 __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, t y2);
54 }
55 if (!AlmostEqualUlps(ty1, ty2)) {
56 printf("%s [%d,%d] y!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
57 __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, t y2);
58 }
59 }
60 }
61 }
62 }
OLDNEW
« no previous file with comments | « experimental/Intersection/LineCubicIntersection.cpp ('k') | experimental/Intersection/LineIntersection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698