| 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 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 fIsBW = true; | 69 fIsBW = true; |
| 70 fAA.setEmpty(); | 70 fAA.setEmpty(); |
| 71 fIsRect = fBW.setRect(rect); | 71 fIsRect = fBW.setRect(rect); |
| 72 fIsEmpty = !fIsRect; | 72 fIsEmpty = !fIsRect; |
| 73 return fIsRect; | 73 return fIsRect; |
| 74 } | 74 } |
| 75 | 75 |
| 76 ////////////////////////////////////////////////////////////////////////////////
///// | 76 ////////////////////////////////////////////////////////////////////////////////
///// |
| 77 | 77 |
| 78 bool SkRasterClip::setConservativeRect(const SkRect& r, const SkIRect& clipR, bo
ol isInverse) { | 78 bool SkRasterClip::setConservativeRect(const SkRect& r, const SkIRect& clipR, bo
ol isInverse) { |
| 79 SkIRect ir; | |
| 80 r.roundOut(&ir); | |
| 81 | |
| 82 SkRegion::Op op; | 79 SkRegion::Op op; |
| 83 if (isInverse) { | 80 if (isInverse) { |
| 84 op = SkRegion::kDifference_Op; | 81 op = SkRegion::kDifference_Op; |
| 85 } else { | 82 } else { |
| 86 op = SkRegion::kIntersect_Op; | 83 op = SkRegion::kIntersect_Op; |
| 87 } | 84 } |
| 88 fBW.setRect(clipR); | 85 fBW.setRect(clipR); |
| 89 fBW.op(ir, op); | 86 fBW.op(r.roundOut(), op); |
| 90 return this->updateCacheAndReturnNonEmpty(); | 87 return this->updateCacheAndReturnNonEmpty(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 ////////////////////////////////////////////////////////////////////////////////
///// | 90 ////////////////////////////////////////////////////////////////////////////////
///// |
| 94 | 91 |
| 95 enum MutateResult { | 92 enum MutateResult { |
| 96 kDoNothing_MutateResult, | 93 kDoNothing_MutateResult, |
| 97 kReplaceClippedAgainstGlobalBounds_MutateResult, | 94 kReplaceClippedAgainstGlobalBounds_MutateResult, |
| 98 kContinue_MutateResult, | 95 kContinue_MutateResult, |
| 99 }; | 96 }; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 168 |
| 172 if (fForceConservativeRects) { | 169 if (fForceConservativeRects) { |
| 173 SkIRect ir; | 170 SkIRect ir; |
| 174 switch (mutate_conservative_op(&op, path.isInverseFillType())) { | 171 switch (mutate_conservative_op(&op, path.isInverseFillType())) { |
| 175 case kDoNothing_MutateResult: | 172 case kDoNothing_MutateResult: |
| 176 return !this->isEmpty(); | 173 return !this->isEmpty(); |
| 177 case kReplaceClippedAgainstGlobalBounds_MutateResult: | 174 case kReplaceClippedAgainstGlobalBounds_MutateResult: |
| 178 ir = SkIRect::MakeSize(size); | 175 ir = SkIRect::MakeSize(size); |
| 179 break; | 176 break; |
| 180 case kContinue_MutateResult: | 177 case kContinue_MutateResult: |
| 181 path.getBounds().roundOut(&ir); | 178 ir = path.getBounds().roundOut(); |
| 182 break; | 179 break; |
| 183 } | 180 } |
| 184 return this->op(ir, op); | 181 return this->op(ir, op); |
| 185 } | 182 } |
| 186 | 183 |
| 187 if (SkRegion::kIntersect_Op == op) { | 184 if (SkRegion::kIntersect_Op == op) { |
| 188 // since we are intersect, we can do better (tighter) with currRgn's | 185 // since we are intersect, we can do better (tighter) with currRgn's |
| 189 // bounds, than just using the device. However, if currRgn is complex, | 186 // bounds, than just using the device. However, if currRgn is complex, |
| 190 // our region blitter may hork, so we do that case in two steps. | 187 // our region blitter may hork, so we do that case in two steps. |
| 191 if (this->isRect()) { | 188 if (this->isRect()) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 277 |
| 281 if (fForceConservativeRects) { | 278 if (fForceConservativeRects) { |
| 282 SkIRect ir; | 279 SkIRect ir; |
| 283 switch (mutate_conservative_op(&op, false)) { | 280 switch (mutate_conservative_op(&op, false)) { |
| 284 case kDoNothing_MutateResult: | 281 case kDoNothing_MutateResult: |
| 285 return !this->isEmpty(); | 282 return !this->isEmpty(); |
| 286 case kReplaceClippedAgainstGlobalBounds_MutateResult: | 283 case kReplaceClippedAgainstGlobalBounds_MutateResult: |
| 287 ir = SkIRect::MakeSize(size); | 284 ir = SkIRect::MakeSize(size); |
| 288 break; | 285 break; |
| 289 case kContinue_MutateResult: | 286 case kContinue_MutateResult: |
| 290 r.roundOut(&ir); | 287 ir = r.roundOut(); |
| 291 break; | 288 break; |
| 292 } | 289 } |
| 293 return this->op(ir, op); | 290 return this->op(ir, op); |
| 294 } | 291 } |
| 295 | 292 |
| 296 if (fIsBW && doAA) { | 293 if (fIsBW && doAA) { |
| 297 // check that the rect really needs aa, or is it close enought to | 294 // check that the rect really needs aa, or is it close enought to |
| 298 // integer boundaries that we can just treat it as a BW rect? | 295 // integer boundaries that we can just treat it as a BW rect? |
| 299 if (nearly_integral(r.fLeft) && nearly_integral(r.fTop) && | 296 if (nearly_integral(r.fLeft) && nearly_integral(r.fTop) && |
| 300 nearly_integral(r.fRight) && nearly_integral(r.fBottom)) { | 297 nearly_integral(r.fRight) && nearly_integral(r.fBottom)) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 fBlitter = blitter; | 413 fBlitter = blitter; |
| 417 } else { | 414 } else { |
| 418 const SkAAClip& aaclip = clip.aaRgn(); | 415 const SkAAClip& aaclip = clip.aaRgn(); |
| 419 fBWRgn.setRect(aaclip.getBounds()); | 416 fBWRgn.setRect(aaclip.getBounds()); |
| 420 fAABlitter.init(blitter, &aaclip); | 417 fAABlitter.init(blitter, &aaclip); |
| 421 // now our return values | 418 // now our return values |
| 422 fClipRgn = &fBWRgn; | 419 fClipRgn = &fBWRgn; |
| 423 fBlitter = &fAABlitter; | 420 fBlitter = &fAABlitter; |
| 424 } | 421 } |
| 425 } | 422 } |
| OLD | NEW |