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

Unified Diff: skia/ext/analysis_canvas_unittest.cc

Issue 2449583002: Support rrect clips in analysis canvas (Closed)
Patch Set: Address reviewer feedback. Created 4 years, 2 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 | « skia/ext/analysis_canvas.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/analysis_canvas_unittest.cc
diff --git a/skia/ext/analysis_canvas_unittest.cc b/skia/ext/analysis_canvas_unittest.cc
index 73750325c8bfac490d822dcbfe8fb128458c5eb1..f64722a5dec95354aeb3255396d9f3bb9c6db86c 100644
--- a/skia/ext/analysis_canvas_unittest.cc
+++ b/skia/ext/analysis_canvas_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/compiler_specific.h"
+#include "base/macros.h"
#include "skia/ext/analysis_canvas.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkPicture.h"
@@ -388,4 +389,67 @@ TEST(AnalysisCanvasTest, ClipComplexRegion) {
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
}
+TEST(AnalysisCanvasTest, ClipRRectCoversCanvas) {
+
+ SkVector radii[4] = {
+ SkVector::Make(10.0, 15.0),
+ SkVector::Make(20.0, 25.0),
+ SkVector::Make(30.0, 35.0),
+ SkVector::Make(40.0, 45.0),
+ };
+
+ int rr_size = 600;
+ int canvas_size = 255;
+
+ struct {
+ SkVector offset;
+ bool expected;
+ } cases [] = {
+ // Not within bounding box of |rr|.
+ { SkVector::Make(100.0, 100.0), false },
+
+ // Intersects UL corner.
+ { SkVector::Make(0.0, 0.0), false },
+
+ // Between UL and UR.
+ { SkVector::Make(-50.0, 0), true },
+
+ // Intersects UR corner.
+ { SkVector::Make(canvas_size - rr_size, 0), false },
+
+ // Between UR and LR.
+ { SkVector::Make(canvas_size - rr_size, -50.0), true },
+
+ // Intersects LR corner.
+ { SkVector::Make(canvas_size - rr_size, canvas_size - rr_size), false },
+
+ // Between LL and LR
+ { SkVector::Make(-50, canvas_size - rr_size), true },
+
+ // Intersects LL corner
+ { SkVector::Make(0, canvas_size - rr_size), false },
+
+ // Between UL and LL
+ { SkVector::Make(0, -50), true },
+
+ // In center
+ { SkVector::Make(-100, -100), true},
+ };
+
+ SkColor outputColor;
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ skia::AnalysisCanvas canvas(canvas_size, canvas_size);
+
+ SkRect bounding_rect = SkRect::MakeXYWH(
+ cases[i].offset.x(), cases[i].offset.y(), rr_size, rr_size);
+
+ SkRRect rr;
+ rr.setRectRadii(bounding_rect, radii);
+
+ canvas.clipRRect(rr);
+ EXPECT_EQ(cases[i].expected, canvas.GetColorIfSolid(&outputColor)) << i;
+ }
+}
+
} // namespace skia
« no previous file with comments | « skia/ext/analysis_canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698