| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 #ifndef SkRasterClip_DEFINED | 8 #ifndef SkRasterClip_DEFINED |
| 9 #define SkRasterClip_DEFINED | 9 #define SkRasterClip_DEFINED |
| 10 | 10 |
| 11 #include "SkRegion.h" | 11 #include "SkRegion.h" |
| 12 #include "SkAAClip.h" | 12 #include "SkAAClip.h" |
| 13 | 13 |
| 14 class SkRasterClip { | 14 class SkRasterClip { |
| 15 public: | 15 public: |
| 16 SkRasterClip(bool forceConservativeRects = false); | 16 SkRasterClip(); |
| 17 SkRasterClip(const SkIRect&, bool forceConservativeRects = false); | 17 SkRasterClip(const SkIRect&); |
| 18 SkRasterClip(const SkRasterClip&); | 18 SkRasterClip(const SkRasterClip&); |
| 19 ~SkRasterClip(); | 19 ~SkRasterClip(); |
| 20 | 20 |
| 21 bool isForceConservativeRects() const { return fForceConservativeRects; } | |
| 22 | |
| 23 bool isBW() const { return fIsBW; } | 21 bool isBW() const { return fIsBW; } |
| 24 bool isAA() const { return !fIsBW; } | 22 bool isAA() const { return !fIsBW; } |
| 25 const SkRegion& bwRgn() const { SkASSERT(fIsBW); return fBW; } | 23 const SkRegion& bwRgn() const { SkASSERT(fIsBW); return fBW; } |
| 26 const SkAAClip& aaRgn() const { SkASSERT(!fIsBW); return fAA; } | 24 const SkAAClip& aaRgn() const { SkASSERT(!fIsBW); return fAA; } |
| 27 | 25 |
| 28 bool isEmpty() const { | 26 bool isEmpty() const { |
| 29 SkASSERT(this->computeIsEmpty() == fIsEmpty); | 27 SkASSERT(this->computeIsEmpty() == fIsEmpty); |
| 30 return fIsEmpty; | 28 return fIsEmpty; |
| 31 } | 29 } |
| 32 | 30 |
| 33 bool isRect() const { | 31 bool isRect() const { |
| 34 SkASSERT(this->computeIsRect() == fIsRect); | 32 SkASSERT(this->computeIsRect() == fIsRect); |
| 35 return fIsRect; | 33 return fIsRect; |
| 36 } | 34 } |
| 37 | 35 |
| 38 bool isComplex() const; | 36 bool isComplex() const; |
| 39 const SkIRect& getBounds() const; | 37 const SkIRect& getBounds() const; |
| 40 | 38 |
| 41 bool setEmpty(); | 39 bool setEmpty(); |
| 42 bool setRect(const SkIRect&); | 40 bool setRect(const SkIRect&); |
| 43 | 41 |
| 44 bool op(const SkIRect&, SkRegion::Op); | 42 bool op(const SkIRect&, SkRegion::Op); |
| 45 bool op(const SkRegion&, SkRegion::Op); | 43 bool op(const SkRegion&, SkRegion::Op); |
| 46 bool op(const SkRect&, const SkISize&, SkRegion::Op, bool doAA); | 44 bool op(const SkRect&, SkRegion::Op, bool doAA); |
| 47 bool op(const SkPath&, const SkISize&, SkRegion::Op, bool doAA); | 45 bool op(const SkPath&, const SkISize&, SkRegion::Op, bool doAA); |
| 48 | 46 |
| 49 void translate(int dx, int dy, SkRasterClip* dst) const; | 47 void translate(int dx, int dy, SkRasterClip* dst) const; |
| 50 void translate(int dx, int dy) { | 48 void translate(int dx, int dy) { |
| 51 this->translate(dx, dy, this); | 49 this->translate(dx, dy, this); |
| 52 } | 50 } |
| 53 | 51 |
| 54 bool quickContains(const SkIRect& rect) const; | 52 bool quickContains(const SkIRect& rect) const; |
| 55 bool quickContains(int left, int top, int right, int bottom) const { | 53 bool quickContains(int left, int top, int right, int bottom) const { |
| 56 return quickContains(SkIRect::MakeLTRB(left, top, right, bottom)); | 54 return quickContains(SkIRect::MakeLTRB(left, top, right, bottom)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 | 68 |
| 71 #ifdef SK_DEBUG | 69 #ifdef SK_DEBUG |
| 72 void validate() const; | 70 void validate() const; |
| 73 #else | 71 #else |
| 74 void validate() const {} | 72 void validate() const {} |
| 75 #endif | 73 #endif |
| 76 | 74 |
| 77 private: | 75 private: |
| 78 SkRegion fBW; | 76 SkRegion fBW; |
| 79 SkAAClip fAA; | 77 SkAAClip fAA; |
| 80 bool fForceConservativeRects; | |
| 81 bool fIsBW; | 78 bool fIsBW; |
| 82 // these 2 are caches based on querying the right obj based on fIsBW | 79 // these 2 are caches based on querying the right obj based on fIsBW |
| 83 bool fIsEmpty; | 80 bool fIsEmpty; |
| 84 bool fIsRect; | 81 bool fIsRect; |
| 85 | 82 |
| 86 bool computeIsEmpty() const { | 83 bool computeIsEmpty() const { |
| 87 return fIsBW ? fBW.isEmpty() : fAA.isEmpty(); | 84 return fIsBW ? fBW.isEmpty() : fAA.isEmpty(); |
| 88 } | 85 } |
| 89 | 86 |
| 90 bool computeIsRect() const { | 87 bool computeIsRect() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 | 100 |
| 104 fIsRect = this->computeIsRect(); | 101 fIsRect = this->computeIsRect(); |
| 105 return !fIsEmpty; | 102 return !fIsEmpty; |
| 106 } | 103 } |
| 107 | 104 |
| 108 void convertToAA(); | 105 void convertToAA(); |
| 109 | 106 |
| 110 bool setPath(const SkPath& path, const SkRegion& clip, bool doAA); | 107 bool setPath(const SkPath& path, const SkRegion& clip, bool doAA); |
| 111 bool setPath(const SkPath& path, const SkIRect& clip, bool doAA); | 108 bool setPath(const SkPath& path, const SkIRect& clip, bool doAA); |
| 112 bool op(const SkRasterClip&, SkRegion::Op); | 109 bool op(const SkRasterClip&, SkRegion::Op); |
| 113 bool setConservativeRect(const SkRect& r, const SkIRect& clipR, bool isInver
se); | |
| 114 }; | 110 }; |
| 115 | 111 |
| 116 class SkAutoRasterClipValidate : SkNoncopyable { | 112 class SkAutoRasterClipValidate : SkNoncopyable { |
| 117 public: | 113 public: |
| 118 SkAutoRasterClipValidate(const SkRasterClip& rc) : fRC(rc) { | 114 SkAutoRasterClipValidate(const SkRasterClip& rc) : fRC(rc) { |
| 119 fRC.validate(); | 115 fRC.validate(); |
| 120 } | 116 } |
| 121 ~SkAutoRasterClipValidate() { | 117 ~SkAutoRasterClipValidate() { |
| 122 fRC.validate(); | 118 fRC.validate(); |
| 123 } | 119 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 162 |
| 167 private: | 163 private: |
| 168 SkRegion fBWRgn; | 164 SkRegion fBWRgn; |
| 169 SkAAClipBlitter fAABlitter; | 165 SkAAClipBlitter fAABlitter; |
| 170 // what we return | 166 // what we return |
| 171 const SkRegion* fClipRgn; | 167 const SkRegion* fClipRgn; |
| 172 SkBlitter* fBlitter; | 168 SkBlitter* fBlitter; |
| 173 }; | 169 }; |
| 174 | 170 |
| 175 #endif | 171 #endif |
| OLD | NEW |