OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]" | 48 ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]" |
49 " filltype[%d] ptcount[%d]", str, paint.getStyle(), | 49 " filltype[%d] ptcount[%d]", str, paint.getStyle(), |
50 paint.getStrokeCap(), paint.getStrokeJoin(), | 50 paint.getStrokeCap(), paint.getStrokeJoin(), |
51 paint.isAntiAlias(), path.getFillType(), path.countPoints()); | 51 paint.isAntiAlias(), path.getFillType(), path.countPoints()); |
52 // uncomment this if you want to step in to see the failure | 52 // uncomment this if you want to step in to see the failure |
53 // canvas.drawPath(path, p); | 53 // canvas.drawPath(path, p); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 enum DrawCaps { | 57 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh
ouldDraw) { |
58 kDontDrawCaps, | |
59 kDrawCaps | |
60 }; | |
61 | |
62 static void iter_paint(skiatest::Reporter* reporter, const SkPath& path, bool sh
ouldDraw, | |
63 DrawCaps drawCaps) { | |
64 static const SkPaint::Cap gCaps[] = { | 58 static const SkPaint::Cap gCaps[] = { |
65 SkPaint::kButt_Cap, | 59 SkPaint::kButt_Cap, |
66 SkPaint::kRound_Cap, | 60 SkPaint::kRound_Cap, |
67 SkPaint::kSquare_Cap | 61 SkPaint::kSquare_Cap |
68 }; | 62 }; |
69 static const SkPaint::Join gJoins[] = { | 63 static const SkPaint::Join gJoins[] = { |
70 SkPaint::kMiter_Join, | 64 SkPaint::kMiter_Join, |
71 SkPaint::kRound_Join, | 65 SkPaint::kRound_Join, |
72 SkPaint::kBevel_Join | 66 SkPaint::kBevel_Join |
73 }; | 67 }; |
74 static const SkPaint::Style gStyles[] = { | 68 static const SkPaint::Style gStyles[] = { |
75 SkPaint::kFill_Style, | 69 SkPaint::kFill_Style, |
76 SkPaint::kStroke_Style, | 70 SkPaint::kStroke_Style, |
77 SkPaint::kStrokeAndFill_Style | 71 SkPaint::kStrokeAndFill_Style |
78 }; | 72 }; |
79 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { | 73 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { |
80 for (size_t join = 0; join < SK_ARRAY_COUNT(gJoins); ++join) { | 74 for (size_t join = 0; join < SK_ARRAY_COUNT(gJoins); ++join) { |
81 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) { | 75 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) { |
82 if (drawCaps && SkPaint::kButt_Cap != gCaps[cap] | |
83 && SkPaint::kFill_Style != gStyles[style]) { | |
84 continue; | |
85 } | |
86 | |
87 SkPaint paint; | 76 SkPaint paint; |
88 paint.setStrokeWidth(SkIntToScalar(10)); | 77 paint.setStrokeWidth(SkIntToScalar(10)); |
89 | 78 |
90 paint.setStrokeCap(gCaps[cap]); | 79 paint.setStrokeCap(gCaps[cap]); |
91 paint.setStrokeJoin(gJoins[join]); | 80 paint.setStrokeJoin(gJoins[join]); |
92 paint.setStyle(gStyles[style]); | 81 paint.setStyle(gStyles[style]); |
93 | 82 |
94 paint.setAntiAlias(false); | 83 paint.setAntiAlias(false); |
95 drawAndTest(reporter, path, paint, shouldDraw); | 84 drawAndTest(reporter, path, paint, shouldDraw); |
96 paint.setAntiAlias(true); | 85 paint.setAntiAlias(true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 SkPath::kInverseWinding_FillType, | 120 SkPath::kInverseWinding_FillType, |
132 SkPath::kInverseEvenOdd_FillType | 121 SkPath::kInverseEvenOdd_FillType |
133 }; | 122 }; |
134 for (int doClose = 0; doClose < 2; ++doClose) { | 123 for (int doClose = 0; doClose < 2; ++doClose) { |
135 for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) { | 124 for (size_t i = 0; i < SK_ARRAY_COUNT(gMakeProc); ++i) { |
136 SkPath path; | 125 SkPath path; |
137 gMakeProc[i](&path); | 126 gMakeProc[i](&path); |
138 if (doClose) { | 127 if (doClose) { |
139 path.close(); | 128 path.close(); |
140 } | 129 } |
141 /* zero length segments and close following moves draw round and squ
are caps */ | |
142 bool allowCaps = make_L == gMakeProc[i] || make_Q == gMakeProc[i] | |
143 || make_C == gMakeProc[i] || make_MZM == gMakeProc[i]; | |
144 allowCaps |= SkToBool(doClose); | |
145 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { | 130 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { |
146 path.setFillType(gFills[fill]); | 131 path.setFillType(gFills[fill]); |
147 bool shouldDraw = path.isInverseFillType(); | 132 bool shouldDraw = path.isInverseFillType(); |
148 iter_paint(reporter, path, shouldDraw, allowCaps ? kDrawCaps : k
DontDrawCaps); | 133 iter_paint(reporter, path, shouldDraw); |
149 } | 134 } |
150 } | 135 } |
151 } | 136 } |
152 } | 137 } |
153 | 138 |
154 DEF_TEST(EmptyPath, reporter) { | 139 DEF_TEST(EmptyPath, reporter) { |
155 test_emptydrawing(reporter); | 140 test_emptydrawing(reporter); |
156 } | 141 } |
OLD | NEW |