| 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 #ifndef SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
| 9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
| 10 | 10 |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 this to check if an area you intend to draw into is clipped out (and | 549 this to check if an area you intend to draw into is clipped out (and |
| 550 therefore you can skip making the draw calls). Note, for speed it may | 550 therefore you can skip making the draw calls). Note, for speed it may |
| 551 return false even if the path itself might not intersect the clip | 551 return false even if the path itself might not intersect the clip |
| 552 (i.e. the bounds of the path intersects, but the path does not). | 552 (i.e. the bounds of the path intersects, but the path does not). |
| 553 @param path The path to compare with the current clip | 553 @param path The path to compare with the current clip |
| 554 @return true if the path (transformed by the canvas' matrix) does not | 554 @return true if the path (transformed by the canvas' matrix) does not |
| 555 intersect with the canvas' clip | 555 intersect with the canvas' clip |
| 556 */ | 556 */ |
| 557 bool quickReject(const SkPath& path) const; | 557 bool quickReject(const SkPath& path) const; |
| 558 | 558 |
| 559 /** Return true if the horizontal band specified by top and bottom is | |
| 560 completely clipped out. This is a conservative calculation, meaning | |
| 561 that it is possible that if the method returns false, the band may still | |
| 562 in fact be clipped out, but the converse is not true. If this method | |
| 563 returns true, then the band is guaranteed to be clipped out. | |
| 564 @param top The top of the horizontal band to compare with the clip | |
| 565 @param bottom The bottom of the horizontal and to compare with the clip | |
| 566 @return true if the horizontal band is completely clipped out (i.e. does | |
| 567 not intersect the current clip) | |
| 568 */ | |
| 569 bool quickRejectY(SkScalar top, SkScalar bottom) const { | |
| 570 SkASSERT(top <= bottom); | |
| 571 | |
| 572 #ifndef SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT | |
| 573 // TODO: add a hasPerspective method similar to getLocalClipBounds. This | |
| 574 // would cache the SkMatrix::hasPerspective result. Alternatively, have | |
| 575 // the MC stack just set a hasPerspective boolean as it is updated. | |
| 576 if (this->getTotalMatrix().hasPerspective()) { | |
| 577 // TODO: consider implementing some half-plane test between the | |
| 578 // two Y planes and the device-bounds (i.e., project the top and | |
| 579 // bottom Y planes and then determine if the clip bounds is complete
ly | |
| 580 // outside either one). | |
| 581 return false; | |
| 582 } | |
| 583 #endif | |
| 584 | |
| 585 const SkRect& clipR = this->getLocalClipBounds(); | |
| 586 // In the case where the clip is empty and we are provided with a | |
| 587 // negative top and positive bottom parameter then this test will return | |
| 588 // false even though it will be clipped. We have chosen to exclude that | |
| 589 // check as it is rare and would result double the comparisons. | |
| 590 return top >= clipR.fBottom || bottom <= clipR.fTop; | |
| 591 } | |
| 592 | |
| 593 /** Return the bounds of the current clip (in local coordinates) in the | 559 /** Return the bounds of the current clip (in local coordinates) in the |
| 594 bounds parameter, and return true if it is non-empty. This can be useful | 560 bounds parameter, and return true if it is non-empty. This can be useful |
| 595 in a way similar to quickReject, in that it tells you that drawing | 561 in a way similar to quickReject, in that it tells you that drawing |
| 596 outside of these bounds will be clipped out. | 562 outside of these bounds will be clipped out. |
| 597 */ | 563 */ |
| 598 virtual bool getClipBounds(SkRect* bounds) const; | 564 virtual bool getClipBounds(SkRect* bounds) const; |
| 599 | 565 |
| 600 /** Return the bounds of the current clip, in device coordinates; returns | 566 /** Return the bounds of the current clip, in device coordinates; returns |
| 601 true if non-empty. Maybe faster than getting the clip explicitly and | 567 true if non-empty. Maybe faster than getting the clip explicitly and |
| 602 then taking its bounds. | 568 then taking its bounds. |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 | 1683 |
| 1718 class SkCanvasClipVisitor { | 1684 class SkCanvasClipVisitor { |
| 1719 public: | 1685 public: |
| 1720 virtual ~SkCanvasClipVisitor(); | 1686 virtual ~SkCanvasClipVisitor(); |
| 1721 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1687 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1722 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1688 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1723 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1689 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1724 }; | 1690 }; |
| 1725 | 1691 |
| 1726 #endif | 1692 #endif |
| OLD | NEW |