Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: src/core/SkRasterClip.cpp

Issue 1461923004: Avoid devolving to a path when conservative clipping with RRects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simplify Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRasterClip.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // TODO: since we are going to over-write fAA completely (aren't we?) 154 // TODO: since we are going to over-write fAA completely (aren't we?)
155 // we should just clear our BW data (if any) and set fIsAA=true 155 // we should just clear our BW data (if any) and set fIsAA=true
156 if (this->isBW()) { 156 if (this->isBW()) {
157 this->convertToAA(); 157 this->convertToAA();
158 } 158 }
159 (void)fAA.setPath(path, &clip, doAA); 159 (void)fAA.setPath(path, &clip, doAA);
160 } 160 }
161 return this->updateCacheAndReturnNonEmpty(); 161 return this->updateCacheAndReturnNonEmpty();
162 } 162 }
163 163
164 bool SkRasterClip::op(const SkRRect& rrect, const SkISize& size, SkRegion::Op op , bool doAA) {
165 if (fForceConservativeRects) {
166 return this->op(rrect.getBounds(), size, op, doAA);
167 }
168
169 SkPath path;
170 path.addRRect(rrect);
171
172 return this->op(path, size, op, doAA);
173 }
174
164 bool SkRasterClip::op(const SkPath& path, const SkISize& size, SkRegion::Op op, bool doAA) { 175 bool SkRasterClip::op(const SkPath& path, const SkISize& size, SkRegion::Op op, bool doAA) {
165 // base is used to limit the size (and therefore memory allocation) of the 176 AUTO_RASTERCLIP_VALIDATE(*this);
166 // region that results from scan converting devPath.
167 SkRegion base;
168 177
169 if (fForceConservativeRects) { 178 if (fForceConservativeRects) {
170 SkIRect ir; 179 SkIRect ir;
171 switch (mutate_conservative_op(&op, path.isInverseFillType())) { 180 switch (mutate_conservative_op(&op, path.isInverseFillType())) {
172 case kDoNothing_MutateResult: 181 case kDoNothing_MutateResult:
173 return !this->isEmpty(); 182 return !this->isEmpty();
174 case kReplaceClippedAgainstGlobalBounds_MutateResult: 183 case kReplaceClippedAgainstGlobalBounds_MutateResult:
175 ir = SkIRect::MakeSize(size); 184 ir = SkIRect::MakeSize(size);
176 break; 185 break;
177 case kContinue_MutateResult: 186 case kContinue_MutateResult:
178 ir = path.getBounds().roundOut(); 187 ir = path.getBounds().roundOut();
179 break; 188 break;
180 } 189 }
181 return this->op(ir, op); 190 return this->op(ir, op);
182 } 191 }
183 192
193 // base is used to limit the size (and therefore memory allocation) of the
194 // region that results from scan converting devPath.
195 SkRegion base;
196
184 if (SkRegion::kIntersect_Op == op) { 197 if (SkRegion::kIntersect_Op == op) {
185 // since we are intersect, we can do better (tighter) with currRgn's 198 // since we are intersect, we can do better (tighter) with currRgn's
186 // bounds, than just using the device. However, if currRgn is complex, 199 // bounds, than just using the device. However, if currRgn is complex,
187 // our region blitter may hork, so we do that case in two steps. 200 // our region blitter may hork, so we do that case in two steps.
188 if (this->isRect()) { 201 if (this->isRect()) {
189 // FIXME: we should also be able to do this when this->isBW(), 202 // FIXME: we should also be able to do this when this->isBW(),
190 // but relaxing the test above triggers GM asserts in 203 // but relaxing the test above triggers GM asserts in
191 // SkRgnBuilder::blitH(). We need to investigate what's going on. 204 // SkRgnBuilder::blitH(). We need to investigate what's going on.
192 return this->setPath(path, this->bwRgn(), doAA); 205 return this->setPath(path, this->bwRgn(), doAA);
193 } else { 206 } else {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 fBlitter = blitter; 426 fBlitter = blitter;
414 } else { 427 } else {
415 const SkAAClip& aaclip = clip.aaRgn(); 428 const SkAAClip& aaclip = clip.aaRgn();
416 fBWRgn.setRect(aaclip.getBounds()); 429 fBWRgn.setRect(aaclip.getBounds());
417 fAABlitter.init(blitter, &aaclip); 430 fAABlitter.init(blitter, &aaclip);
418 // now our return values 431 // now our return values
419 fClipRgn = &fBWRgn; 432 fClipRgn = &fBWRgn;
420 fBlitter = &fAABlitter; 433 fBlitter = &fAABlitter;
421 } 434 }
422 } 435 }
OLDNEW
« no previous file with comments | « src/core/SkRasterClip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698