| 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 |
| 321 #include "SkRasterClip.h" | 345 #include "SkRasterClip.h" |
| 322 | 346 |
| 323 static void copyToMask(const SkRasterClip& rc, SkMask* mask) { | 347 static void copyToMask(const SkRasterClip& rc, SkMask* mask) { |
| 324 if (rc.isAA()) { | 348 if (rc.isAA()) { |
| 325 rc.aaRgn().copyToMask(mask); | 349 rc.aaRgn().copyToMask(mask); |
| 326 } else { | 350 } else { |
| 327 copyToMask(rc.bwRgn(), mask); | 351 copyToMask(rc.bwRgn(), mask); |
| 328 } | 352 } |
| 329 } | 353 } |
| 330 | 354 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 421 } |
| 398 | 422 |
| 399 DEF_TEST(AAClip, reporter) { | 423 DEF_TEST(AAClip, reporter) { |
| 400 test_empty(reporter); | 424 test_empty(reporter); |
| 401 test_path_bounds(reporter); | 425 test_path_bounds(reporter); |
| 402 test_irect(reporter); | 426 test_irect(reporter); |
| 403 test_rgn(reporter); | 427 test_rgn(reporter); |
| 404 test_path_with_hole(reporter); | 428 test_path_with_hole(reporter); |
| 405 test_regressions(); | 429 test_regressions(); |
| 406 test_nearly_integral(reporter); | 430 test_nearly_integral(reporter); |
| 431 test_really_a_rect(reporter); |
| 407 } | 432 } |
| OLD | NEW |