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 "SkAAClip.h" | 8 #include "SkAAClip.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkMask.h" | 10 #include "SkMask.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 clip.setPath(path, NULL, 1 == i); | 311 clip.setPath(path, NULL, 1 == i); |
312 | 312 |
313 SkMask mask; | 313 SkMask mask; |
314 clip.copyToMask(&mask); | 314 clip.copyToMask(&mask); |
315 SkAutoMaskFreeImage freeM(mask.fImage); | 315 SkAutoMaskFreeImage freeM(mask.fImage); |
316 | 316 |
317 REPORTER_ASSERT(reporter, expected == mask); | 317 REPORTER_ASSERT(reporter, expected == mask); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 static void test_really_a_rect(skiatest::Reporter* reporter) { | |
322 SkRRect rrect; | |
323 rrect.setRectXY(SkRect::MakeWH(100, 100), 5, 5); | |
324 | |
325 SkPath path; | |
326 path.addRRect(rrect); | |
327 | |
328 SkAAClip clip; | |
329 clip.setPath(path); | |
330 | |
331 REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeWH(100, 100)); | |
332 REPORTER_ASSERT(reporter, !clip.isRect()); | |
333 | |
334 // This rect should intersect the clip, but slice-out all of the "soft" part
s, | |
335 // leaving just a rect. | |
336 const SkIRect ir = SkIRect::MakeLTRB(10, -10, 50, 90); | |
337 | |
338 clip.op(ir, SkRegion::kIntersect_Op); | |
339 | |
340 REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeLTRB(10, 0, 50, 9
0)); | |
341 // the clip recognized that that it is just a rect! | |
342 REPORTER_ASSERT(reporter, clip.isRect()); | |
343 } | |
344 | |
345 #include "SkRasterClip.h" | 321 #include "SkRasterClip.h" |
346 | 322 |
347 static void copyToMask(const SkRasterClip& rc, SkMask* mask) { | 323 static void copyToMask(const SkRasterClip& rc, SkMask* mask) { |
348 if (rc.isAA()) { | 324 if (rc.isAA()) { |
349 rc.aaRgn().copyToMask(mask); | 325 rc.aaRgn().copyToMask(mask); |
350 } else { | 326 } else { |
351 copyToMask(rc.bwRgn(), mask); | 327 copyToMask(rc.bwRgn(), mask); |
352 } | 328 } |
353 } | 329 } |
354 | 330 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 397 } |
422 | 398 |
423 DEF_TEST(AAClip, reporter) { | 399 DEF_TEST(AAClip, reporter) { |
424 test_empty(reporter); | 400 test_empty(reporter); |
425 test_path_bounds(reporter); | 401 test_path_bounds(reporter); |
426 test_irect(reporter); | 402 test_irect(reporter); |
427 test_rgn(reporter); | 403 test_rgn(reporter); |
428 test_path_with_hole(reporter); | 404 test_path_with_hole(reporter); |
429 test_regressions(); | 405 test_regressions(); |
430 test_nearly_integral(reporter); | 406 test_nearly_integral(reporter); |
431 test_really_a_rect(reporter); | |
432 } | 407 } |
OLD | NEW |