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

Side by Side Diff: gm/hairlines.cpp

Issue 1502613002: add hairline with caps gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 } 212 }
213 canvas->restore(); 213 canvas->restore();
214 } 214 }
215 215
216 private: 216 private:
217 SkTArray<SkPath> fPaths; 217 SkTArray<SkPath> fPaths;
218 typedef GM INHERITED; 218 typedef GM INHERITED;
219 }; 219 };
220 220
221 static void draw_squarehair_tests(SkCanvas* canvas, SkScalar width, SkPaint::Cap cap, bool aa) {
222 SkPaint paint;
223 paint.setStrokeCap(cap);
224 paint.setStrokeWidth(width);
225 paint.setAntiAlias(aa);
226 paint.setStyle(SkPaint::kStroke_Style);
227 canvas->drawLine(10, 10, 20, 10, paint);
228 canvas->drawLine(30, 10, 30, 20, paint);
229 canvas->drawLine(40, 10, 50, 20, paint);
230 SkPath path;
231 path.moveTo(60, 10);
232 path.quadTo(60, 20, 70, 20);
233 path.conicTo(70, 10, 80, 10, 0.707f);
234 canvas->drawPath(path, paint);
235 path.reset();
236 path.moveTo(90, 10);
237 path.cubicTo(90, 20, 100, 20, 100, 10);
238 path.lineTo(110, 10);
239 canvas->drawPath(path, paint);
240 canvas->translate(0, 30);
241 }
242
243 DEF_SIMPLE_GM(squarehair, canvas, 240, 360) {
244 const bool aliases[] = { false, true };
245 const SkScalar widths[] = { 0, 0.999f, 1, 1.001f };
246 const SkPaint::Cap caps[] = { SkPaint::kButt_Cap, SkPaint::kSquare_Cap, SkPa int::kRound_Cap };
247 for (auto alias : aliases) {
248 canvas->save();
249 for (auto width : widths) {
250 for (auto cap : caps) {
251 draw_squarehair_tests(canvas, width, cap, alias);
252 }
253 }
254 canvas->restore();
255 canvas->translate(120, 0);
256 }
257 }
258
221 ////////////////////////////////////////////////////////////////////////////// 259 //////////////////////////////////////////////////////////////////////////////
222 260
223 static GM* MyFactory(void*) { return new HairlinesGM; } 261 static GM* MyFactory(void*) { return new HairlinesGM; }
224 static GMRegistry reg(MyFactory); 262 static GMRegistry reg(MyFactory);
225 263
226 } 264 }
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