| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
| 8 #include "SkPath.h" |
| 8 #include "SkRandom.h" | 9 #include "SkRandom.h" |
| 9 #include "SkRegion.h" | 10 #include "SkRegion.h" |
| 10 #include "Test.h" | 11 #include "Test.h" |
| 11 | 12 |
| 12 static void Union(SkRegion* rgn, const SkIRect& rect) { | 13 static void Union(SkRegion* rgn, const SkIRect& rect) { |
| 13 rgn->op(rect, SkRegion::kUnion_Op); | 14 rgn->op(rect, SkRegion::kUnion_Op); |
| 14 } | 15 } |
| 15 | 16 |
| 16 #define TEST_NO_INTERSECT(rgn, rect) REPORTER_ASSERT(reporter, !rgn.intersect
s(rect)) | 17 #define TEST_NO_INTERSECT(rgn, rect) REPORTER_ASSERT(reporter, !rgn.intersect
s(rect)) |
| 17 #define TEST_INTERSECT(rgn, rect) REPORTER_ASSERT(reporter, rgn.intersects
(rect)) | 18 #define TEST_INTERSECT(rgn, rect) REPORTER_ASSERT(reporter, rgn.intersects
(rect)) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 REPORTER_ASSERT(reporter, !valid.isEmpty()); | 85 REPORTER_ASSERT(reporter, !valid.isEmpty()); |
| 85 | 86 |
| 86 // test intersects | 87 // test intersects |
| 87 REPORTER_ASSERT(reporter, !empty.intersects(empty2)); | 88 REPORTER_ASSERT(reporter, !empty.intersects(empty2)); |
| 88 REPORTER_ASSERT(reporter, !valid.intersects(empty)); | 89 REPORTER_ASSERT(reporter, !valid.intersects(empty)); |
| 89 | 90 |
| 90 // test contains | 91 // test contains |
| 91 REPORTER_ASSERT(reporter, !empty.contains(empty2)); | 92 REPORTER_ASSERT(reporter, !empty.contains(empty2)); |
| 92 REPORTER_ASSERT(reporter, !valid.contains(empty)); | 93 REPORTER_ASSERT(reporter, !valid.contains(empty)); |
| 93 REPORTER_ASSERT(reporter, !empty.contains(valid)); | 94 REPORTER_ASSERT(reporter, !empty.contains(valid)); |
| 95 |
| 96 SkPath emptyPath; |
| 97 emptyPath.moveTo(1, 5); |
| 98 emptyPath.close(); |
| 99 SkRegion openClip; |
| 100 openClip.setRect(-16000, -16000, 16000, 16000); |
| 101 empty.setPath(emptyPath, openClip); // should not assert |
| 94 } | 102 } |
| 95 | 103 |
| 96 enum { | 104 enum { |
| 97 W = 256, | 105 W = 256, |
| 98 H = 256 | 106 H = 256 |
| 99 }; | 107 }; |
| 100 | 108 |
| 101 static SkIRect randRect(SkRandom& rand) { | 109 static SkIRect randRect(SkRandom& rand) { |
| 102 int x = rand.nextU() % W; | 110 int x = rand.nextU() % W; |
| 103 int y = rand.nextU() % H; | 111 int y = rand.nextU() % H; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 rand_rect(&rect[j], rand); | 255 rand_rect(&rect[j], rand); |
| 248 } | 256 } |
| 249 REPORTER_ASSERT(reporter, test_rects(rect, N)); | 257 REPORTER_ASSERT(reporter, test_rects(rect, N)); |
| 250 } | 258 } |
| 251 | 259 |
| 252 test_proc(reporter, contains_proc); | 260 test_proc(reporter, contains_proc); |
| 253 test_proc(reporter, intersects_proc); | 261 test_proc(reporter, intersects_proc); |
| 254 test_empties(reporter); | 262 test_empties(reporter); |
| 255 test_fromchrome(reporter); | 263 test_fromchrome(reporter); |
| 256 } | 264 } |
| OLD | NEW |