diff options
author | Mike Reed <reed@google.com> | 2017-03-02 15:21:11 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-02 21:02:39 +0000 |
commit | cd667b6e581b5f3060caf7a959ac6ef50fd33266 (patch) | |
tree | 7ca4a24ebce1210a42062eb85122dae2dd1ff7b2 | |
parent | fe3b51636d4216c4ea6cb74ed0964c1d315ca487 (diff) |
add unittests for clip-state queries
BUG=skia:
Change-Id: I6f8d5a0e78c5b41caa6c6388f7f2ace050ed08ac
Reviewed-on: https://skia-review.googlesource.com/9171
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
-rw-r--r-- | tests/CanvasTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index c947ce42ad..af18938bc5 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -813,3 +813,32 @@ DEF_TEST(CanvasStack, r) { REPORTER_ASSERT(r, !life[0]); REPORTER_ASSERT(r, !life[1]); } + +DEF_TEST(CanvasClipType, r) { + sk_sp<SkSurface> surf = SkSurface::MakeRasterN32Premul(10, 10); + SkCanvas* canvas = surf->getCanvas(); + + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); + + canvas->save(); + canvas->clipRect({0, 0, 0, 0}); + REPORTER_ASSERT(r, canvas->isClipEmpty()); + REPORTER_ASSERT(r, !canvas->isClipRect()); + canvas->restore(); + + canvas->save(); + canvas->clipRect({2, 2, 6, 6}); + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); + canvas->restore(); + + canvas->save(); + canvas->clipRect({2, 2, 6, 6}, SkClipOp::kDifference); // punch a hole in the clip + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, !canvas->isClipRect()); + canvas->restore(); + + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); +} |