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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; | 64 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; |
65 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; | 65 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; |
66 canvas->translate(x, y); | 66 canvas->translate(x, y); |
67 } | 67 } |
68 | 68 |
69 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 69 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
70 // Stroke widths are: | 70 // Stroke widths are: |
71 // 0(may use hairline rendering), 10(common case for stroke-style) | 71 // 0(may use hairline rendering), 10(common case for stroke-style) |
72 // 40 and 50(>= geometry width/height, make the contour filled in fact) | 72 // 40 and 50(>= geometry width/height, make the contour filled in fact) |
73 static const int kStrokeWidth[] = {0, 10, 40, 50}; | 73 static const int kStrokeWidth[] = {0, 10, 40, 50}; |
74 size_t numWidths = SK_ARRAY_COUNT(kStrokeWidth); | 74 int numWidths = SK_ARRAY_COUNT(kStrokeWidth); |
75 | 75 |
76 static const SkPaint::Style kStyle[] = { | 76 static const SkPaint::Style kStyle[] = { |
77 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style | 77 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style |
78 }; | 78 }; |
79 | 79 |
80 static const SkPaint::Cap kCap[] = { | 80 static const SkPaint::Cap kCap[] = { |
81 SkPaint::kButt_Cap, SkPaint::kRound_Cap, SkPaint::kSquare_Cap | 81 SkPaint::kButt_Cap, SkPaint::kRound_Cap, SkPaint::kSquare_Cap |
82 }; | 82 }; |
83 | 83 |
84 static const SkPaint::Join kJoin[] = { | 84 static const SkPaint::Join kJoin[] = { |
85 SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join | 85 SkPaint::kMiter_Join, SkPaint::kRound_Join, SkPaint::kBevel_Join |
86 }; | 86 }; |
87 | 87 |
88 static const ClosureType kType[] = { | 88 static const ClosureType kType[] = { |
89 TotallyNonClosed, FakeCloseCorner, FakeCloseMiddle | 89 TotallyNonClosed, FakeCloseCorner, FakeCloseMiddle |
90 }; | 90 }; |
91 | 91 |
92 int counter = 0; | 92 int counter = 0; |
93 SkPaint paint; | 93 SkPaint paint; |
94 paint.setAntiAlias(true); | 94 paint.setAntiAlias(true); |
95 | 95 |
96 // For stroke style painter and fill-and-stroke style painter | 96 // For stroke style painter and fill-and-stroke style painter |
97 for (size_t type = 0; type < kClosureTypeCount; ++type) { | 97 for (size_t type = 0; type < kClosureTypeCount; ++type) { |
98 for (size_t style = 0; style < SK_ARRAY_COUNT(kStyle); ++style) { | 98 for (size_t style = 0; style < SK_ARRAY_COUNT(kStyle); ++style) { |
99 for (size_t cap = 0; cap < SK_ARRAY_COUNT(kCap); ++cap) { | 99 for (size_t cap = 0; cap < SK_ARRAY_COUNT(kCap); ++cap) { |
100 for (size_t join = 0; join < SK_ARRAY_COUNT(kJoin); ++join)
{ | 100 for (size_t join = 0; join < SK_ARRAY_COUNT(kJoin); ++join)
{ |
101 for (size_t width = 0; width < numWidths; ++width) { | 101 for (int width = 0; width < numWidths; ++width) { |
102 canvas->save(); | 102 canvas->save(); |
103 SetLocation(canvas, counter, SkPaint::kJoinCount * n
umWidths); | 103 SetLocation(canvas, counter, SkPaint::kJoinCount * n
umWidths); |
104 | 104 |
105 SkPath path; | 105 SkPath path; |
106 MakePath(&path, kType[type]); | 106 MakePath(&path, kType[type]); |
107 | 107 |
108 paint.setStyle(kStyle[style]); | 108 paint.setStyle(kStyle[style]); |
109 paint.setStrokeCap(kCap[cap]); | 109 paint.setStrokeCap(kCap[cap]); |
110 paint.setStrokeJoin(kJoin[join]); | 110 paint.setStrokeJoin(kJoin[join]); |
111 paint.setStrokeWidth(SkIntToScalar(kStrokeWidth[widt
h])); | 111 paint.setStrokeWidth(SkIntToScalar(kStrokeWidth[widt
h])); |
(...skipping 24 matching lines...) Expand all Loading... |
136 | 136 |
137 private: | 137 private: |
138 typedef GM INHERITED; | 138 typedef GM INHERITED; |
139 }; | 139 }; |
140 | 140 |
141 ////////////////////////////////////////////////////////////////////////////// | 141 ////////////////////////////////////////////////////////////////////////////// |
142 | 142 |
143 DEF_GM(return new NonClosedPathsGM;) | 143 DEF_GM(return new NonClosedPathsGM;) |
144 | 144 |
145 } | 145 } |
OLD | NEW |