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 "gm.h" | 8 #include "gm.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 | 284 |
285 SkString onShortName() override { | 285 SkString onShortName() override { |
286 return SkString("strokes_poly"); | 286 return SkString("strokes_poly"); |
287 } | 287 } |
288 | 288 |
289 SkISize onISize() override { | 289 SkISize onISize() override { |
290 return SkISize::Make(W, H*2); | 290 return SkISize::Make(W, H*2); |
291 } | 291 } |
292 | 292 |
293 static void rotate(SkScalar angle, SkScalar px, SkScalar py, SkCanvas* canva
s) { | |
294 SkMatrix matrix; | |
295 matrix.setRotate(angle, px, py); | |
296 canvas->concat(matrix); | |
297 } | |
298 | |
299 void onDraw(SkCanvas* canvas) override { | 293 void onDraw(SkCanvas* canvas) override { |
300 canvas->drawColor(SK_ColorWHITE); | 294 canvas->drawColor(SK_ColorWHITE); |
301 | 295 |
302 SkPaint paint; | 296 SkPaint paint; |
303 paint.setStyle(SkPaint::kStroke_Style); | 297 paint.setStyle(SkPaint::kStroke_Style); |
304 paint.setStrokeWidth(SkIntToScalar(9)/2); | 298 paint.setStrokeWidth(SkIntToScalar(9)/2); |
305 | 299 |
306 for (int y = 0; y < 2; y++) { | 300 for (int y = 0; y < 2; y++) { |
307 paint.setAntiAlias(!!y); | 301 paint.setAntiAlias(!!y); |
308 SkAutoCanvasRestore acr(canvas, true); | 302 SkAutoCanvasRestore acr(canvas, true); |
309 canvas->translate(0, SH * y); | 303 canvas->translate(0, SH * y); |
310 canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2), | 304 canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2), |
311 SkIntToScalar(2), | 305 SkIntToScalar(2), |
312 SW - SkIntToScalar(2), | 306 SW - SkIntToScalar(2), |
313 SH - SkIntToScalar(2))); | 307 SH - SkIntToScalar(2))); |
314 | 308 |
315 SkRandom rand; | 309 SkRandom rand; |
316 for (int i = 0; i < N/2; i++) { | 310 for (int i = 0; i < N/2; i++) { |
317 SkRect r; | 311 SkRect r; |
318 rnd_rect(&r, &paint, rand); | 312 rnd_rect(&r, &paint, rand); |
319 rotate(SkIntToScalar(15), SW/2, SH/2, canvas); | 313 canvas->rotate(SkIntToScalar(15), SW/2, SH/2); |
320 canvas->drawPath(fPath, paint); | 314 canvas->drawPath(fPath, paint); |
321 } | 315 } |
322 } | 316 } |
323 } | 317 } |
324 | 318 |
325 private: | 319 private: |
326 typedef skiagm::GM INHERITED; | 320 typedef skiagm::GM INHERITED; |
327 }; | 321 }; |
328 | 322 |
329 ////////////////////////////////////////////////////////////////////////////// | 323 ////////////////////////////////////////////////////////////////////////////// |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 ////////////////////////////////////////////////////////////////////////////// | 510 ////////////////////////////////////////////////////////////////////////////// |
517 | 511 |
518 DEF_GM( return new StrokesGM; ) | 512 DEF_GM( return new StrokesGM; ) |
519 DEF_GM( return new Strokes2GM; ) | 513 DEF_GM( return new Strokes2GM; ) |
520 DEF_GM( return new Strokes3GM; ) | 514 DEF_GM( return new Strokes3GM; ) |
521 DEF_GM( return new Strokes4GM; ) | 515 DEF_GM( return new Strokes4GM; ) |
522 DEF_GM( return new Strokes5GM; ) | 516 DEF_GM( return new Strokes5GM; ) |
523 | 517 |
524 DEF_GM( return new ZeroLenStrokesGM; ) | 518 DEF_GM( return new ZeroLenStrokesGM; ) |
525 DEF_GM( return new TeenyStrokesGM; ) | 519 DEF_GM( return new TeenyStrokesGM; ) |
OLD | NEW |