| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 SkIntToScalar(phase), | 469 SkIntToScalar(phase), |
| 470 sign * SkIntToScalar(10003), SkIntToScalar(y)); | 470 sign * SkIntToScalar(10003), SkIntToScalar(y)); |
| 471 phase = (phase + 1) % kIntervalLength; | 471 phase = (phase + 1) % kIntervalLength; |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 private: | 475 private: |
| 476 bool fDoAA; | 476 bool fDoAA; |
| 477 }; | 477 }; |
| 478 | 478 |
| 479 DEF_SIMPLE_GM(longpathdash, canvas, 512, 512) { | 479 DEF_SIMPLE_GM(longpathdash, canvas, 612, 612) { |
| 480 SkPath lines; | 480 SkPath lines; |
| 481 for (int x = 32; x < 256; x += 16) { | 481 for (int x = 32; x < 256; x += 16) { |
| 482 for (SkScalar a = 0; a < 3.141592f * 2; a += 0.03141592f) { | 482 for (SkScalar a = 0; a < 3.141592f * 2; a += 0.03141592f) { |
| 483 SkPoint pts[2] = { | 483 SkPoint pts[2] = { |
| 484 { 256 + (float) sin(a) * x, | 484 { 256 + (float) sin(a) * x, |
| 485 256 + (float) cos(a) * x }, | 485 256 + (float) cos(a) * x }, |
| 486 { 256 + (float) sin(a + 3.141592 / 3) * (x + 64), | 486 { 256 + (float) sin(a + 3.141592 / 3) * (x + 64), |
| 487 256 + (float) cos(a + 3.141592 / 3) * (x + 64) } | 487 256 + (float) cos(a + 3.141592 / 3) * (x + 64) } |
| 488 }; | 488 }; |
| 489 lines.moveTo(pts[0]); | 489 lines.moveTo(pts[0]); |
| 490 for (SkScalar i = 0; i < 1; i += 0.05f) { | 490 for (SkScalar i = 0; i < 1; i += 0.05f) { |
| 491 lines.lineTo(pts[0].fX * (1 - i) + pts[1].fX * i, | 491 lines.lineTo(pts[0].fX * (1 - i) + pts[1].fX * i, |
| 492 pts[0].fY * (1 - i) + pts[1].fY * i); | 492 pts[0].fY * (1 - i) + pts[1].fY * i); |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 SkPaint p; | 496 SkPaint p; |
| 497 p.setAntiAlias(true); | 497 p.setAntiAlias(true); |
| 498 p.setStyle(SkPaint::kStroke_Style); | 498 p.setStyle(SkPaint::kStroke_Style); |
| 499 p.setStrokeWidth(1); | 499 p.setStrokeWidth(1); |
| 500 const SkScalar intervals[] = { 1, 1 }; | 500 const SkScalar intervals[] = { 1, 1 }; |
| 501 p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals),
0)); | 501 p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals),
0)); |
| 502 |
| 503 canvas->translate(50, 50); |
| 502 canvas->drawPath(lines, p); | 504 canvas->drawPath(lines, p); |
| 503 } | 505 } |
| 504 | 506 |
| 505 DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) { | 507 DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) { |
| 506 SkPaint p; | 508 SkPaint p; |
| 507 p.setAntiAlias(true); | 509 p.setAntiAlias(true); |
| 508 p.setStyle(SkPaint::kStroke_Style); | 510 p.setStyle(SkPaint::kStroke_Style); |
| 509 p.setStrokeWidth(80); | 511 p.setStrokeWidth(80); |
| 510 | 512 |
| 511 const SkScalar intervals[] = { 2, 2 }; | 513 const SkScalar intervals[] = { 2, 2 }; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 547 } |
| 546 | 548 |
| 547 ////////////////////////////////////////////////////////////////////////////// | 549 ////////////////////////////////////////////////////////////////////////////// |
| 548 | 550 |
| 549 DEF_GM(return new DashingGM;) | 551 DEF_GM(return new DashingGM;) |
| 550 DEF_GM(return new Dashing2GM;) | 552 DEF_GM(return new Dashing2GM;) |
| 551 DEF_GM(return new Dashing3GM;) | 553 DEF_GM(return new Dashing3GM;) |
| 552 DEF_GM(return new Dashing4GM;) | 554 DEF_GM(return new Dashing4GM;) |
| 553 DEF_GM(return new Dashing5GM(true);) | 555 DEF_GM(return new Dashing5GM(true);) |
| 554 DEF_GM(return new Dashing5GM(false);) | 556 DEF_GM(return new Dashing5GM(false);) |
| OLD | NEW |