OLD | NEW |
---|---|
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 "SkScanPriv.h" | 8 #include "SkScanPriv.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkEdge.h" | 10 #include "SkEdge.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 // | 426 // |
427 // clipRect (if no null) has already been shifted up | 427 // clipRect (if no null) has already been shifted up |
428 // | 428 // |
429 void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte r, | 429 void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte r, |
430 int start_y, int stop_y, int shiftEdgesUp, const SkRegion& cli pRgn) { | 430 int start_y, int stop_y, int shiftEdgesUp, const SkRegion& cli pRgn) { |
431 SkASSERT(blitter); | 431 SkASSERT(blitter); |
432 | 432 |
433 SkEdgeBuilder builder; | 433 SkEdgeBuilder builder; |
434 | 434 |
435 // If we're convex, then we need both edges, even the right edge is past the clip | 435 // If we're convex, then we need both edges, even the right edge is past the clip |
436 const bool cullToTheRight = !path.isConvex(); | 436 const bool canCullToTheRight = !path.isConvex(); |
437 | 437 |
438 int count = builder.build(path, clipRect, shiftEdgesUp, cullToTheRight); | 438 int count = builder.build(path, clipRect, shiftEdgesUp, canCullToTheRight); |
439 SkASSERT(count >= 0); | |
440 | |
439 SkEdge** list = builder.edgeList(); | 441 SkEdge** list = builder.edgeList(); |
440 | 442 |
441 if (count < 2) { | 443 if (0 == count) { |
caryclark
2015/02/09 16:06:30
I don't mind this pattern -- but is it preferable
| |
442 if (path.isInverseFillType()) { | 444 if (path.isInverseFillType()) { |
443 /* | 445 /* |
444 * Since we are in inverse-fill, our caller has already drawn above | 446 * Since we are in inverse-fill, our caller has already drawn above |
445 * our top (start_y) and will draw below our bottom (stop_y). Thus | 447 * our top (start_y) and will draw below our bottom (stop_y). Thus |
446 * we need to restrict our drawing to the intersection of the clip | 448 * we need to restrict our drawing to the intersection of the clip |
447 * and those two limits. | 449 * and those two limits. |
448 */ | 450 */ |
449 SkIRect rect = clipRgn.getBounds(); | 451 SkIRect rect = clipRgn.getBounds(); |
450 if (rect.fTop < start_y) { | 452 if (rect.fTop < start_y) { |
451 rect.fTop = start_y; | 453 rect.fTop = start_y; |
452 } | 454 } |
453 if (rect.fBottom > stop_y) { | 455 if (rect.fBottom > stop_y) { |
454 rect.fBottom = stop_y; | 456 rect.fBottom = stop_y; |
455 } | 457 } |
456 if (!rect.isEmpty()) { | 458 if (!rect.isEmpty()) { |
457 blitter->blitRect(rect.fLeft << shiftEdgesUp, | 459 blitter->blitRect(rect.fLeft << shiftEdgesUp, |
458 rect.fTop << shiftEdgesUp, | 460 rect.fTop << shiftEdgesUp, |
459 rect.width() << shiftEdgesUp, | 461 rect.width() << shiftEdgesUp, |
460 rect.height() << shiftEdgesUp); | 462 rect.height() << shiftEdgesUp); |
461 } | 463 } |
462 } | 464 } |
463 | |
464 return; | 465 return; |
465 } | 466 } |
466 | 467 |
467 SkEdge headEdge, tailEdge, *last; | 468 SkEdge headEdge, tailEdge, *last; |
468 // this returns the first and last edge after they're sorted into a dlink li st | 469 // this returns the first and last edge after they're sorted into a dlink li st |
469 SkEdge* edge = sort_edges(list, count, &last); | 470 SkEdge* edge = sort_edges(list, count, &last); |
470 | 471 |
471 headEdge.fPrev = NULL; | 472 headEdge.fPrev = NULL; |
472 headEdge.fNext = edge; | 473 headEdge.fNext = edge; |
473 headEdge.fFirstY = kEDGE_HEAD_Y; | 474 headEdge.fFirstY = kEDGE_HEAD_Y; |
(...skipping 19 matching lines...) Expand all Loading... | |
493 InverseBlitter ib; | 494 InverseBlitter ib; |
494 PrePostProc proc = NULL; | 495 PrePostProc proc = NULL; |
495 | 496 |
496 if (path.isInverseFillType()) { | 497 if (path.isInverseFillType()) { |
497 ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp); | 498 ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp); |
498 blitter = &ib; | 499 blitter = &ib; |
499 proc = PrePostInverseBlitterProc; | 500 proc = PrePostInverseBlitterProc; |
500 } | 501 } |
501 | 502 |
502 if (path.isConvex() && (NULL == proc)) { | 503 if (path.isConvex() && (NULL == proc)) { |
504 SkASSERT(count >= 2); // convex walker does not handle missing right e dges | |
503 walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_ y, NULL); | 505 walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_ y, NULL); |
504 } else { | 506 } else { |
505 int rightEdge; | 507 int rightEdge; |
506 if (clipRect) { | 508 if (clipRect) { |
507 rightEdge = clipRect->right(); | 509 rightEdge = clipRect->right(); |
508 } else { | 510 } else { |
509 rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdg esUp; | 511 rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdg esUp; |
510 } | 512 } |
511 | 513 |
512 walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc , rightEdge); | 514 walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc , rightEdge); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 clipRgn = &wrap.getRgn(); | 732 clipRgn = &wrap.getRgn(); |
731 blitter = wrap.getBlitter(); | 733 blitter = wrap.getBlitter(); |
732 } | 734 } |
733 | 735 |
734 SkScanClipper clipper(blitter, clipRgn, ir); | 736 SkScanClipper clipper(blitter, clipRgn, ir); |
735 blitter = clipper.getBlitter(); | 737 blitter = clipper.getBlitter(); |
736 if (blitter) { | 738 if (blitter) { |
737 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); | 739 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); |
738 } | 740 } |
739 } | 741 } |
OLD | NEW |