aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/clip_strokerect.cpp
diff options
context:
space:
mode:
authorGravatar george <george@mozilla.com>2014-09-09 11:33:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-09 11:33:57 -0700
commitb3eba478d5bed5fb2b5f0f224738c8c292cebf36 (patch)
tree0d1a4fee05c8292abd4544240afba10bb91e968a /gm/clip_strokerect.cpp
parent32673b99a4fb5d798206eb7665b730ed0b4597a0 (diff)
Outset the stroke width when computing the bounds for drawing a stroked rect, or 1 if it's a hairline
Adds a testcase for stroke rect bug R=reed@google.com, reed1 BUG=skia: Author: george@mozilla.com Review URL: https://codereview.chromium.org/552743004
Diffstat (limited to 'gm/clip_strokerect.cpp')
-rw-r--r--gm/clip_strokerect.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/gm/clip_strokerect.cpp b/gm/clip_strokerect.cpp
new file mode 100644
index 0000000000..707229214a
--- /dev/null
+++ b/gm/clip_strokerect.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2011 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"
+
+class ClipStrokeRectGM : public skiagm::GM {
+public:
+ ClipStrokeRectGM() {
+
+ }
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("clip_strokerect");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(200, 400);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(22);
+
+ SkRect r = SkRect::MakeXYWH(20, 20, 100, 100);
+ // setting the height of this to 19 causes failure
+ SkRect rect = SkRect::MakeXYWH(20, 0, 100, 20);
+
+ canvas->save();
+ canvas->clipRect(rect, SkRegion::kReplace_Op, true);
+ canvas->drawRect(r, p);
+ canvas->restore();
+
+ p.setColor(SK_ColorBLUE);
+ p.setStrokeWidth(2);
+ canvas->drawRect(rect, p);
+
+ p.setColor(SK_ColorRED);
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(22);
+
+ SkRect r2 = SkRect::MakeXYWH(20, 140, 100, 100);
+ // setting the height of this to 19 causes failure
+ SkRect rect2 = SkRect::MakeXYWH(20, 120, 100, 19);
+
+ canvas->save();
+ canvas->clipRect(rect2, SkRegion::kReplace_Op, true);
+ canvas->drawRect(r2, p);
+ canvas->restore();
+
+ p.setColor(SK_ColorBLUE);
+ p.setStrokeWidth(2);
+ canvas->drawRect(rect2, p);
+ }
+
+ virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(ClipStrokeRectGM); )
+