Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkClipStack.h" | 9 #include "SkClipStack.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 fFiniteBoundType = kInsideOut_BoundsType; | 412 fFiniteBoundType = kInsideOut_BoundsType; |
| 413 } else { | 413 } else { |
| 414 fFiniteBoundType = kNormal_BoundsType; | 414 fFiniteBoundType = kNormal_BoundsType; |
| 415 } | 415 } |
| 416 break; | 416 break; |
| 417 case kEmpty_Type: | 417 case kEmpty_Type: |
| 418 SkDEBUGFAIL("We shouldn't get here with an empty element."); | 418 SkDEBUGFAIL("We shouldn't get here with an empty element."); |
| 419 break; | 419 break; |
| 420 } | 420 } |
| 421 | 421 |
| 422 if (!fDoAA) { | 422 if (!fDoAA) { |
|
robertphillips
2015/02/10 14:54:07
Just FYI - if we replace the 0.45f oddness with an
bsalomon
2015/02/10 15:57:24
eek, do we know why that happens?
| |
| 423 // Here we mimic a non-anti-aliased scanline system. If there is | |
| 424 // no anti-aliasing we can integerize the bounding box to exclude | |
| 425 // fractional parts that won't be rendered. | |
| 426 // Note: the left edge is handled slightly differently below. We | |
| 427 // are a bit more generous in the rounding since we don't want to | |
| 428 // risk missing the left pixels when fLeft is very close to .5 | |
| 429 fFiniteBound.set(SkScalarFloorToScalar(fFiniteBound.fLeft+0.45f), | 423 fFiniteBound.set(SkScalarFloorToScalar(fFiniteBound.fLeft+0.45f), |
| 430 SkScalarRoundToScalar(fFiniteBound.fTop), | 424 SkScalarRoundToScalar(fFiniteBound.fTop), |
| 431 SkScalarRoundToScalar(fFiniteBound.fRight), | 425 SkScalarRoundToScalar(fFiniteBound.fRight), |
| 432 SkScalarRoundToScalar(fFiniteBound.fBottom)); | 426 SkScalarRoundToScalar(fFiniteBound.fBottom)); |
| 433 } | 427 } |
| 434 | 428 |
| 435 // Now determine the previous Element's bound information taking into | 429 // Now determine the previous Element's bound information taking into |
| 436 // account that there may be no previous clip | 430 // account that there may be no previous clip |
| 437 SkRect prevFinite; | 431 SkRect prevFinite; |
| 438 SkClipStack::BoundsType prevType; | 432 SkClipStack::BoundsType prevType; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 return; | 609 return; |
| 616 } | 610 } |
| 617 | 611 |
| 618 *canvFiniteBound = element->fFiniteBound; | 612 *canvFiniteBound = element->fFiniteBound; |
| 619 *boundType = element->fFiniteBoundType; | 613 *boundType = element->fFiniteBoundType; |
| 620 if (isIntersectionOfRects) { | 614 if (isIntersectionOfRects) { |
| 621 *isIntersectionOfRects = element->fIsIntersectionOfRects; | 615 *isIntersectionOfRects = element->fIsIntersectionOfRects; |
| 622 } | 616 } |
| 623 } | 617 } |
| 624 | 618 |
| 625 bool SkClipStack::intersectRectWithClip(SkRect* rect) const { | |
| 626 SkASSERT(rect); | |
| 627 | |
| 628 SkRect bounds; | |
| 629 SkClipStack::BoundsType bt; | |
| 630 this->getBounds(&bounds, &bt); | |
| 631 if (bt == SkClipStack::kInsideOut_BoundsType) { | |
| 632 if (bounds.contains(*rect)) { | |
| 633 return false; | |
| 634 } else { | |
| 635 // If rect's x values are both within bound's x range we | |
| 636 // could clip here. Same for y. But we don't bother to check. | |
| 637 return true; | |
| 638 } | |
| 639 } else { | |
| 640 return rect->intersect(bounds); | |
| 641 } | |
| 642 } | |
| 643 | |
| 644 bool SkClipStack::quickContains(const SkRect& rect) const { | 619 bool SkClipStack::quickContains(const SkRect& rect) const { |
| 645 | 620 |
| 646 Iter iter(*this, Iter::kTop_IterStart); | 621 Iter iter(*this, Iter::kTop_IterStart); |
| 647 const Element* element = iter.prev(); | 622 const Element* element = iter.prev(); |
| 648 while (element != NULL) { | 623 while (element != NULL) { |
| 649 if (SkRegion::kIntersect_Op != element->getOp() && SkRegion::kReplace_Op != element->getOp()) | 624 if (SkRegion::kIntersect_Op != element->getOp() && SkRegion::kReplace_Op != element->getOp()) |
| 650 return false; | 625 return false; |
| 651 if (element->isInverseFilled()) { | 626 if (element->isInverseFilled()) { |
| 652 // Part of 'rect' could be trimmed off by the inverse-filled clip el ement | 627 // Part of 'rect' could be trimmed off by the inverse-filled clip el ement |
| 653 if (SkRect::Intersects(element->getBounds(), rect)) { | 628 if (SkRect::Intersects(element->getBounds(), rect)) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 | 906 |
| 932 void SkClipStack::dump() const { | 907 void SkClipStack::dump() const { |
| 933 B2TIter iter(*this); | 908 B2TIter iter(*this); |
| 934 const Element* e; | 909 const Element* e; |
| 935 while ((e = iter.next())) { | 910 while ((e = iter.next())) { |
| 936 e->dump(); | 911 e->dump(); |
| 937 SkDebugf("\n"); | 912 SkDebugf("\n"); |
| 938 } | 913 } |
| 939 } | 914 } |
| 940 #endif | 915 #endif |
| OLD | NEW |