aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/bug6783.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-06-22 11:00:17 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-22 19:46:51 +0000
commit0cc60b8bbd251efbeb374815395ea3e5fb62e184 (patch)
tree9c8cf5bd9610027a660ec5f34a5f4343a57f1176 /gm/bug6783.cpp
parent915893167e69f79677b17f3f388072e65d80d083 (diff)
fix repeat/mirror sampling bleed
I think this has been broken since we tried to simplify this in https://skia-review.googlesource.com/16547 The HSW backend does still look a little wrong, but improved, and the others seem fixed. Can you see how this affects your test cases, layout tests, etc? BUG=skia:6783 Change-Id: I17957ac8100331bea5b64d674bf43105048b72f6 Reviewed-on: https://skia-review.googlesource.com/20548 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'gm/bug6783.cpp')
-rw-r--r--gm/bug6783.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/gm/bug6783.cpp b/gm/bug6783.cpp
new file mode 100644
index 0000000000..5b54e1ce6a
--- /dev/null
+++ b/gm/bug6783.cpp
@@ -0,0 +1,47 @@
+/*
+* 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 "SkSurface.h"
+
+// This GM reproduces skia:6783, which demonstrated a bug in repeat and mirror
+// image sampling tiling modes as implemented in software. We want to tile to
+// [0,limit), and the old incorrect logic was:
+//
+// limit = ulp_before(limit)
+// val = val - floor(val/limit)*limit (This is repeat; mirror is similar.)
+//
+// while the correct logic is more like:
+//
+// val = val - floor(val/limit)*limit
+// val = min(val, ulp_before(limit))
+//
+// You would see ugly jaggies on the blue/yellow edge near the bottom left if
+// the bug were still present. All stripes should now look roughly the same.
+
+DEF_SIMPLE_GM(bug6783, canvas, 500, 500) {
+ sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+
+ SkPaint p;
+ p.setColor(SK_ColorYELLOW);
+ surface->getCanvas()->drawPaint(p);
+ p.setColor(SK_ColorBLUE);
+ surface->getCanvas()->drawRect(SkRect::MakeWH(50, 100), p);
+
+ sk_sp<SkImage> img = surface->makeImageSnapshot();
+
+ SkMatrix m = SkMatrix::Concat(SkMatrix::MakeTrans(25, 214),
+ SkMatrix::MakeScale(2, 2));
+ m.preSkew(0.5f, 0.5f);
+
+ // The bug was present at all filter levels, but you might not notice it at kNone.
+ p.setFilterQuality(kLow_SkFilterQuality);
+
+ // It's only important to repeat or mirror in x to show off the bug.
+ p.setShader(img->makeShader(SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode, &m));
+ canvas->drawPaint(p);
+}