OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 "SkPath.h" |
| 9 #include "SkStream.h" |
| 10 #include "gm.h" |
| 11 |
| 12 // Test how short paths are stroked with various caps |
| 13 DEF_SIMPLE_GM(path_stroke_with_zero_length, canvas, 240, 120) { |
| 14 SkPath paths[5]; |
| 15 paths[0].moveTo(30.0f, 0); // single line segment |
| 16 paths[0].rLineTo(30.0f, 0); |
| 17 |
| 18 paths[1].moveTo(90.0f, 0); // single line segment with close |
| 19 paths[1].rLineTo(30.0f, 0); |
| 20 paths[1].close(); |
| 21 |
| 22 paths[2].moveTo(150.0f, 0); // zero-length line |
| 23 paths[2].rLineTo(0, 0); |
| 24 |
| 25 paths[3].moveTo(180.0f, 0); // zero-length line with close |
| 26 paths[3].rLineTo(0, 0); |
| 27 paths[3].close(); |
| 28 |
| 29 paths[4].moveTo(210.0f, 0); // close only, no line |
| 30 paths[4].close(); |
| 31 |
| 32 auto drawPaths = [&](const SkPaint& paint) { |
| 33 canvas->translate(0, 30.0f); |
| 34 for (const SkPath& path : paths) { |
| 35 canvas->drawPath(path, paint); |
| 36 } |
| 37 }; |
| 38 |
| 39 SkAutoCanvasRestore autoCanvasRestore(canvas, true); |
| 40 |
| 41 SkPaint butt; |
| 42 butt.setStyle(SkPaint::kStroke_Style); |
| 43 butt.setStrokeWidth(20.0f); |
| 44 butt.setStrokeCap(SkPaint::kButt_Cap); |
| 45 drawPaths(butt); |
| 46 |
| 47 SkPaint round(butt); |
| 48 round.setStrokeCap(SkPaint::kRound_Cap); |
| 49 drawPaths(round); |
| 50 |
| 51 SkPaint square(butt); |
| 52 square.setStrokeCap(SkPaint::kSquare_Cap); |
| 53 drawPaths(square); |
| 54 } |
OLD | NEW |