fix non-square stroke rects (non-aa)
fiddle showing bug: https://fiddle.skia.org/c/a21ecf5e33da84f52eba26e8c2f3d280
BUG=skia:5408
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2060543002
Review-Url: https://codereview.chromium.org/2060543002
diff --git a/gm/strokerect.cpp b/gm/strokerect.cpp
index f7e3605..a1c8bb8 100644
--- a/gm/strokerect.cpp
+++ b/gm/strokerect.cpp
@@ -110,7 +110,20 @@
private:
typedef GM INHERITED;
};
+DEF_GM(return new StrokeRectGM;)
///////////////////////////////////////////////////////////////////////////////////////////////////
-DEF_GM(return new StrokeRectGM;)
+/*
+ * Exercise rect-stroking (which is specialized from paths) when the resulting stroke-width is
+ * non-square. See https://bugs.chromium.org/p/skia/issues/detail?id=5408
+ */
+DEF_SIMPLE_GM(strokerect_anisotropic_5408, canvas, 200, 50) {
+ SkPaint p;
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(6);
+
+ canvas->scale(10, 1);
+ SkRect r = SkRect::MakeXYWH(5, 20, 10, 10);
+ canvas->drawRect(r, p);
+}
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index fc9e828..083dc0d 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -641,7 +641,7 @@
outer.set(r.fLeft - rx, r.fTop - ry,
r.fRight + rx, r.fBottom + ry);
- if (r.width() <= dx || r.height() <= dx) {
+ if (r.width() <= dx || r.height() <= dy) {
SkScan::FillRect(outer, clip, blitter);
return;
}