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

Side by Side Diff: tests/PathOpsBoundsTest.cpp

Issue 1107353004: align top and bounds computations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up code Created 5 years, 7 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/SkPathOpsSimplify.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | 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 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 "SkPathOpsBounds.h" 8 #include "SkPathOpsBounds.h"
9 #include "SkPathOpsCurve.h"
9 #include "Test.h" 10 #include "Test.h"
10 11
11 static const SkRect sectTests[][2] = { 12 static const SkRect sectTests[][2] = {
12 {{2, 0, 4, 1}, {4, 0, 6, 1}}, 13 {{2, 0, 4, 1}, {4, 0, 6, 1}},
13 {{2, 0, 4, 1}, {3, 0, 5, 1}}, 14 {{2, 0, 4, 1}, {3, 0, 5, 1}},
14 {{2, 0, 4, 1}, {3, 0, 5, 0}}, 15 {{2, 0, 4, 1}, {3, 0, 5, 0}},
15 {{2, 0, 4, 1}, {3, 1, 5, 2}}, 16 {{2, 0, 4, 1}, {3, 1, 5, 2}},
16 {{2, 1, 4, 2}, {1, 0, 5, 3}}, 17 {{2, 1, 4, 2}, {1, 0, 5, 3}},
17 {{2, 1, 5, 3}, {3, 1, 4, 2}}, 18 {{2, 1, 5, 3}, {3, 1, 4, 2}},
18 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK 19 {{2, 0, 4, 1}, {3, 0, 3, 0}}, // intersecting an empty bounds is OK
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bounds.setEmpty(); 68 bounds.setEmpty();
68 bounds.add(1, 2, 3, 4); 69 bounds.add(1, 2, 3, 4);
69 SkPathOpsBounds expected; 70 SkPathOpsBounds expected;
70 expected.set(0, 0, 3, 4); 71 expected.set(0, 0, 3, 4);
71 REPORTER_ASSERT(reporter, bounds == expected); 72 REPORTER_ASSERT(reporter, bounds == expected);
72 bounds.setEmpty(); 73 bounds.setEmpty();
73 SkPathOpsBounds ordinal; 74 SkPathOpsBounds ordinal;
74 ordinal.set(1, 2, 3, 4); 75 ordinal.set(1, 2, 3, 4);
75 bounds.add(ordinal); 76 bounds.add(ordinal);
76 REPORTER_ASSERT(reporter, bounds == expected); 77 REPORTER_ASSERT(reporter, bounds == expected);
77 SkPoint topLeft = {0, 0}; 78 SkDPoint topLeft = {0, 0};
78 bounds.setPointBounds(topLeft); 79 bounds.setPointBounds(topLeft);
79 SkPoint botRight = {3, 4}; 80 SkDPoint botRight = {3, 4};
80 bounds.add(botRight); 81 bounds.add(botRight);
81 REPORTER_ASSERT(reporter, bounds == expected); 82 REPORTER_ASSERT(reporter, bounds == expected);
82 for (size_t index = 0; index < emptyTestsCount; ++index) { 83 for (size_t index = 0; index < emptyTestsCount; ++index) {
83 const SkPathOpsBounds& bounds = static_cast<const SkPathOpsBounds&>(real lyEmpty[index]); 84 const SkPathOpsBounds& bounds = static_cast<const SkPathOpsBounds&>(real lyEmpty[index]);
84 // SkASSERT(ValidBounds(bounds)); // don't check because test may conta in nan 85 // SkASSERT(ValidBounds(bounds)); // don't check because test may conta in nan
85 bool empty = bounds.isReallyEmpty(); 86 bool empty = bounds.isReallyEmpty();
86 REPORTER_ASSERT(reporter, empty); 87 REPORTER_ASSERT(reporter, empty);
87 } 88 }
88 for (size_t index = 0; index < notEmptyTestsCount; ++index) { 89 for (size_t index = 0; index < notEmptyTestsCount; ++index) {
89 const SkPathOpsBounds& bounds = static_cast<const SkPathOpsBounds&>(notR eallyEmpty[index]); 90 const SkPathOpsBounds& bounds = static_cast<const SkPathOpsBounds&>(notR eallyEmpty[index]);
90 SkASSERT(ValidBounds(bounds)); 91 SkASSERT(ValidBounds(bounds));
91 bool empty = bounds.isReallyEmpty(); 92 bool empty = bounds.isReallyEmpty();
92 REPORTER_ASSERT(reporter, !empty); 93 REPORTER_ASSERT(reporter, !empty);
93 } 94 }
94 const SkPoint curvePts[] = {{0, 0}, {1, 2}, {3, 4}, {5, 6}}; 95 const SkPoint curvePts[] = {{0, 0}, {1, 2}, {3, 4}, {5, 6}};
95 bounds.setLineBounds(curvePts, 1); 96 SkDCurve curve;
97 curve.fLine.set(curvePts);
98 curve.setLineBounds(curvePts, 1, 0, 1, &bounds);
96 expected.set(0, 0, 1, 2); 99 expected.set(0, 0, 1, 2);
97 REPORTER_ASSERT(reporter, bounds == expected); 100 REPORTER_ASSERT(reporter, bounds == expected);
98 (bounds.*SetCurveBounds[SkPath::kLine_Verb])(curvePts, 1); 101 (curve.*SetBounds[SkPath::kLine_Verb])(curvePts, 1, 0, 1, &bounds);
99 REPORTER_ASSERT(reporter, bounds == expected); 102 REPORTER_ASSERT(reporter, bounds == expected);
100 bounds.setQuadBounds(curvePts, 1); 103 curve.fQuad.set(curvePts);
104 curve.setQuadBounds(curvePts, 1, 0, 1, &bounds);
101 expected.set(0, 0, 3, 4); 105 expected.set(0, 0, 3, 4);
102 REPORTER_ASSERT(reporter, bounds == expected); 106 REPORTER_ASSERT(reporter, bounds == expected);
103 (bounds.*SetCurveBounds[SkPath::kQuad_Verb])(curvePts, 1); 107 (curve.*SetBounds[SkPath::kQuad_Verb])(curvePts, 1, 0, 1, &bounds);
104 REPORTER_ASSERT(reporter, bounds == expected); 108 REPORTER_ASSERT(reporter, bounds == expected);
105 bounds.setCubicBounds(curvePts, 1); 109 curve.fCubic.set(curvePts);
110 curve.setCubicBounds(curvePts, 1, 0, 1, &bounds);
106 expected.set(0, 0, 5, 6); 111 expected.set(0, 0, 5, 6);
107 REPORTER_ASSERT(reporter, bounds == expected); 112 REPORTER_ASSERT(reporter, bounds == expected);
108 (bounds.*SetCurveBounds[SkPath::kCubic_Verb])(curvePts, 1); 113 (curve.*SetBounds[SkPath::kCubic_Verb])(curvePts, 1, 0, 1, &bounds);
109 REPORTER_ASSERT(reporter, bounds == expected); 114 REPORTER_ASSERT(reporter, bounds == expected);
110 } 115 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsSimplify.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698