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

Side by Side Diff: src/core/SkScan_Hairline.cpp

Issue 1497283002: use RawIter in hairpath (simplifies) (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 | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkScan.h" 8 #include "SkScan.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkRasterClip.h" 10 #include "SkRasterClip.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (rclip.isBW()) { 367 if (rclip.isBW()) {
368 clip = &rclip.bwRgn(); 368 clip = &rclip.bwRgn();
369 } else { 369 } else {
370 wrap.init(rclip, blitter); 370 wrap.init(rclip, blitter);
371 blitter = wrap.getBlitter(); 371 blitter = wrap.getBlitter();
372 clip = &wrap.getRgn(); 372 clip = &wrap.getRgn();
373 } 373 }
374 } 374 }
375 } 375 }
376 376
377 SkPath::Iter iter(path, false); 377 SkPath::RawIter iter(path);
378 SkPoint pts[4]; 378 SkPoint pts[4], firstPt, lastPt;
379 SkPath::Verb verb; 379 SkPath::Verb verb;
380 SkAutoConicToQuads converter; 380 SkAutoConicToQuads converter;
381 381
382 while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) { 382 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
383 switch (verb) { 383 switch (verb) {
384 case SkPath::kMove_Verb: 384 case SkPath::kMove_Verb:
385 firstPt = lastPt = pts[0];
385 break; 386 break;
386 case SkPath::kLine_Verb: 387 case SkPath::kLine_Verb:
387 lineproc(pts, 2, clip, blitter); 388 lineproc(pts, 2, clip, blitter);
389 lastPt = pts[1];
388 break; 390 break;
389 case SkPath::kQuad_Verb: 391 case SkPath::kQuad_Verb:
390 hairquad(pts, clip, blitter, compute_quad_level(pts), lineproc); 392 hairquad(pts, clip, blitter, compute_quad_level(pts), lineproc);
393 lastPt = pts[2];
391 break; 394 break;
392 case SkPath::kConic_Verb: { 395 case SkPath::kConic_Verb: {
393 // how close should the quads be to the original conic? 396 // how close should the quads be to the original conic?
394 const SkScalar tol = SK_Scalar1 / 4; 397 const SkScalar tol = SK_Scalar1 / 4;
395 const SkPoint* quadPts = converter.computeQuads(pts, 398 const SkPoint* quadPts = converter.computeQuads(pts,
396 iter.conicWeight(), tol); 399 iter.conicWeight(), tol);
397 for (int i = 0; i < converter.countQuads(); ++i) { 400 for (int i = 0; i < converter.countQuads(); ++i) {
398 int level = compute_quad_level(quadPts); 401 int level = compute_quad_level(quadPts);
399 hairquad(quadPts, clip, blitter, level, lineproc); 402 hairquad(quadPts, clip, blitter, level, lineproc);
400 quadPts += 2; 403 quadPts += 2;
401 } 404 }
405 lastPt = pts[2];
402 break; 406 break;
403 } 407 }
404 case SkPath::kCubic_Verb: { 408 case SkPath::kCubic_Verb: {
405 haircubic(pts, clip, blitter, kMaxCubicSubdivideLevel, lineproc) ; 409 haircubic(pts, clip, blitter, kMaxCubicSubdivideLevel, lineproc) ;
410 lastPt = pts[3];
406 } break; 411 } break;
407 case SkPath::kClose_Verb: 412 case SkPath::kClose_Verb:
413 pts[0] = lastPt;
414 pts[1] = firstPt;
415 lineproc(pts, 2, clip, blitter);
408 break; 416 break;
409 case SkPath::kDone_Verb: 417 case SkPath::kDone_Verb:
410 break; 418 break;
411 } 419 }
412 } 420 }
413 } 421 }
414 422
415 void SkScan::HairPath(const SkPath& path, const SkRasterClip& clip, SkBlitter* b litter) { 423 void SkScan::HairPath(const SkPath& path, const SkRasterClip& clip, SkBlitter* b litter) {
416 hair_path(path, clip, blitter, SkScan::HairLineRgn); 424 hair_path(path, clip, blitter, SkScan::HairLineRgn);
417 } 425 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 498
491 SkAAClipBlitterWrapper wrap; 499 SkAAClipBlitterWrapper wrap;
492 if (!clip.quickContains(r.roundOut().makeOutset(1, 1))) { 500 if (!clip.quickContains(r.roundOut().makeOutset(1, 1))) {
493 wrap.init(clip, blitter); 501 wrap.init(clip, blitter);
494 blitter = wrap.getBlitter(); 502 blitter = wrap.getBlitter();
495 clipRgn = &wrap.getRgn(); 503 clipRgn = &wrap.getRgn();
496 } 504 }
497 AntiHairLineRgn(pts, count, clipRgn, blitter); 505 AntiHairLineRgn(pts, count, clipRgn, blitter);
498 } 506 }
499 } 507 }
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