Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: gm/linepaths.cpp

Issue 1225303010: make linepaths gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const char* fName; 75 const char* fName;
76 }; 76 };
77 PathAndName path; 77 PathAndName path;
78 path.fPath.moveTo(25*SK_Scalar1, 15*SK_Scalar1); 78 path.fPath.moveTo(25*SK_Scalar1, 15*SK_Scalar1);
79 path.fPath.lineTo(75*SK_Scalar1, 15*SK_Scalar1); 79 path.fPath.lineTo(75*SK_Scalar1, 15*SK_Scalar1);
80 path.fName = "moveTo-line"; 80 path.fName = "moveTo-line";
81 81
82 SkPaint titlePaint; 82 SkPaint titlePaint;
83 titlePaint.setColor(SK_ColorBLACK); 83 titlePaint.setColor(SK_ColorBLACK);
84 titlePaint.setAntiAlias(true); 84 titlePaint.setAntiAlias(true);
85 sk_tool_utils::set_portable_typeface(&titlePaint); 85 sk_tool_utils::set_portable_typeface_always(&titlePaint);
86 titlePaint.setLCDRenderText(true);
87 titlePaint.setTextSize(15 * SK_Scalar1); 86 titlePaint.setTextSize(15 * SK_Scalar1);
88 const char title[] = "Line Drawn Into Rectangle Clips With " 87 const char title[] = "Line Drawn Into Rectangle Clips With "
89 "Indicated Style, Fill and Linecaps, with stroke wi dth 10"; 88 "Indicated Style, Fill and Linecaps, with stroke wi dth 10";
90 canvas->drawText(title, strlen(title), 89 canvas->drawText(title, strlen(title),
91 20 * SK_Scalar1, 90 20 * SK_Scalar1,
92 20 * SK_Scalar1, 91 20 * SK_Scalar1,
93 titlePaint); 92 titlePaint);
94 93
95 SkRandom rand; 94 SkRandom rand;
96 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); 95 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1);
97 canvas->save(); 96 canvas->save();
98 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); 97 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1);
99 canvas->save(); 98 canvas->save();
100 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { 99 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) {
101 if (0 < cap) { 100 if (0 < cap) {
102 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO UNT(gStyles), 0); 101 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO UNT(gStyles), 0);
103 } 102 }
104 canvas->save(); 103 canvas->save();
105 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { 104 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) {
106 if (0 < fill) { 105 if (0 < fill) {
107 canvas->translate(0, rect.height() + 40 * SK_Scalar1); 106 canvas->translate(0, rect.height() + 40 * SK_Scalar1);
108 } 107 }
109 canvas->save(); 108 canvas->save();
110 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) { 109 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) {
111 if (0 < style) { 110 if (0 < style) {
112 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); 111 canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
113 } 112 }
114 113
115 SkColor color = 0xff007000; 114 SkColor color = sk_tool_utils::color_to_565(0xff007000);
116 this->drawPath(path.fPath, canvas, color, rect, 115 this->drawPath(path.fPath, canvas, color, rect,
117 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s tyle].fStyle, 116 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s tyle].fStyle,
118 gFills[fill].fFill, SK_Scalar1*10); 117 gFills[fill].fFill, SK_Scalar1*10);
119 118
120 SkPaint rectPaint; 119 SkPaint rectPaint;
121 rectPaint.setColor(SK_ColorBLACK); 120 rectPaint.setColor(SK_ColorBLACK);
122 rectPaint.setStyle(SkPaint::kStroke_Style); 121 rectPaint.setStyle(SkPaint::kStroke_Style);
123 rectPaint.setStrokeWidth(-1); 122 rectPaint.setStrokeWidth(-1);
124 rectPaint.setAntiAlias(true); 123 rectPaint.setAntiAlias(true);
125 canvas->drawRect(rect, rectPaint); 124 canvas->drawRect(rect, rectPaint);
126 125
127 SkPaint labelPaint; 126 SkPaint labelPaint;
128 labelPaint.setColor(color); 127 labelPaint.setColor(color);
129 labelPaint.setAntiAlias(true); 128 labelPaint.setAntiAlias(true);
130 sk_tool_utils::set_portable_typeface(&labelPaint); 129 sk_tool_utils::set_portable_typeface_always(&labelPaint);
131 labelPaint.setLCDRenderText(true);
132 labelPaint.setTextSize(10 * SK_Scalar1); 130 labelPaint.setTextSize(10 * SK_Scalar1);
133 canvas->drawText(gStyles[style].fName, 131 canvas->drawText(gStyles[style].fName,
134 strlen(gStyles[style].fName), 132 strlen(gStyles[style].fName),
135 0, rect.height() + 12 * SK_Scalar1, 133 0, rect.height() + 12 * SK_Scalar1,
136 labelPaint); 134 labelPaint);
137 canvas->drawText(gFills[fill].fName, 135 canvas->drawText(gFills[fill].fName,
138 strlen(gFills[fill].fName), 136 strlen(gFills[fill].fName),
139 0, rect.height() + 24 * SK_Scalar1, 137 0, rect.height() + 24 * SK_Scalar1,
140 labelPaint); 138 labelPaint);
141 canvas->drawText(gCaps[cap].fName, 139 canvas->drawText(gCaps[cap].fName,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 }; 217 };
220 PathAndName path; 218 PathAndName path;
221 path.fPath.moveTo(25*SK_Scalar1, 15*SK_Scalar1); 219 path.fPath.moveTo(25*SK_Scalar1, 15*SK_Scalar1);
222 path.fPath.lineTo(75*SK_Scalar1, 15*SK_Scalar1); 220 path.fPath.lineTo(75*SK_Scalar1, 15*SK_Scalar1);
223 path.fPath.close(); 221 path.fPath.close();
224 path.fName = "moveTo-line-close"; 222 path.fName = "moveTo-line-close";
225 223
226 SkPaint titlePaint; 224 SkPaint titlePaint;
227 titlePaint.setColor(SK_ColorBLACK); 225 titlePaint.setColor(SK_ColorBLACK);
228 titlePaint.setAntiAlias(true); 226 titlePaint.setAntiAlias(true);
229 sk_tool_utils::set_portable_typeface(&titlePaint); 227 sk_tool_utils::set_portable_typeface_always(&titlePaint);
230 titlePaint.setLCDRenderText(true);
231 titlePaint.setTextSize(15 * SK_Scalar1); 228 titlePaint.setTextSize(15 * SK_Scalar1);
232 const char title[] = "Line Closed Drawn Into Rectangle Clips With " 229 const char title[] = "Line Closed Drawn Into Rectangle Clips With "
233 "Indicated Style, Fill and Linecaps, with stroke wi dth 10"; 230 "Indicated Style, Fill and Linecaps, with stroke wi dth 10";
234 canvas->drawText(title, strlen(title), 231 canvas->drawText(title, strlen(title),
235 20 * SK_Scalar1, 232 20 * SK_Scalar1,
236 20 * SK_Scalar1, 233 20 * SK_Scalar1,
237 titlePaint); 234 titlePaint);
238 235
239 SkRandom rand; 236 SkRandom rand;
240 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); 237 SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1);
241 canvas->save(); 238 canvas->save();
242 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1); 239 canvas->translate(10 * SK_Scalar1, 30 * SK_Scalar1);
243 canvas->save(); 240 canvas->save();
244 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) { 241 for (size_t cap = 0; cap < SK_ARRAY_COUNT(gCaps); ++cap) {
245 if (0 < cap) { 242 if (0 < cap) {
246 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO UNT(gStyles), 0); 243 canvas->translate((rect.width() + 40 * SK_Scalar1) * SK_ARRAY_CO UNT(gStyles), 0);
247 } 244 }
248 canvas->save(); 245 canvas->save();
249 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) { 246 for (size_t fill = 0; fill < SK_ARRAY_COUNT(gFills); ++fill) {
250 if (0 < fill) { 247 if (0 < fill) {
251 canvas->translate(0, rect.height() + 40 * SK_Scalar1); 248 canvas->translate(0, rect.height() + 40 * SK_Scalar1);
252 } 249 }
253 canvas->save(); 250 canvas->save();
254 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) { 251 for (size_t style = 0; style < SK_ARRAY_COUNT(gStyles); ++style) {
255 if (0 < style) { 252 if (0 < style) {
256 canvas->translate(rect.width() + 40 * SK_Scalar1, 0); 253 canvas->translate(rect.width() + 40 * SK_Scalar1, 0);
257 } 254 }
258 255
259 SkColor color = 0xff007000; 256 SkColor color = sk_tool_utils::color_to_565(0xff007000);
260 this->drawPath(path.fPath, canvas, color, rect, 257 this->drawPath(path.fPath, canvas, color, rect,
261 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s tyle].fStyle, 258 gCaps[cap].fCap, gCaps[cap].fJoin, gStyles[s tyle].fStyle,
262 gFills[fill].fFill, SK_Scalar1*10); 259 gFills[fill].fFill, SK_Scalar1*10);
263 260
264 SkPaint rectPaint; 261 SkPaint rectPaint;
265 rectPaint.setColor(SK_ColorBLACK); 262 rectPaint.setColor(SK_ColorBLACK);
266 rectPaint.setStyle(SkPaint::kStroke_Style); 263 rectPaint.setStyle(SkPaint::kStroke_Style);
267 rectPaint.setStrokeWidth(-1); 264 rectPaint.setStrokeWidth(-1);
268 rectPaint.setAntiAlias(true); 265 rectPaint.setAntiAlias(true);
269 canvas->drawRect(rect, rectPaint); 266 canvas->drawRect(rect, rectPaint);
270 267
271 SkPaint labelPaint; 268 SkPaint labelPaint;
272 labelPaint.setColor(color); 269 labelPaint.setColor(color);
273 labelPaint.setAntiAlias(true); 270 labelPaint.setAntiAlias(true);
274 sk_tool_utils::set_portable_typeface(&labelPaint); 271 sk_tool_utils::set_portable_typeface_always(&labelPaint);
275 labelPaint.setLCDRenderText(true);
276 labelPaint.setTextSize(10 * SK_Scalar1); 272 labelPaint.setTextSize(10 * SK_Scalar1);
277 canvas->drawText(gStyles[style].fName, 273 canvas->drawText(gStyles[style].fName,
278 strlen(gStyles[style].fName), 274 strlen(gStyles[style].fName),
279 0, rect.height() + 12 * SK_Scalar1, 275 0, rect.height() + 12 * SK_Scalar1,
280 labelPaint); 276 labelPaint);
281 canvas->drawText(gFills[fill].fName, 277 canvas->drawText(gFills[fill].fName,
282 strlen(gFills[fill].fName), 278 strlen(gFills[fill].fName),
283 0, rect.height() + 24 * SK_Scalar1, 279 0, rect.height() + 24 * SK_Scalar1,
284 labelPaint); 280 labelPaint);
285 canvas->drawText(gCaps[cap].fName, 281 canvas->drawText(gCaps[cap].fName,
(...skipping 15 matching lines...) Expand all
301 297
302 ////////////////////////////////////////////////////////////////////////////// 298 //////////////////////////////////////////////////////////////////////////////
303 299
304 static GM* LinePathFactory(void*) { return new LinePathGM; } 300 static GM* LinePathFactory(void*) { return new LinePathGM; }
305 static GMRegistry regLinePath(LinePathFactory); 301 static GMRegistry regLinePath(LinePathFactory);
306 302
307 static GM* LineClosePathFactory(void*) { return new LineClosePathGM; } 303 static GM* LineClosePathFactory(void*) { return new LineClosePathGM; }
308 static GMRegistry regLineClosePath(LineClosePathFactory); 304 static GMRegistry regLineClosePath(LineClosePathFactory);
309 305
310 } 306 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698