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

Side by Side Diff: gm/roundrects.cpp

Issue 2272703009: Add fat stroke test case to roundrects GM. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkTArray.h" 9 #include "SkTArray.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 29 matching lines...) Expand all
40 SkString onShortName() override { 40 SkString onShortName() override {
41 return SkString("roundrects"); 41 return SkString("roundrects");
42 } 42 }
43 43
44 SkISize onISize() override { 44 SkISize onISize() override {
45 return SkISize::Make(1200, 900); 45 return SkISize::Make(1200, 900);
46 } 46 }
47 47
48 void makePaints() { 48 void makePaints() {
49 { 49 {
50 // no AA 50 // no AA
51 SkPaint p; 51 SkPaint p;
52 fPaints.push_back(p); 52 fPaints.push_back(p);
53 } 53 }
54 54
55 { 55 {
56 // AA 56 // AA
57 SkPaint p; 57 SkPaint p;
58 p.setAntiAlias(true); 58 p.setAntiAlias(true);
59 fPaints.push_back(p); 59 fPaints.push_back(p);
60 } 60 }
61 61
62 { 62 {
63 // AA with stroke style 63 // AA with stroke style
64 SkPaint p; 64 SkPaint p;
65 p.setAntiAlias(true); 65 p.setAntiAlias(true);
66 p.setStyle(SkPaint::kStroke_Style); 66 p.setStyle(SkPaint::kStroke_Style);
67 p.setStrokeWidth(SkIntToScalar(5)); 67 p.setStrokeWidth(SkIntToScalar(5));
68 fPaints.push_back(p); 68 fPaints.push_back(p);
69 } 69 }
70 70
71 { 71 {
72 // AA with stroke style, width = 0 72 // AA with stroke style, width = 0
73 SkPaint p; 73 SkPaint p;
74 p.setAntiAlias(true); 74 p.setAntiAlias(true);
75 p.setStyle(SkPaint::kStroke_Style); 75 p.setStyle(SkPaint::kStroke_Style);
76 fPaints.push_back(p); 76 fPaints.push_back(p);
77 } 77 }
78 78
79 { 79 {
80 // AA with stroke and fill style 80 // AA with stroke and fill style
81 SkPaint p; 81 SkPaint p;
82 p.setAntiAlias(true); 82 p.setAntiAlias(true);
83 p.setStyle(SkPaint::kStrokeAndFill_Style); 83 p.setStyle(SkPaint::kStrokeAndFill_Style);
84 p.setStrokeWidth(SkIntToScalar(3)); 84 p.setStrokeWidth(SkIntToScalar(3));
85 fPaints.push_back(p); 85 fPaints.push_back(p);
86 } 86 }
87 } 87 }
88 88
89 void makeMatrices() { 89 void makeMatrices() {
90 { 90 {
91 SkMatrix m; 91 SkMatrix m;
92 m.setIdentity(); 92 m.setIdentity();
93 fMatrices.push_back(m); 93 fMatrices.push_back(m);
94 } 94 }
95 95
96 { 96 {
97 SkMatrix m; 97 SkMatrix m;
98 m.setScale(SkIntToScalar(3), SkIntToScalar(2)); 98 m.setScale(SkIntToScalar(3), SkIntToScalar(2));
99 fMatrices.push_back(m); 99 fMatrices.push_back(m);
100 } 100 }
101 101
102 { 102 {
103 SkMatrix m; 103 SkMatrix m;
104 m.setScale(SkIntToScalar(2), SkIntToScalar(2)); 104 m.setScale(SkIntToScalar(2), SkIntToScalar(2));
105 fMatrices.push_back(m); 105 fMatrices.push_back(m);
106 } 106 }
107 107
108 { 108 {
109 SkMatrix m; 109 SkMatrix m;
110 m.setScale(SkIntToScalar(1), SkIntToScalar(2)); 110 m.setScale(SkIntToScalar(1), SkIntToScalar(2));
111 fMatrices.push_back(m); 111 fMatrices.push_back(m);
112 } 112 }
113 113
114 { 114 {
115 SkMatrix m; 115 SkMatrix m;
116 m.setScale(SkIntToScalar(4), SkIntToScalar(1)); 116 m.setScale(SkIntToScalar(4), SkIntToScalar(1));
117 fMatrices.push_back(m); 117 fMatrices.push_back(m);
118 } 118 }
119 119
120 { 120 {
121 SkMatrix m; 121 SkMatrix m;
122 m.setRotate(SkIntToScalar(90)); 122 m.setRotate(SkIntToScalar(90));
123 fMatrices.push_back(m); 123 fMatrices.push_back(m);
124 } 124 }
125 125
126 { 126 {
127 SkMatrix m; 127 SkMatrix m;
128 m.setSkew(SkIntToScalar(2), SkIntToScalar(3)); 128 m.setSkew(SkIntToScalar(2), SkIntToScalar(3));
129 fMatrices.push_back(m); 129 fMatrices.push_back(m);
130 } 130 }
131 131
132 { 132 {
133 SkMatrix m; 133 SkMatrix m;
134 m.setRotate(SkIntToScalar(60)); 134 m.setRotate(SkIntToScalar(60));
135 fMatrices.push_back(m); 135 fMatrices.push_back(m);
136 } 136 }
137 } 137 }
138 138
139 void onDraw(SkCanvas* canvas) override { 139 void onDraw(SkCanvas* canvas) override {
140 SkRandom rand(1); 140 SkRandom rand(1);
141 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); 141 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
142 const SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30); 142 const SkRect rect = SkRect::MakeLTRB(-20, -30, 20, 30);
143 SkRRect circleRect; 143 SkRRect circleRect;
144 circleRect.setRectXY(rect, 5, 5); 144 circleRect.setRectXY(rect, 5, 5);
145 145
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 const SkColor color = gen_color(&rand); 330 const SkColor color = gen_color(&rand);
331 331
332 SkPaint p; 332 SkPaint p;
333 p.setColor(color); 333 p.setColor(color);
334 334
335 const SkRect oooRect = { 20, 30, -20, -30 }; // intentionally ou t of order 335 const SkRect oooRect = { 20, 30, -20, -30 }; // intentionally ou t of order
336 canvas->drawRoundRect(oooRect, 10, 10, p); 336 canvas->drawRoundRect(oooRect, 10, 10, p);
337 337
338 canvas->restore(); 338 canvas->restore();
339 } 339 }
340
341 // rrect with stroke > radius/2
342 {
343 SkRect smallRect = { -30, -20, 30, 20 };
344 SkRRect circleRect;
345 circleRect.setRectXY(smallRect, 5, 5);
346
347 canvas->save();
348 // position the roundrect, and make it at off-integer coords.
349 canvas->translate(kXStart + SK_Scalar1 * kXStep * 5 + SK_Scalar1 / 4 ,
350 kYStart - SK_Scalar1 * kYStep + 73 * SK_Scalar1 / 4 +
351 SK_ScalarHalf * kYStep);
352
353 SkColor color = gen_color(&rand);
354
355 SkPaint p;
356 p.setAntiAlias(true);
357 p.setStyle(SkPaint::kStroke_Style);
358 p.setStrokeWidth(25);
359 p.setColor(color);
360
361 canvas->drawRRect(circleRect, p);
362 canvas->restore();
363 }
340 } 364 }
341 365
342 private: 366 private:
343 SkTArray<SkPaint> fPaints; 367 SkTArray<SkPaint> fPaints;
344 SkTArray<SkMatrix> fMatrices; 368 SkTArray<SkMatrix> fMatrices;
345 369
346 typedef GM INHERITED; 370 typedef GM INHERITED;
347 }; 371 };
348 372
349 ////////////////////////////////////////////////////////////////////////////// 373 //////////////////////////////////////////////////////////////////////////////
350 374
351 static GM* MyFactory(void*) { return new RoundRectGM; } 375 static GM* MyFactory(void*) { return new RoundRectGM; }
352 static GMRegistry reg(MyFactory); 376 static GMRegistry reg(MyFactory);
353 377
354 } 378 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698