aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Stephen White <senorblanco@chromium.org>2017-01-11 16:19:26 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-12 05:28:22 +0000
commite7a364d435843a868dcac2c61d78c34e5d3e326c (patch)
tree84721c5bdee36d75db59c18677812cc0006b14f8 /gm
parente4ca362259a36458cce94a5e643a11306037e8d6 (diff)
GrTessellator: fix artifact with exactly-1-px-wide edges.
When path features are exactly a pixel wide, the extruded inner edges can become collinear and then be removed, since their winding is zero. We need these edges to be preserved through triangulation, otherwise opaque portions of the geometry can become transparent. Since the simplify() pass can handle zero-winding edges just fine, the the fix is to simply not remove them. In addition, this changes refactors out disconnect() from all the calls to remove_edge_above()/remove_edge_below(). It also renames the remaining function erase_edge() (since it's now unconditional). Add a new test to a new "thinconcavepaths" GM. BUG=680260 NOTRY=true Change-Id: I1d3a436c95a01c4d4ef5dc05503de4312677f65d Reviewed-on: https://skia-review.googlesource.com/6902 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephan White <senorblanco@chromium.org>
Diffstat (limited to 'gm')
-rw-r--r--gm/thinconcavepaths.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/gm/thinconcavepaths.cpp b/gm/thinconcavepaths.cpp
new file mode 100644
index 0000000000..6c81d7c272
--- /dev/null
+++ b/gm/thinconcavepaths.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkPath.h"
+
+#define WIDTH 400
+#define HEIGHT 400
+
+namespace {
+// Test thin stroked rect (stroked "by hand", not by stroking).
+void draw_thin_stroked_rect(SkCanvas* canvas, const SkPaint& paint, SkScalar width) {
+ SkPath path;
+ path.moveTo(10 + width, 10 + width);
+ path.lineTo(40, 10 + width);
+ path.lineTo(40, 20);
+ path.lineTo(10 + width, 20);
+ path.moveTo(10, 10);
+ path.lineTo(10, 20 + width);
+ path.lineTo(40 + width, 20 + width);
+ path.lineTo(40 + width, 10);
+ canvas->drawPath(path, paint);
+}
+
+};
+
+class ThinConcavePathsGM : public skiagm::GM {
+public:
+ ThinConcavePathsGM() {}
+
+protected:
+ SkString onShortName() override {
+ return SkString("thinconcavepaths");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(WIDTH, HEIGHT);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPaint paint;
+
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ canvas->save();
+ for (SkScalar width = 1.0; width < 2.05; width += 0.25) {
+ draw_thin_stroked_rect(canvas, paint, width);
+ canvas->translate(0, 25);
+ }
+ canvas->restore();
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return new ThinConcavePathsGM; )