OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkRRect.h" | 10 #include "SkRRect.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 void onDraw(SkCanvas* canvas) override { | 38 void onDraw(SkCanvas* canvas) override { |
39 SkPaint paint; | 39 SkPaint paint; |
40 SkPath path; | 40 SkPath path; |
41 paint.setStyle(SkPaint::Style::kStroke_Style); | 41 paint.setStyle(SkPaint::Style::kStroke_Style); |
42 canvas->translate(5.0f, 5.0f); | 42 canvas->translate(5.0f, 5.0f); |
43 const SkScalar size = 60.0f; | 43 const SkScalar size = 60.0f; |
44 for (int i = 0; i < 2; i++) { | 44 for (int i = 0; i < 2; i++) { |
45 paint.setAntiAlias(i == 1); | 45 paint.setAntiAlias(i == 1); |
46 canvas->save(); | |
47 for (int j = 0; j < 4; j++) { | 46 for (int j = 0; j < 4; j++) { |
48 SkScalar scale = 4.0f - j; | 47 SkScalar scale = 4.0f - j; |
49 paint.setStrokeWidth(4.0f / scale); | 48 paint.setStrokeWidth(4.0f / scale); |
50 canvas->save(); | 49 canvas->save(); |
51 canvas->translate(size / 2.0f, size / 2.0f); | 50 canvas->translate(size / 2.0f, size / 2.0f); |
52 canvas->scale(scale, scale); | 51 canvas->scale(scale, scale); |
53 draw_path(size / 2.0f / scale, canvas, paint); | 52 draw_path(size / 2.0f / scale, canvas, paint); |
54 canvas->restore(); | 53 canvas->restore(); |
55 | 54 |
56 canvas->save(); | 55 canvas->save(); |
57 canvas->translate(size / 2.0f, 80.0f + size / 2.0f); | 56 canvas->translate(size / 2.0f, 80.0f + size / 2.0f); |
58 canvas->scale(scale, scale); | 57 canvas->scale(scale, scale); |
59 canvas->drawCircle(0.0f, 0.0f, size / 2.0f / scale, paint); | 58 canvas->drawCircle(0.0f, 0.0f, size / 2.0f / scale, paint); |
60 canvas->restore(); | 59 canvas->restore(); |
61 | 60 |
62 canvas->save(); | 61 canvas->save(); |
63 canvas->translate(0.0f, 160.0f); | 62 canvas->translate(0.0f, 160.0f); |
64 canvas->scale(scale, scale); | 63 canvas->scale(scale, scale); |
65 canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, size / scale, size
/ scale), paint); | 64 canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, size / scale, size
/ scale), paint); |
66 canvas->restore(); | 65 canvas->restore(); |
67 | 66 |
68 canvas->save(); | 67 canvas->save(); |
69 canvas->translate(0.0f, 240.0f); | 68 canvas->translate(0.0f, 240.0f); |
70 canvas->scale(scale, scale); | 69 canvas->scale(scale, scale); |
71 canvas->drawLine(0.0f, 0.0f, size / scale, size / scale, paint); | 70 canvas->drawLine(0.0f, 0.0f, size / scale, size / scale, paint); |
72 canvas->restore(); | 71 canvas->restore(); |
73 | 72 |
74 canvas->translate(80.0f, 0.0f); | 73 canvas->translate(80.0f, 0.0f); |
75 } | 74 } |
76 canvas->restore(); | |
77 } | 75 } |
78 | 76 |
79 } | 77 } |
80 | 78 |
81 private: | 79 private: |
82 typedef GM INHERITED; | 80 typedef GM INHERITED; |
83 }; | 81 }; |
84 | 82 |
85 DEF_GM( return new ScaledStrokesGM; ) | 83 DEF_GM( return new ScaledStrokesGM; ) |
OLD | NEW |