Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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, 400, 400) { | |
| 244 canvas->save(); | |
| 245 draw_squarehair_tests(canvas, 0, SkPaint::kButt_Cap, false); | |
| 246 draw_squarehair_tests(canvas, 0, SkPaint::kSquare_Cap, false); | |
|
reed1
2015/12/04 18:01:10
Wonder if adding 0.999 would be helpful.
caryclark
2015/12/04 20:55:15
Done.
| |
| 247 draw_squarehair_tests(canvas, 0, SkPaint::kRound_Cap, false); | |
| 248 draw_squarehair_tests(canvas, 1, SkPaint::kButt_Cap, false); | |
| 249 draw_squarehair_tests(canvas, 1, SkPaint::kSquare_Cap, false); | |
| 250 draw_squarehair_tests(canvas, 1, SkPaint::kRound_Cap, false); | |
| 251 draw_squarehair_tests(canvas, 1.001f, SkPaint::kButt_Cap, false); | |
| 252 draw_squarehair_tests(canvas, 1.001f, SkPaint::kSquare_Cap, false); | |
| 253 draw_squarehair_tests(canvas, 1.001f, SkPaint::kRound_Cap, false); | |
| 254 canvas->restore(); | |
| 255 canvas->translate(120, 0); | |
| 256 draw_squarehair_tests(canvas, 0, SkPaint::kButt_Cap, true); | |
| 257 draw_squarehair_tests(canvas, 0, SkPaint::kSquare_Cap, true); | |
| 258 draw_squarehair_tests(canvas, 0, SkPaint::kRound_Cap, true); | |
| 259 draw_squarehair_tests(canvas, 1, SkPaint::kButt_Cap, true); | |
| 260 draw_squarehair_tests(canvas, 1, SkPaint::kSquare_Cap, true); | |
| 261 draw_squarehair_tests(canvas, 1, SkPaint::kRound_Cap, true); | |
| 262 draw_squarehair_tests(canvas, 1.001f, SkPaint::kButt_Cap, true); | |
| 263 draw_squarehair_tests(canvas, 1.001f, SkPaint::kSquare_Cap, true); | |
| 264 draw_squarehair_tests(canvas, 1.001f, SkPaint::kRound_Cap, true); | |
| 265 } | |
| 266 | |
| 221 ////////////////////////////////////////////////////////////////////////////// | 267 ////////////////////////////////////////////////////////////////////////////// |
| 222 | 268 |
| 223 static GM* MyFactory(void*) { return new HairlinesGM; } | 269 static GM* MyFactory(void*) { return new HairlinesGM; } |
| 224 static GMRegistry reg(MyFactory); | 270 static GMRegistry reg(MyFactory); |
| 225 | 271 |
| 226 } | 272 } |
| OLD | NEW |