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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 SkDEBUGFAIL("blitV unexpected"); | 339 SkDEBUGFAIL("blitV unexpected"); |
340 } | 340 } |
341 void blitRect(int x, int y, int width, int height) override { | 341 void blitRect(int x, int y, int width, int height) override { |
342 SkDEBUGFAIL("blitRect unexpected"); | 342 SkDEBUGFAIL("blitRect unexpected"); |
343 } | 343 } |
344 void blitMask(const SkMask&, const SkIRect& clip) override { | 344 void blitMask(const SkMask&, const SkIRect& clip) override { |
345 SkDEBUGFAIL("blitMask unexpected"); | 345 SkDEBUGFAIL("blitMask unexpected"); |
346 } | 346 } |
347 const SkPixmap* justAnOpaqueColor(uint32_t* value) override { | 347 const SkPixmap* justAnOpaqueColor(uint32_t* value) override { |
348 SkDEBUGFAIL("justAnOpaqueColor unexpected"); | 348 SkDEBUGFAIL("justAnOpaqueColor unexpected"); |
349 return NULL; | 349 return nullptr; |
350 } | 350 } |
351 | 351 |
352 private: | 352 private: |
353 SkBlitter* fBlitter; | 353 SkBlitter* fBlitter; |
354 int fFirstX, fLastX, fPrevX; | 354 int fFirstX, fLastX, fPrevX; |
355 }; | 355 }; |
356 | 356 |
357 static void PrePostInverseBlitterProc(SkBlitter* blitter, int y, bool isStart) { | 357 static void PrePostInverseBlitterProc(SkBlitter* blitter, int y, bool isStart) { |
358 ((InverseBlitter*)blitter)->prepost(y, isStart); | 358 ((InverseBlitter*)blitter)->prepost(y, isStart); |
359 } | 359 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 rect.height() << shiftEdgesUp); | 430 rect.height() << shiftEdgesUp); |
431 } | 431 } |
432 } | 432 } |
433 return; | 433 return; |
434 } | 434 } |
435 | 435 |
436 SkEdge headEdge, tailEdge, *last; | 436 SkEdge headEdge, tailEdge, *last; |
437 // this returns the first and last edge after they're sorted into a dlink li
st | 437 // this returns the first and last edge after they're sorted into a dlink li
st |
438 SkEdge* edge = sort_edges(list, count, &last); | 438 SkEdge* edge = sort_edges(list, count, &last); |
439 | 439 |
440 headEdge.fPrev = NULL; | 440 headEdge.fPrev = nullptr; |
441 headEdge.fNext = edge; | 441 headEdge.fNext = edge; |
442 headEdge.fFirstY = kEDGE_HEAD_Y; | 442 headEdge.fFirstY = kEDGE_HEAD_Y; |
443 headEdge.fX = SK_MinS32; | 443 headEdge.fX = SK_MinS32; |
444 edge->fPrev = &headEdge; | 444 edge->fPrev = &headEdge; |
445 | 445 |
446 tailEdge.fPrev = last; | 446 tailEdge.fPrev = last; |
447 tailEdge.fNext = NULL; | 447 tailEdge.fNext = nullptr; |
448 tailEdge.fFirstY = kEDGE_TAIL_Y; | 448 tailEdge.fFirstY = kEDGE_TAIL_Y; |
449 last->fNext = &tailEdge; | 449 last->fNext = &tailEdge; |
450 | 450 |
451 // now edge is the head of the sorted linklist | 451 // now edge is the head of the sorted linklist |
452 | 452 |
453 start_y <<= shiftEdgesUp; | 453 start_y <<= shiftEdgesUp; |
454 stop_y <<= shiftEdgesUp; | 454 stop_y <<= shiftEdgesUp; |
455 if (clipRect && start_y < clipRect->fTop) { | 455 if (clipRect && start_y < clipRect->fTop) { |
456 start_y = clipRect->fTop; | 456 start_y = clipRect->fTop; |
457 } | 457 } |
458 if (clipRect && stop_y > clipRect->fBottom) { | 458 if (clipRect && stop_y > clipRect->fBottom) { |
459 stop_y = clipRect->fBottom; | 459 stop_y = clipRect->fBottom; |
460 } | 460 } |
461 | 461 |
462 InverseBlitter ib; | 462 InverseBlitter ib; |
463 PrePostProc proc = NULL; | 463 PrePostProc proc = nullptr; |
464 | 464 |
465 if (path.isInverseFillType()) { | 465 if (path.isInverseFillType()) { |
466 ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp); | 466 ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp); |
467 blitter = &ib; | 467 blitter = &ib; |
468 proc = PrePostInverseBlitterProc; | 468 proc = PrePostInverseBlitterProc; |
469 } | 469 } |
470 | 470 |
471 if (path.isConvex() && (NULL == proc)) { | 471 if (path.isConvex() && (nullptr == proc)) { |
472 SkASSERT(count >= 2); // convex walker does not handle missing right e
dges | 472 SkASSERT(count >= 2); // convex walker does not handle missing right e
dges |
473 walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_
y, NULL); | 473 walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_
y, nullptr); |
474 } else { | 474 } else { |
475 int rightEdge; | 475 int rightEdge; |
476 if (clipRect) { | 476 if (clipRect) { |
477 rightEdge = clipRect->right(); | 477 rightEdge = clipRect->right(); |
478 } else { | 478 } else { |
479 rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdg
esUp; | 479 rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdg
esUp; |
480 } | 480 } |
481 | 481 |
482 walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc
, rightEdge); | 482 walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc
, rightEdge); |
483 } | 483 } |
(...skipping 27 matching lines...) Expand all Loading... |
511 | 511 |
512 /////////////////////////////////////////////////////////////////////////////// | 512 /////////////////////////////////////////////////////////////////////////////// |
513 | 513 |
514 /** | 514 /** |
515 * If the caller is drawing an inverse-fill path, then it pass true for | 515 * If the caller is drawing an inverse-fill path, then it pass true for |
516 * skipRejectTest, so we don't abort drawing just because the src bounds (ir) | 516 * skipRejectTest, so we don't abort drawing just because the src bounds (ir) |
517 * is outside of the clip. | 517 * is outside of the clip. |
518 */ | 518 */ |
519 SkScanClipper::SkScanClipper(SkBlitter* blitter, const SkRegion* clip, | 519 SkScanClipper::SkScanClipper(SkBlitter* blitter, const SkRegion* clip, |
520 const SkIRect& ir, bool skipRejectTest) { | 520 const SkIRect& ir, bool skipRejectTest) { |
521 fBlitter = NULL; // null means blit nothing | 521 fBlitter = nullptr; // null means blit nothing |
522 fClipRect = NULL; | 522 fClipRect = nullptr; |
523 | 523 |
524 if (clip) { | 524 if (clip) { |
525 fClipRect = &clip->getBounds(); | 525 fClipRect = &clip->getBounds(); |
526 if (!skipRejectTest && !SkIRect::Intersects(*fClipRect, ir)) { // comple
tely clipped out | 526 if (!skipRejectTest && !SkIRect::Intersects(*fClipRect, ir)) { // comple
tely clipped out |
527 return; | 527 return; |
528 } | 528 } |
529 | 529 |
530 if (clip->isRect()) { | 530 if (clip->isRect()) { |
531 if (fClipRect->contains(ir)) { | 531 if (fClipRect->contains(ir)) { |
532 fClipRect = NULL; | 532 fClipRect = nullptr; |
533 } else { | 533 } else { |
534 // only need a wrapper blitter if we're horizontally clipped | 534 // only need a wrapper blitter if we're horizontally clipped |
535 if (fClipRect->fLeft > ir.fLeft || fClipRect->fRight < ir.fRight
) { | 535 if (fClipRect->fLeft > ir.fLeft || fClipRect->fRight < ir.fRight
) { |
536 fRectBlitter.init(blitter, *fClipRect); | 536 fRectBlitter.init(blitter, *fClipRect); |
537 blitter = &fRectBlitter; | 537 blitter = &fRectBlitter; |
538 } | 538 } |
539 } | 539 } |
540 } else { | 540 } else { |
541 fRgnBlitter.init(blitter, clip); | 541 fRgnBlitter.init(blitter, clip); |
542 blitter = &fRgnBlitter; | 542 blitter = &fRgnBlitter; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 int count = build_tri_edges(edgeStorage, pts, clipRect, list); | 646 int count = build_tri_edges(edgeStorage, pts, clipRect, list); |
647 if (count < 2) { | 647 if (count < 2) { |
648 return; | 648 return; |
649 } | 649 } |
650 | 650 |
651 SkEdge headEdge, tailEdge, *last; | 651 SkEdge headEdge, tailEdge, *last; |
652 | 652 |
653 // this returns the first and last edge after they're sorted into a dlink li
st | 653 // this returns the first and last edge after they're sorted into a dlink li
st |
654 SkEdge* edge = sort_edges(list, count, &last); | 654 SkEdge* edge = sort_edges(list, count, &last); |
655 | 655 |
656 headEdge.fPrev = NULL; | 656 headEdge.fPrev = nullptr; |
657 headEdge.fNext = edge; | 657 headEdge.fNext = edge; |
658 headEdge.fFirstY = kEDGE_HEAD_Y; | 658 headEdge.fFirstY = kEDGE_HEAD_Y; |
659 headEdge.fX = SK_MinS32; | 659 headEdge.fX = SK_MinS32; |
660 edge->fPrev = &headEdge; | 660 edge->fPrev = &headEdge; |
661 | 661 |
662 tailEdge.fPrev = last; | 662 tailEdge.fPrev = last; |
663 tailEdge.fNext = NULL; | 663 tailEdge.fNext = nullptr; |
664 tailEdge.fFirstY = kEDGE_TAIL_Y; | 664 tailEdge.fFirstY = kEDGE_TAIL_Y; |
665 last->fNext = &tailEdge; | 665 last->fNext = &tailEdge; |
666 | 666 |
667 // now edge is the head of the sorted linklist | 667 // now edge is the head of the sorted linklist |
668 int stop_y = ir.fBottom; | 668 int stop_y = ir.fBottom; |
669 if (clipRect && stop_y > clipRect->fBottom) { | 669 if (clipRect && stop_y > clipRect->fBottom) { |
670 stop_y = clipRect->fBottom; | 670 stop_y = clipRect->fBottom; |
671 } | 671 } |
672 int start_y = ir.fTop; | 672 int start_y = ir.fTop; |
673 if (clipRect && start_y < clipRect->fTop) { | 673 if (clipRect && start_y < clipRect->fTop) { |
674 start_y = clipRect->fTop; | 674 start_y = clipRect->fTop; |
675 } | 675 } |
676 walk_convex_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, st
op_y, NULL); | 676 walk_convex_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, st
op_y, nullptr); |
677 // walk_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, stop_y,
NULL); | 677 // walk_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, stop_y,
nullptr); |
678 } | 678 } |
679 | 679 |
680 void SkScan::FillTriangle(const SkPoint pts[], const SkRasterClip& clip, | 680 void SkScan::FillTriangle(const SkPoint pts[], const SkRasterClip& clip, |
681 SkBlitter* blitter) { | 681 SkBlitter* blitter) { |
682 if (clip.isEmpty()) { | 682 if (clip.isEmpty()) { |
683 return; | 683 return; |
684 } | 684 } |
685 | 685 |
686 SkRect r; | 686 SkRect r; |
687 SkIRect ir; | 687 SkIRect ir; |
(...skipping 12 matching lines...) Expand all Loading... |
700 clipRgn = &wrap.getRgn(); | 700 clipRgn = &wrap.getRgn(); |
701 blitter = wrap.getBlitter(); | 701 blitter = wrap.getBlitter(); |
702 } | 702 } |
703 | 703 |
704 SkScanClipper clipper(blitter, clipRgn, ir); | 704 SkScanClipper clipper(blitter, clipRgn, ir); |
705 blitter = clipper.getBlitter(); | 705 blitter = clipper.getBlitter(); |
706 if (blitter) { | 706 if (blitter) { |
707 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); | 707 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); |
708 } | 708 } |
709 } | 709 } |
OLD | NEW |