| 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 #include "SkRasterClip.h" | 8 #include "SkRasterClip.h" |
| 9 #include "SkPath.h" | 9 #include "SkPath.h" |
| 10 | 10 |
| 11 SkRasterClip::SkRasterClip(const SkRasterClip& src) { | 11 SkRasterClip::SkRasterClip(const SkRasterClip& src) { |
| 12 AUTO_RASTERCLIP_VALIDATE(src); | 12 AUTO_RASTERCLIP_VALIDATE(src); |
| 13 | 13 |
| 14 fForceConservativeRects = src.fForceConservativeRects; | 14 fForceConservativeRects = src.fForceConservativeRects; |
| 15 fIsBW = src.fIsBW; | 15 fIsBW = src.fIsBW; |
| 16 if (fIsBW) { | 16 if (fIsBW) { |
| 17 fBW = src.fBW; | 17 fBW = src.fBW; |
| 18 } else { | 18 } else { |
| 19 fAA = src.fAA; | 19 fAA = src.fAA; |
| 20 } | 20 } |
| 21 | 21 |
| 22 fIsEmpty = src.isEmpty(); | 22 fIsEmpty = src.isEmpty(); |
| 23 fIsRect = src.isRect(); | 23 fIsRect = src.isRect(); |
| 24 SkDEBUGCODE(this->validate();) | 24 SkDEBUGCODE(this->validate();) |
| 25 } | 25 } |
| 26 | 26 |
| 27 SkRasterClip::SkRasterClip(const SkRegion& rgn) : fBW(rgn) { |
| 28 fForceConservativeRects = false; |
| 29 fIsBW = true; |
| 30 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute |
| 31 fIsRect = !fIsEmpty; |
| 32 SkDEBUGCODE(this->validate();) |
| 33 } |
| 34 |
| 27 SkRasterClip::SkRasterClip(const SkIRect& bounds, bool forceConservativeRects) :
fBW(bounds) { | 35 SkRasterClip::SkRasterClip(const SkIRect& bounds, bool forceConservativeRects) :
fBW(bounds) { |
| 28 fForceConservativeRects = forceConservativeRects; | 36 fForceConservativeRects = forceConservativeRects; |
| 29 fIsBW = true; | 37 fIsBW = true; |
| 30 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute | 38 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute |
| 31 fIsRect = !fIsEmpty; | 39 fIsRect = !fIsEmpty; |
| 32 SkDEBUGCODE(this->validate();) | 40 SkDEBUGCODE(this->validate();) |
| 33 } | 41 } |
| 34 | 42 |
| 35 SkRasterClip::SkRasterClip(bool forceConservativeRects) { | 43 SkRasterClip::SkRasterClip(bool forceConservativeRects) { |
| 36 fForceConservativeRects = forceConservativeRects; | 44 fForceConservativeRects = forceConservativeRects; |
| 37 fIsBW = true; | 45 fIsBW = true; |
| 38 fIsEmpty = true; | 46 fIsEmpty = true; |
| 39 fIsRect = false; | 47 fIsRect = false; |
| 40 SkDEBUGCODE(this->validate();) | 48 SkDEBUGCODE(this->validate();) |
| 41 } | 49 } |
| 42 | 50 |
| 43 SkRasterClip::~SkRasterClip() { | 51 SkRasterClip::~SkRasterClip() { |
| 44 SkDEBUGCODE(this->validate();) | 52 SkDEBUGCODE(this->validate();) |
| 45 } | 53 } |
| 46 | 54 |
| 55 bool SkRasterClip::operator==(const SkRasterClip& other) const { |
| 56 // This impl doesn't care if fForceConservativeRects is the same in both, on
ly the current state |
| 57 |
| 58 if (fIsBW != other.fIsBW) { |
| 59 return false; |
| 60 } |
| 61 bool isEqual = fIsBW ? fBW == other.fBW : fAA == other.fAA; |
| 62 #ifdef SK_DEBUG |
| 63 if (isEqual) { |
| 64 SkASSERT(fIsEmpty == other.fIsEmpty); |
| 65 SkASSERT(fIsRect == other.fIsRect); |
| 66 } |
| 67 #endif |
| 68 return isEqual; |
| 69 } |
| 70 |
| 47 bool SkRasterClip::isComplex() const { | 71 bool SkRasterClip::isComplex() const { |
| 48 return fIsBW ? fBW.isComplex() : !fAA.isEmpty(); | 72 return fIsBW ? fBW.isComplex() : !fAA.isEmpty(); |
| 49 } | 73 } |
| 50 | 74 |
| 51 const SkIRect& SkRasterClip::getBounds() const { | 75 const SkIRect& SkRasterClip::getBounds() const { |
| 52 return fIsBW ? fBW.getBounds() : fAA.getBounds(); | 76 return fIsBW ? fBW.getBounds() : fAA.getBounds(); |
| 53 } | 77 } |
| 54 | 78 |
| 55 bool SkRasterClip::setEmpty() { | 79 bool SkRasterClip::setEmpty() { |
| 56 AUTO_RASTERCLIP_VALIDATE(*this); | 80 AUTO_RASTERCLIP_VALIDATE(*this); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 fBlitter = blitter; | 450 fBlitter = blitter; |
| 427 } else { | 451 } else { |
| 428 const SkAAClip& aaclip = clip.aaRgn(); | 452 const SkAAClip& aaclip = clip.aaRgn(); |
| 429 fBWRgn.setRect(aaclip.getBounds()); | 453 fBWRgn.setRect(aaclip.getBounds()); |
| 430 fAABlitter.init(blitter, &aaclip); | 454 fAABlitter.init(blitter, &aaclip); |
| 431 // now our return values | 455 // now our return values |
| 432 fClipRgn = &fBWRgn; | 456 fClipRgn = &fBWRgn; |
| 433 fBlitter = &fAABlitter; | 457 fBlitter = &fAABlitter; |
| 434 } | 458 } |
| 435 } | 459 } |
| OLD | NEW |