Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: tests/AAClipTest.cpp

Issue 443353004: add isRect() check to AAClip, to detect if a soft-clip is really just an irect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRasterClip.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/AAClipTest.cpp
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index 26c1ec1d0e21c30e2ce40095ed46a24dd497f92d..776cd5267ab6a4a31022394072f78fe4cd462b2d 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);
}
« no previous file with comments | « src/core/SkRasterClip.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698