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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkPath.h"
11
12 class ClipStrokeRectGM : public skiagm::GM {
13 public:
14 ClipStrokeRectGM() {
15
16 }
17
18 protected:
19 virtual SkString onShortName() SK_OVERRIDE {
20 return SkString("clip_strokerect");
21 }
22
23 virtual SkISize onISize() SK_OVERRIDE {
24 return SkISize::Make(200, 400);
25 }
26
27 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
28 SkPaint p;
29 p.setColor(SK_ColorRED);
30 p.setAntiAlias(true);
31 p.setStyle(SkPaint::kStroke_Style);
32 p.setStrokeWidth(22);
33
34 SkRect r = SkRect::MakeXYWH(20, 20, 100, 100);
35 // setting the height of this to 19 causes failure
36 SkRect rect = SkRect::MakeXYWH(20, 0, 100, 20);
37
38 canvas->save();
39 canvas->clipRect(rect, SkRegion::kReplace_Op, true);
40 canvas->drawRect(r, p);
41 canvas->restore();
42
43 p.setColor(SK_ColorBLUE);
44 p.setStrokeWidth(2);
45 canvas->drawRect(rect, p);
46
47 p.setColor(SK_ColorRED);
48 p.setAntiAlias(true);
49 p.setStyle(SkPaint::kStroke_Style);
50 p.setStrokeWidth(22);
51
52 SkRect r2 = SkRect::MakeXYWH(20, 140, 100, 100);
53 // setting the height of this to 19 causes failure
54 SkRect rect2 = SkRect::MakeXYWH(20, 120, 100, 19);
55
56 canvas->save();
57 canvas->clipRect(rect2, SkRegion::kReplace_Op, true);
58 canvas->drawRect(r2, p);
59 canvas->restore();
60
61 p.setColor(SK_ColorBLUE);
62 p.setStrokeWidth(2);
63 canvas->drawRect(rect2, p);
64 }
65
66 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; }
67
68 private:
69 typedef skiagm::GM INHERITED;
70 };
71
72 DEF_GM( return SkNEW(ClipStrokeRectGM); )
73
OLDNEW
« 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