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

Side by Side Diff: tests/PathOpsDRectTest.cpp

Issue 13934009: path ops -- use standard max, min, double-is-nan (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathOpsTypes.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
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkPathOpsCubic.h" 7 #include "SkPathOpsCubic.h"
8 #include "SkPathOpsLine.h" 8 #include "SkPathOpsLine.h"
9 #include "SkPathOpsQuad.h" 9 #include "SkPathOpsQuad.h"
10 #include "SkPathOpsRect.h" 10 #include "SkPathOpsRect.h"
(...skipping 25 matching lines...) Expand all
36 static const size_t lineTests_count = SK_ARRAY_COUNT(lineTests); 36 static const size_t lineTests_count = SK_ARRAY_COUNT(lineTests);
37 static const size_t quadTests_count = SK_ARRAY_COUNT(quadTests); 37 static const size_t quadTests_count = SK_ARRAY_COUNT(quadTests);
38 static const size_t cubicTests_count = SK_ARRAY_COUNT(cubicTests); 38 static const size_t cubicTests_count = SK_ARRAY_COUNT(cubicTests);
39 39
40 static void PathOpsDRectTest(skiatest::Reporter* reporter) { 40 static void PathOpsDRectTest(skiatest::Reporter* reporter) {
41 size_t index; 41 size_t index;
42 SkDRect rect, rect2; 42 SkDRect rect, rect2;
43 for (index = 0; index < lineTests_count; ++index) { 43 for (index = 0; index < lineTests_count; ++index) {
44 const SkDLine& line = lineTests[index]; 44 const SkDLine& line = lineTests[index];
45 rect.setBounds(line); 45 rect.setBounds(line);
46 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin<double>(line[0].fX, line[ 1].fX)); 46 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(line[0].fX, line[1].fX));
47 REPORTER_ASSERT(reporter, rect.fTop == SkTMin<double>(line[0].fY, line[1 ].fY)); 47 REPORTER_ASSERT(reporter, rect.fTop == SkTMin(line[0].fY, line[1].fY));
48 REPORTER_ASSERT(reporter, rect.fRight == SkTMax<double>(line[0].fX, line [1].fX)); 48 REPORTER_ASSERT(reporter, rect.fRight == SkTMax(line[0].fX, line[1].fX)) ;
49 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax<double>(line[0].fY, lin e[1].fY)); 49 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(line[0].fY, line[1].fY) );
50 rect2.set(line[0]); 50 rect2.set(line[0]);
51 rect2.add(line[1]); 51 rect2.add(line[1]);
52 REPORTER_ASSERT(reporter, rect2.fLeft == SkTMin<double>(line[0].fX, line [1].fX)); 52 REPORTER_ASSERT(reporter, rect2.fLeft == SkTMin(line[0].fX, line[1].fX)) ;
53 REPORTER_ASSERT(reporter, rect2.fTop == SkTMin<double>(line[0].fY, line[ 1].fY)); 53 REPORTER_ASSERT(reporter, rect2.fTop == SkTMin(line[0].fY, line[1].fY));
54 REPORTER_ASSERT(reporter, rect2.fRight == SkTMax<double>(line[0].fX, lin e[1].fX)); 54 REPORTER_ASSERT(reporter, rect2.fRight == SkTMax(line[0].fX, line[1].fX) );
55 REPORTER_ASSERT(reporter, rect2.fBottom == SkTMax<double>(line[0].fY, li ne[1].fY)); 55 REPORTER_ASSERT(reporter, rect2.fBottom == SkTMax(line[0].fY, line[1].fY ));
56 REPORTER_ASSERT(reporter, rect.contains(line[0])); 56 REPORTER_ASSERT(reporter, rect.contains(line[0]));
57 REPORTER_ASSERT(reporter, rect.intersects(&rect2)); 57 REPORTER_ASSERT(reporter, rect.intersects(&rect2));
58 } 58 }
59 for (index = 0; index < quadTests_count; ++index) { 59 for (index = 0; index < quadTests_count; ++index) {
60 const SkDQuad& quad = quadTests[index]; 60 const SkDQuad& quad = quadTests[index];
61 rect.setRawBounds(quad); 61 rect.setRawBounds(quad);
62 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin<double>(quad[0].fX, 62 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(quad[0].fX,
63 SkTMin<double>(quad[1].fX, quad[2].fX))); 63 SkTMin(quad[1].fX, quad[2].fX)));
64 REPORTER_ASSERT(reporter, rect.fTop == SkTMin<double>(quad[0].fY, 64 REPORTER_ASSERT(reporter, rect.fTop == SkTMin(quad[0].fY,
65 SkTMin<double>(quad[1].fY, quad[2].fY))); 65 SkTMin(quad[1].fY, quad[2].fY)));
66 REPORTER_ASSERT(reporter, rect.fRight == SkTMax<double>(quad[0].fX, 66 REPORTER_ASSERT(reporter, rect.fRight == SkTMax(quad[0].fX,
67 SkTMax<double>(quad[1].fX, quad[2].fX))); 67 SkTMax(quad[1].fX, quad[2].fX)));
68 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax<double>(quad[0].fY, 68 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(quad[0].fY,
69 SkTMax<double>(quad[1].fY, quad[2].fY))); 69 SkTMax(quad[1].fY, quad[2].fY)));
70 rect2.setBounds(quad); 70 rect2.setBounds(quad);
71 REPORTER_ASSERT(reporter, rect.intersects(&rect2)); 71 REPORTER_ASSERT(reporter, rect.intersects(&rect2));
72 // FIXME: add a recursive box subdivision method to verify that tight bo unds is correct 72 // FIXME: add a recursive box subdivision method to verify that tight bo unds is correct
73 SkDPoint leftTop = {rect2.fLeft, rect2.fTop}; 73 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
74 REPORTER_ASSERT(reporter, rect.contains(leftTop)); 74 REPORTER_ASSERT(reporter, rect.contains(leftTop));
75 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom}; 75 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
76 REPORTER_ASSERT(reporter, rect.contains(rightBottom)); 76 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
77 } 77 }
78 for (index = 0; index < cubicTests_count; ++index) { 78 for (index = 0; index < cubicTests_count; ++index) {
79 const SkDCubic& cubic = cubicTests[index]; 79 const SkDCubic& cubic = cubicTests[index];
80 rect.setRawBounds(cubic); 80 rect.setRawBounds(cubic);
81 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin<double>(cubic[0].fX, 81 REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(cubic[0].fX,
82 SkTMin<double>(cubic[1].fX, SkTMin<double>(cubic[2].fX, cubic[3] .fX)))); 82 SkTMin(cubic[1].fX, SkTMin(cubic[2].fX, cubic[3].fX))));
83 REPORTER_ASSERT(reporter, rect.fTop == SkTMin<double>(cubic[0].fY, 83 REPORTER_ASSERT(reporter, rect.fTop == SkTMin(cubic[0].fY,
84 SkTMin<double>(cubic[1].fY, SkTMin<double>(cubic[2].fY, cubic[3] .fY)))); 84 SkTMin(cubic[1].fY, SkTMin(cubic[2].fY, cubic[3].fY))));
85 REPORTER_ASSERT(reporter, rect.fRight == SkTMax<double>(cubic[0].fX, 85 REPORTER_ASSERT(reporter, rect.fRight == SkTMax(cubic[0].fX,
86 SkTMax<double>(cubic[1].fX, SkTMax<double>(cubic[2].fX, cubic[3] .fX)))); 86 SkTMax(cubic[1].fX, SkTMax(cubic[2].fX, cubic[3].fX))));
87 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax<double>(cubic[0].fY, 87 REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(cubic[0].fY,
88 SkTMax<double>(cubic[1].fY, SkTMax<double>(cubic[2].fY, cubic[3] .fY)))); 88 SkTMax(cubic[1].fY, SkTMax(cubic[2].fY, cubic[3].fY))));
89 rect2.setBounds(cubic); 89 rect2.setBounds(cubic);
90 REPORTER_ASSERT(reporter, rect.intersects(&rect2)); 90 REPORTER_ASSERT(reporter, rect.intersects(&rect2));
91 // FIXME: add a recursive box subdivision method to verify that tight bo unds is correct 91 // FIXME: add a recursive box subdivision method to verify that tight bo unds is correct
92 SkDPoint leftTop = {rect2.fLeft, rect2.fTop}; 92 SkDPoint leftTop = {rect2.fLeft, rect2.fTop};
93 REPORTER_ASSERT(reporter, rect.contains(leftTop)); 93 REPORTER_ASSERT(reporter, rect.contains(leftTop));
94 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom}; 94 SkDPoint rightBottom = {rect2.fRight, rect2.fBottom};
95 REPORTER_ASSERT(reporter, rect.contains(rightBottom)); 95 REPORTER_ASSERT(reporter, rect.contains(rightBottom));
96 } 96 }
97 } 97 }
98 98
99 #include "TestClassDef.h" 99 #include "TestClassDef.h"
100 DEFINE_TESTCLASS_SHORT(PathOpsDRectTest) 100 DEFINE_TESTCLASS_SHORT(PathOpsDRectTest)
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698