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 #include "gm.h" | 7 #include "gm.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 }; | 76 }; |
77 PathAndName path; | 77 PathAndName path; |
78 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); | 78 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); |
79 path.fPath.quadTo(50*SK_Scalar1, 20*SK_Scalar1, | 79 path.fPath.quadTo(50*SK_Scalar1, 20*SK_Scalar1, |
80 75*SK_Scalar1, 10*SK_Scalar1); | 80 75*SK_Scalar1, 10*SK_Scalar1); |
81 path.fName = "moveTo-quad"; | 81 path.fName = "moveTo-quad"; |
82 | 82 |
83 SkPaint titlePaint; | 83 SkPaint titlePaint; |
84 titlePaint.setColor(SK_ColorBLACK); | 84 titlePaint.setColor(SK_ColorBLACK); |
85 titlePaint.setAntiAlias(true); | 85 titlePaint.setAntiAlias(true); |
86 sk_tool_utils::set_portable_typeface(&titlePaint); | 86 sk_tool_utils::set_portable_typeface_always(&titlePaint); |
87 titlePaint.setLCDRenderText(true); | |
88 titlePaint.setTextSize(15 * SK_Scalar1); | 87 titlePaint.setTextSize(15 * SK_Scalar1); |
89 const char title[] = "Quad Drawn Into Rectangle Clips With " | 88 const char title[] = "Quad Drawn Into Rectangle Clips With " |
90 "Indicated Style, Fill and Linecaps, with stroke wi
dth 10"; | 89 "Indicated Style, Fill and Linecaps, with stroke wi
dth 10"; |
91 canvas->drawText(title, strlen(title), | 90 canvas->drawText(title, strlen(title), |
92 20 * SK_Scalar1, | 91 20 * SK_Scalar1, |
93 20 * SK_Scalar1, | 92 20 * SK_Scalar1, |
94 titlePaint); | 93 titlePaint); |
95 | 94 |
96 SkRandom rand; | 95 SkRandom rand; |
97 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); | 96 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); |
98 canvas->save(); | 97 canvas->save(); |
99 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); | 98 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); |
100 canvas->save(); | 99 canvas->save(); |
101 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { | 100 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { |
102 if (0 < cap) { | 101 if (0 < cap) { |
103 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO
UNT(gStyles), 0); | 102 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO
UNT(gStyles), 0); |
104 } | 103 } |
105 canvas->save(); | 104 canvas->save(); |
106 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { | 105 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { |
107 if (0 < fill) { | 106 if (0 < fill) { |
108 canvas->translate(0, rect.height() + 40 * SK_Scalar1); | 107 canvas->translate(0, rect.height() + 40 * SK_Scalar1); |
109 } | 108 } |
110 canvas->save(); | 109 canvas->save(); |
111 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style)
{ | 110 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style)
{ |
112 if (0 < style) { | 111 if (0 < style) { |
113 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); | 112 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); |
114 } | 113 } |
115 | 114 |
116 SkColor color = 0xff007000; | 115 SkColor color = sk_tool_utils::color_to_565(0xff007000); |
117 this->drawPath(path.fPath, canvas, color, rect, | 116 this->drawPath(path.fPath, canvas, color, rect, |
118 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s
tyle].fStyle, | 117 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s
tyle].fStyle, |
119 gFills[fill].fFill, SK_Scalar1*10); | 118 gFills[fill].fFill, SK_Scalar1*10); |
120 | 119 |
121 SkPaint rectPaint; | 120 SkPaint rectPaint; |
122 rectPaint.setColor(SK_ColorBLACK); | 121 rectPaint.setColor(SK_ColorBLACK); |
123 rectPaint.setStyle(SkPaint::kStroke_Style); | 122 rectPaint.setStyle(SkPaint::kStroke_Style); |
124 rectPaint.setStrokeWidth(-1); | 123 rectPaint.setStrokeWidth(-1); |
125 rectPaint.setAntiAlias(true); | 124 rectPaint.setAntiAlias(true); |
126 canvas->drawRect(rect, rectPaint); | 125 canvas->drawRect(rect, rectPaint); |
127 | 126 |
128 SkPaint labelPaint; | 127 SkPaint labelPaint; |
129 labelPaint.setColor(color); | 128 labelPaint.setColor(color); |
130 labelPaint.setAntiAlias(true); | 129 labelPaint.setAntiAlias(true); |
131 sk_tool_utils::set_portable_typeface(&labelPaint); | 130 sk_tool_utils::set_portable_typeface_always(&labelPaint); |
132 labelPaint.setLCDRenderText(true); | |
133 labelPaint.setTextSize(10 * SK_Scalar1); | 131 labelPaint.setTextSize(10 * SK_Scalar1); |
134 canvas->drawText(gStyles[style].fName, | 132 canvas->drawText(gStyles[style].fName, |
135 strlen(gStyles[style].fName), | 133 strlen(gStyles[style].fName), |
136 0, rect.height() + 12 * SK_Scalar1, | 134 0, rect.height() + 12 * SK_Scalar1, |
137 labelPaint); | 135 labelPaint); |
138 canvas->drawText(gFills[fill].fName, | 136 canvas->drawText(gFills[fill].fName, |
139 strlen(gFills[fill].fName), | 137 strlen(gFills[fill].fName), |
140 0, rect.height() + 24 * SK_Scalar1, | 138 0, rect.height() + 24 * SK_Scalar1, |
141 labelPaint); | 139 labelPaint); |
142 canvas->drawText(gCaps[cap].fName, | 140 canvas->drawText(gCaps[cap].fName, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 PathAndName path; | 220 PathAndName path; |
223 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); | 221 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); |
224 path.fPath.quadTo(50*SK_Scalar1, 20*SK_Scalar1, | 222 path.fPath.quadTo(50*SK_Scalar1, 20*SK_Scalar1, |
225 75*SK_Scalar1, 10*SK_Scalar1); | 223 75*SK_Scalar1, 10*SK_Scalar1); |
226 path.fPath.close(); | 224 path.fPath.close(); |
227 path.fName = "moveTo-quad-close"; | 225 path.fName = "moveTo-quad-close"; |
228 | 226 |
229 SkPaint titlePaint; | 227 SkPaint titlePaint; |
230 titlePaint.setColor(SK_ColorBLACK); | 228 titlePaint.setColor(SK_ColorBLACK); |
231 titlePaint.setAntiAlias(true); | 229 titlePaint.setAntiAlias(true); |
232 sk_tool_utils::set_portable_typeface(&titlePaint); | 230 sk_tool_utils::set_portable_typeface_always(&titlePaint); |
233 titlePaint.setLCDRenderText(true); | |
234 titlePaint.setTextSize(15 * SK_Scalar1); | 231 titlePaint.setTextSize(15 * SK_Scalar1); |
235 const char title[] = "Quad Closed Drawn Into Rectangle Clips With " | 232 const char title[] = "Quad Closed Drawn Into Rectangle Clips With " |
236 "Indicated Style, Fill and Linecaps, with stroke wi
dth 10"; | 233 "Indicated Style, Fill and Linecaps, with stroke wi
dth 10"; |
237 canvas->drawText(title, strlen(title), | 234 canvas->drawText(title, strlen(title), |
238 20 * SK_Scalar1, | 235 20 * SK_Scalar1, |
239 20 * SK_Scalar1, | 236 20 * SK_Scalar1, |
240 titlePaint); | 237 titlePaint); |
241 | 238 |
242 SkRandom rand; | 239 SkRandom rand; |
243 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); | 240 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); |
244 canvas->save(); | 241 canvas->save(); |
245 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); | 242 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); |
246 canvas->save(); | 243 canvas->save(); |
247 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { | 244 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { |
248 if (0 < cap) { | 245 if (0 < cap) { |
249 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO
UNT(gStyles), 0); | 246 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO
UNT(gStyles), 0); |
250 } | 247 } |
251 canvas->save(); | 248 canvas->save(); |
252 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { | 249 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { |
253 if (0 < fill) { | 250 if (0 < fill) { |
254 canvas->translate(0, rect.height() + 40 * SK_Scalar1); | 251 canvas->translate(0, rect.height() + 40 * SK_Scalar1); |
255 } | 252 } |
256 canvas->save(); | 253 canvas->save(); |
257 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style)
{ | 254 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style)
{ |
258 if (0 < style) { | 255 if (0 < style) { |
259 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); | 256 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); |
260 } | 257 } |
261 | 258 |
262 SkColor color = 0xff007000; | 259 SkColor color = sk_tool_utils::color_to_565(0xff007000); |
263 this->drawPath(path.fPath, canvas, color, rect, | 260 this->drawPath(path.fPath, canvas, color, rect, |
264 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s
tyle].fStyle, | 261 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s
tyle].fStyle, |
265 gFills[fill].fFill, SK_Scalar1*10); | 262 gFills[fill].fFill, SK_Scalar1*10); |
266 | 263 |
267 SkPaint rectPaint; | 264 SkPaint rectPaint; |
268 rectPaint.setColor(SK_ColorBLACK); | 265 rectPaint.setColor(SK_ColorBLACK); |
269 rectPaint.setStyle(SkPaint::kStroke_Style); | 266 rectPaint.setStyle(SkPaint::kStroke_Style); |
270 rectPaint.setStrokeWidth(-1); | 267 rectPaint.setStrokeWidth(-1); |
271 rectPaint.setAntiAlias(true); | 268 rectPaint.setAntiAlias(true); |
272 canvas->drawRect(rect, rectPaint); | 269 canvas->drawRect(rect, rectPaint); |
273 | 270 |
274 SkPaint labelPaint; | 271 SkPaint labelPaint; |
275 labelPaint.setColor(color); | 272 labelPaint.setColor(color); |
276 labelPaint.setAntiAlias(true); | 273 labelPaint.setAntiAlias(true); |
277 sk_tool_utils::set_portable_typeface(&labelPaint); | 274 sk_tool_utils::set_portable_typeface_always(&labelPaint); |
278 labelPaint.setLCDRenderText(true); | |
279 labelPaint.setTextSize(10 * SK_Scalar1); | 275 labelPaint.setTextSize(10 * SK_Scalar1); |
280 canvas->drawText(gStyles[style].fName, | 276 canvas->drawText(gStyles[style].fName, |
281 strlen(gStyles[style].fName), | 277 strlen(gStyles[style].fName), |
282 0, rect.height() + 12 * SK_Scalar1, | 278 0, rect.height() + 12 * SK_Scalar1, |
283 labelPaint); | 279 labelPaint); |
284 canvas->drawText(gFills[fill].fName, | 280 canvas->drawText(gFills[fill].fName, |
285 strlen(gFills[fill].fName), | 281 strlen(gFills[fill].fName), |
286 0, rect.height() + 24 * SK_Scalar1, | 282 0, rect.height() + 24 * SK_Scalar1, |
287 labelPaint); | 283 labelPaint); |
288 canvas->drawText(gCaps[cap].fName, | 284 canvas->drawText(gCaps[cap].fName, |
(...skipping 15 matching lines...) Expand all Loading... |
304 | 300 |
305 ////////////////////////////////////////////////////////////////////////////// | 301 ////////////////////////////////////////////////////////////////////////////// |
306 | 302 |
307 static GM* QuadPathFactory(void*) { return new QuadPathGM; } | 303 static GM* QuadPathFactory(void*) { return new QuadPathGM; } |
308 static GMRegistry regQuadPath(QuadPathFactory); | 304 static GMRegistry regQuadPath(QuadPathFactory); |
309 | 305 |
310 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } | 306 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } |
311 static GMRegistry regQuadClosePath(QuadClosePathFactory); | 307 static GMRegistry regQuadClosePath(QuadClosePathFactory); |
312 | 308 |
313 } | 309 } |
OLD | NEW |