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

Side by Side Diff: gm/strokes.cpp

Issue 1547483003: fix hair fuzz (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: handle case where all points are equal 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 | src/core/SkScan_Hairline.cpp » ('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 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 path.lineTo(60, 30); 229 path.lineTo(60, 30);
230 canvas->drawPath(path, paint); 230 canvas->drawPath(path, paint);
231 231
232 path.reset(); 232 path.reset();
233 path.moveTo(30, 60); 233 path.moveTo(30, 60);
234 path.lineTo(30, 60); 234 path.lineTo(30, 60);
235 path.lineTo(60, 60); 235 path.lineTo(60, 60);
236 canvas->drawPath(path, paint); 236 canvas->drawPath(path, paint);
237 } 237 }
238 238
239 DEF_SIMPLE_GM(quadcap, canvas, 200, 200) {
240 SkPaint p;
241 p.setAntiAlias(true);
242 p.setStyle(SkPaint::kStroke_Style);
243 p.setStrokeWidth(0);
244 SkPath path;
245 SkPoint pts[] = {{105.738571f,13.126318f},
246 {105.738571f,13.126318f},
247 {123.753784f,1.f}};
248 SkVector tangent = pts[1] - pts[2];
249 tangent.normalize();
250 SkPoint pts2[3];
251 memcpy(pts2, pts, sizeof(pts));
252 const SkScalar capOutset = SK_ScalarPI / 8;
253 pts2[0].fX += tangent.fX * capOutset;
254 pts2[0].fY += tangent.fY * capOutset;
255 pts2[1].fX += tangent.fX * capOutset;
256 pts2[1].fY += tangent.fY * capOutset;
257 pts2[2].fX += -tangent.fX * capOutset;
258 pts2[2].fY += -tangent.fY * capOutset;
259 path.moveTo(pts2[0]);
260 path.quadTo(pts2[1], pts2[2]);
261 canvas->drawPath(path, p);
262
263 path.reset();
264 path.moveTo(pts[0]);
265 path.quadTo(pts[1], pts[2]);
266 p.setStrokeCap(SkPaint::kRound_Cap);
267 canvas->translate(30, 0);
268 canvas->drawPath(path, p);
269 }
270
239 class Strokes2GM : public skiagm::GM { 271 class Strokes2GM : public skiagm::GM {
240 SkPath fPath; 272 SkPath fPath;
241 protected: 273 protected:
242 void onOnceBeforeDraw() override { 274 void onOnceBeforeDraw() override {
243 SkRandom rand; 275 SkRandom rand;
244 fPath.moveTo(0, 0); 276 fPath.moveTo(0, 0);
245 for (int i = 0; i < 13; i++) { 277 for (int i = 0; i < 13; i++) {
246 SkScalar x = rand.nextUScalar1() * (W >> 1); 278 SkScalar x = rand.nextUScalar1() * (W >> 1);
247 SkScalar y = rand.nextUScalar1() * (H >> 1); 279 SkScalar y = rand.nextUScalar1() * (H >> 1);
248 fPath.lineTo(x, y); 280 fPath.lineTo(x, y);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 ////////////////////////////////////////////////////////////////////////////// 516 //////////////////////////////////////////////////////////////////////////////
485 517
486 DEF_GM( return new StrokesGM; ) 518 DEF_GM( return new StrokesGM; )
487 DEF_GM( return new Strokes2GM; ) 519 DEF_GM( return new Strokes2GM; )
488 DEF_GM( return new Strokes3GM; ) 520 DEF_GM( return new Strokes3GM; )
489 DEF_GM( return new Strokes4GM; ) 521 DEF_GM( return new Strokes4GM; )
490 DEF_GM( return new Strokes5GM; ) 522 DEF_GM( return new Strokes5GM; )
491 523
492 DEF_GM( return new ZeroLenStrokesGM; ) 524 DEF_GM( return new ZeroLenStrokesGM; )
493 DEF_GM( return new TeenyStrokesGM; ) 525 DEF_GM( return new TeenyStrokesGM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkScan_Hairline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698