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 | 9 |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // TODO: since we are going to over-write fAA completely (aren't we?) | 79 // TODO: since we are going to over-write fAA completely (aren't we?) |
80 // we should just clear our BW data (if any) and set fIsAA=true | 80 // we should just clear our BW data (if any) and set fIsAA=true |
81 if (this->isBW()) { | 81 if (this->isBW()) { |
82 this->convertToAA(); | 82 this->convertToAA(); |
83 } | 83 } |
84 (void)fAA.setPath(path, &clip, doAA); | 84 (void)fAA.setPath(path, &clip, doAA); |
85 } | 85 } |
86 return this->updateCacheAndReturnNonEmpty(); | 86 return this->updateCacheAndReturnNonEmpty(); |
87 } | 87 } |
88 | 88 |
| 89 bool SkRasterClip::op(const SkPath& path, const SkISize& size, SkRegion::Op op,
bool doAA) { |
| 90 // base is used to limit the size (and therefore memory allocation) of the |
| 91 // region that results from scan converting devPath. |
| 92 SkRegion base; |
| 93 |
| 94 if (SkRegion::kIntersect_Op == op) { |
| 95 // since we are intersect, we can do better (tighter) with currRgn's |
| 96 // bounds, than just using the device. However, if currRgn is complex, |
| 97 // our region blitter may hork, so we do that case in two steps. |
| 98 if (this->isRect()) { |
| 99 // FIXME: we should also be able to do this when this->isBW(), |
| 100 // but relaxing the test above triggers GM asserts in |
| 101 // SkRgnBuilder::blitH(). We need to investigate what's going on. |
| 102 return this->setPath(path, this->bwRgn(), doAA); |
| 103 } else { |
| 104 base.setRect(this->getBounds()); |
| 105 SkRasterClip clip; |
| 106 clip.setPath(path, base, doAA); |
| 107 return this->op(clip, op); |
| 108 } |
| 109 } else { |
| 110 base.setRect(0, 0, size.width(), size.height()); |
| 111 |
| 112 if (SkRegion::kReplace_Op == op) { |
| 113 return this->setPath(path, base, doAA); |
| 114 } else { |
| 115 SkRasterClip clip; |
| 116 clip.setPath(path, base, doAA); |
| 117 return this->op(clip, op); |
| 118 } |
| 119 } |
| 120 } |
| 121 |
89 bool SkRasterClip::setPath(const SkPath& path, const SkIRect& clip, bool doAA) { | 122 bool SkRasterClip::setPath(const SkPath& path, const SkIRect& clip, bool doAA) { |
90 SkRegion tmp; | 123 SkRegion tmp; |
91 tmp.setRect(clip); | 124 tmp.setRect(clip); |
92 return this->setPath(path, tmp, doAA); | 125 return this->setPath(path, tmp, doAA); |
93 } | 126 } |
94 | 127 |
95 bool SkRasterClip::op(const SkIRect& rect, SkRegion::Op op) { | 128 bool SkRasterClip::op(const SkIRect& rect, SkRegion::Op op) { |
96 AUTO_RASTERCLIP_VALIDATE(*this); | 129 AUTO_RASTERCLIP_VALIDATE(*this); |
97 | 130 |
98 fIsBW ? fBW.op(rect, op) : fAA.op(rect, op); | 131 fIsBW ? fBW.op(rect, op) : fAA.op(rect, op); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 fBlitter = blitter; | 306 fBlitter = blitter; |
274 } else { | 307 } else { |
275 const SkAAClip& aaclip = clip.aaRgn(); | 308 const SkAAClip& aaclip = clip.aaRgn(); |
276 fBWRgn.setRect(aaclip.getBounds()); | 309 fBWRgn.setRect(aaclip.getBounds()); |
277 fAABlitter.init(blitter, &aaclip); | 310 fAABlitter.init(blitter, &aaclip); |
278 // now our return values | 311 // now our return values |
279 fClipRgn = &fBWRgn; | 312 fClipRgn = &fBWRgn; |
280 fBlitter = &fAABlitter; | 313 fBlitter = &fAABlitter; |
281 } | 314 } |
282 } | 315 } |
OLD | NEW |