aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/clipdrawdraw.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-01-14 09:44:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-14 09:44:02 -0800
commit028b98a08072bd1764936e47c54fa2da5cf92744 (patch)
tree49908922918fa08a1dcde4c53a467fdb4ec81cde /gm/clipdrawdraw.cpp
parent7c348a8097db763cecd3f9703f39714196ab7ec5 (diff)
Add repro GM for GPU clipped-AA vs. non-AA drawRect discrepancy
In the clip stack we were manually rounding out non-AA clip rects but leaving the hardening of non-AA drawRects up to the GPU. In some border cases the GPU can truncate rather than round out resulting in visual discrepancies. BUG=423834 Committed: https://skia.googlesource.com/skia/+/933a03fecb65c83f81cf65d5cf9870c69aa379ff Review URL: https://codereview.chromium.org/839883003
Diffstat (limited to 'gm/clipdrawdraw.cpp')
-rw-r--r--gm/clipdrawdraw.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/gm/clipdrawdraw.cpp b/gm/clipdrawdraw.cpp
new file mode 100644
index 0000000000..0e471dd148
--- /dev/null
+++ b/gm/clipdrawdraw.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2014 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"
+
+namespace skiagm {
+
+// This GM exercises the use case found in crbug.com/423834.
+// The following pattern:
+// clipRect(r);
+// drawRect(r, withAA);
+// drawRect(r, noAA);
+// can leave 1 pixel wide remnants of the first rect.
+class ClipDrawDrawGM : public GM {
+public:
+ ClipDrawDrawGM() {
+ this->setBGColor(0xFFCCCCCC);
+ }
+
+protected:
+ SkString onShortName() SK_OVERRIDE {
+ return SkString("clipdrawdraw");
+ }
+
+ SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(512, 512);
+ }
+
+ // Vertical remnant
+ static void draw1(SkCanvas* canvas) {
+ SkPaint p;
+ p.setAntiAlias(true);
+
+ const SkRect rect = SkRect::MakeXYWH(8, 9, 404, 313);
+
+ canvas->save();
+
+ canvas->scale(0.5f, 0.5f);
+ canvas->translate(265, 265);
+
+ canvas->save();
+ canvas->clipRect(rect);
+ canvas->drawRect(rect, p);
+ canvas->restore();
+
+ p.setColor(SK_ColorWHITE);
+ p.setAntiAlias(false);
+ canvas->drawRect(rect, p);
+ canvas->restore();
+ }
+
+ // Horizontal remnant
+ static void draw2(SkCanvas* canvas) {
+ SkPaint p;
+ p.setAntiAlias(true);
+
+ const SkRect rect = SkRect::MakeXYWH(8, 9, 404, 313);
+
+ canvas->save();
+
+ canvas->translate(200.800003f, 172.299988f);
+ canvas->scale(0.8f, 0.8f);
+
+ canvas->save();
+ canvas->clipRect(rect);
+ canvas->drawRect(rect, p);
+ canvas->restore();
+
+ p.setColor(SK_ColorWHITE);
+ p.setAntiAlias(false);
+ canvas->drawRect(rect, p);
+ canvas->restore();
+ }
+
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ draw1(canvas);
+ draw2(canvas);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM(return SkNEW(ClipDrawDrawGM);)
+
+}