aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-08-07 09:20:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-07 09:20:12 -0700
commit592cb8d552556b1e922887d506d00b64bc5d0547 (patch)
tree339dec7609c69661b75dae70c8d4c928fc324c20 /tests
parentbb204f4917aff10fcb65d29a2d96e53a9611c559 (diff)
add isRect() check to AAClip, to detect if a soft-clip is really just an irect
BUG=skia: R=bsalomon@google.com, humper@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/445233006
Diffstat (limited to 'tests')
-rw-r--r--tests/AAClipTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index 26c1ec1d0e..776cd5267a 100644
--- a/tests/AAClipTest.cpp
+++ b/tests/AAClipTest.cpp
@@ -318,6 +318,30 @@ static void test_path_with_hole(skiatest::Reporter* reporter) {
}
}
+static void test_really_a_rect(skiatest::Reporter* reporter) {
+ SkRRect rrect;
+ rrect.setRectXY(SkRect::MakeWH(100, 100), 5, 5);
+
+ SkPath path;
+ path.addRRect(rrect);
+
+ SkAAClip clip;
+ clip.setPath(path);
+
+ REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeWH(100, 100));
+ REPORTER_ASSERT(reporter, !clip.isRect());
+
+ // This rect should intersect the clip, but slice-out all of the "soft" parts,
+ // leaving just a rect.
+ const SkIRect ir = SkIRect::MakeLTRB(10, -10, 50, 90);
+
+ clip.op(ir, SkRegion::kIntersect_Op);
+
+ REPORTER_ASSERT(reporter, clip.getBounds() == SkIRect::MakeLTRB(10, 0, 50, 90));
+ // the clip recognized that that it is just a rect!
+ REPORTER_ASSERT(reporter, clip.isRect());
+}
+
#include "SkRasterClip.h"
static void copyToMask(const SkRasterClip& rc, SkMask* mask) {
@@ -404,4 +428,5 @@ DEF_TEST(AAClip, reporter) {
test_path_with_hole(reporter);
test_regressions();
test_nearly_integral(reporter);
+ test_really_a_rect(reporter);
}