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