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 15 matching lines...) Expand all Loading... |
26 // The path looks closed, but final rendering has 2 e
nds with cap. | 26 // The path looks closed, but final rendering has 2 e
nds with cap. |
27 | 27 |
28 FakeCloseMiddle, // The last point coincides with the first one in the
middle of a line. | 28 FakeCloseMiddle, // The last point coincides with the first one in the
middle of a line. |
29 // The path looks closed, and the final rendering loo
ks closed too. | 29 // The path looks closed, and the final rendering loo
ks closed too. |
30 | 30 |
31 kClosureTypeCount | 31 kClosureTypeCount |
32 }; | 32 }; |
33 | 33 |
34 protected: | 34 protected: |
35 | 35 |
36 SkString onShortName() SK_OVERRIDE { | 36 SkString onShortName() override { |
37 return SkString("nonclosedpaths"); | 37 return SkString("nonclosedpaths"); |
38 } | 38 } |
39 | 39 |
40 // 12 * 18 + 3 cases, every case is 100 * 100 pixels. | 40 // 12 * 18 + 3 cases, every case is 100 * 100 pixels. |
41 SkISize onISize() SK_OVERRIDE { | 41 SkISize onISize() override { |
42 return SkISize::Make(1220, 1920); | 42 return SkISize::Make(1220, 1920); |
43 } | 43 } |
44 | 44 |
45 // Use rect-like geometry for non-closed path, for right angles make it | 45 // Use rect-like geometry for non-closed path, for right angles make it |
46 // easier to show the visual difference of lineCap and lineJoin. | 46 // easier to show the visual difference of lineCap and lineJoin. |
47 static void MakePath(SkPath* path, ClosureType type) { | 47 static void MakePath(SkPath* path, ClosureType type) { |
48 if (FakeCloseMiddle == type) { | 48 if (FakeCloseMiddle == type) { |
49 path->moveTo(30, 50); | 49 path->moveTo(30, 50); |
50 path->lineTo(30, 30); | 50 path->lineTo(30, 30); |
51 } else { | 51 } else { |
52 path->moveTo(30, 30); | 52 path->moveTo(30, 30); |
53 } | 53 } |
54 path->lineTo(70, 30); | 54 path->lineTo(70, 30); |
55 path->lineTo(70, 70); | 55 path->lineTo(70, 70); |
56 path->lineTo(30, 70); | 56 path->lineTo(30, 70); |
57 path->lineTo(30, 50); | 57 path->lineTo(30, 50); |
58 if (FakeCloseCorner == type) { | 58 if (FakeCloseCorner == type) { |
59 path->lineTo(30, 30); | 59 path->lineTo(30, 30); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 // Set the location for the current test on the canvas | 63 // Set the location for the current test on the canvas |
64 static void SetLocation(SkCanvas* canvas, int counter, int lineNum) { | 64 static void SetLocation(SkCanvas* canvas, int counter, int lineNum) { |
65 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; | 65 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; |
66 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; | 66 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; |
67 canvas->translate(x, y); | 67 canvas->translate(x, y); |
68 } | 68 } |
69 | 69 |
70 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 70 void onDraw(SkCanvas* canvas) override { |
71 // Stroke widths are: | 71 // Stroke widths are: |
72 // 0(may use hairline rendering), 10(common case for stroke-style) | 72 // 0(may use hairline rendering), 10(common case for stroke-style) |
73 // 40 and 50(>= geometry width/height, make the contour filled in fact) | 73 // 40 and 50(>= geometry width/height, make the contour filled in fact) |
74 static const int kStrokeWidth[] = {0, 10, 40, 50}; | 74 static const int kStrokeWidth[] = {0, 10, 40, 50}; |
75 int numWidths = SK_ARRAY_COUNT(kStrokeWidth); | 75 int numWidths = SK_ARRAY_COUNT(kStrokeWidth); |
76 | 76 |
77 static const SkPaint::Style kStyle[] = { | 77 static const SkPaint::Style kStyle[] = { |
78 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style | 78 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style |
79 }; | 79 }; |
80 | 80 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 private: | 138 private: |
139 typedef GM INHERITED; | 139 typedef GM INHERITED; |
140 }; | 140 }; |
141 | 141 |
142 ////////////////////////////////////////////////////////////////////////////// | 142 ////////////////////////////////////////////////////////////////////////////// |
143 | 143 |
144 DEF_GM(return new NonClosedPathsGM;) | 144 DEF_GM(return new NonClosedPathsGM;) |
145 | 145 |
146 } | 146 } |
OLD | NEW |