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

Side by Side Diff: gm/dashing.cpp

Issue 1534223002: fix large dashed paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | include/core/SkPathMeasure.h » ('j') | 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 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
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) {
480 SkPath lines;
481 for (int x = 32; x < 256; x += 16) {
482 for (SkScalar a = 0; a < 3.141592f * 2; a += 0.03141592f) {
483 SkPoint pts[2] = {
484 { 256 + (float) sin(a) * x,
485 256 + (float) cos(a) * x },
486 { 256 + (float) sin(a + 3.141592 / 3) * (x + 64),
487 256 + (float) cos(a + 3.141592 / 3) * (x + 64) }
488 };
489 lines.moveTo(pts[0]);
490 for (SkScalar i = 0; i < 1; i += 0.05f) {
491 lines.lineTo(pts[0].fX * (1 - i) + pts[1].fX * i,
492 pts[0].fY * (1 - i) + pts[1].fY * i);
493 }
494 }
495 }
496 SkPaint p;
497 p.setAntiAlias(true);
498 p.setStyle(SkPaint::kStroke_Style);
499 p.setStrokeWidth(1);
500 const SkScalar intervals[] = { 1, 1 };
501 p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals ), 0))->unref();
502 canvas->drawPath(lines, p);
503 }
504
479 ////////////////////////////////////////////////////////////////////////////// 505 //////////////////////////////////////////////////////////////////////////////
480 506
481 DEF_GM(return new DashingGM;) 507 DEF_GM(return new DashingGM;)
482 DEF_GM(return new Dashing2GM;) 508 DEF_GM(return new Dashing2GM;)
483 DEF_GM(return new Dashing3GM;) 509 DEF_GM(return new Dashing3GM;)
484 DEF_GM(return new Dashing4GM;) 510 DEF_GM(return new Dashing4GM;)
485 DEF_GM(return new Dashing5GM(true);) 511 DEF_GM(return new Dashing5GM(true);)
486 DEF_GM(return new Dashing5GM(false);) 512 DEF_GM(return new Dashing5GM(false);)
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPathMeasure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698