Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: gm/clip_strokerect.cpp

Issue 552743004: Outset the stroke width when computing the bounds for drawing a stroked rect, or 1 if it's a hairli… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkScalarHalf Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/clip_strokerect.cpp
diff --git a/gm/clip_strokerect.cpp b/gm/clip_strokerect.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..707229214a004c642c2f1a765db8c2669654689d
--- /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); )
+
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698