diff options
author | 2014-11-19 05:03:18 -0800 | |
---|---|---|
committer | 2014-11-19 05:03:18 -0800 | |
commit | b07a94f1cba3976596ae1a7f23d8c2043ba353f3 (patch) | |
tree | 9c2d202dc47a62742f950cb9702abc5e4327cf34 /src | |
parent | b50612cbda6c289ac6d859810c37a2a03f0ae26a (diff) |
add roundOut that returns its result
BUG=skia:
Review URL: https://codereview.chromium.org/742663002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 3 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 4 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 10 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 6 | ||||
-rw-r--r-- | src/core/SkMaskFilter.cpp | 2 | ||||
-rw-r--r-- | src/core/SkRasterClip.cpp | 9 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 3 | ||||
-rw-r--r-- | src/core/SkScan_Antihair.cpp | 3 | ||||
-rw-r--r-- | src/core/SkScan_Hairline.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkBitmapSource.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkGpuBlurUtils.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkMatrixImageFilter.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkPictureImageFilter.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkTileImageFilter.cpp | 3 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.cpp | 3 |
16 files changed, 23 insertions, 45 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 5204fdb53e..9df7c9b655 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -260,8 +260,7 @@ void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, // since we may need to clamp to the borders of the src rect within // the bitmap, we extract a subset. - SkIRect srcIR; - tmpSrc.roundOut(&srcIR); + const SkIRect srcIR = tmpSrc.roundOut(); if(bitmap.pixelRef()->getTexture()) { // Accelerated source canvas, don't use extractSubset but readPixels to get the subset. // This way, the pixels are copied in CPU memory instead of GPU memory. diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 8d17be7bfe..4fda7a37b3 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1586,9 +1586,7 @@ bool SkCanvas::quickReject(const SkRect& rect) const { if (fMCRec->fMatrix.hasPerspective()) { SkRect dst; fMCRec->fMatrix.mapRect(&dst, rect); - SkIRect idst; - dst.roundOut(&idst); - return !SkIRect::Intersects(idst, fMCRec->fRasterClip.getBounds()); + return !SkIRect::Intersects(dst.roundOut(), fMCRec->fRasterClip.getBounds()); } else { const SkRect& clipR = this->getLocalClipBounds(); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 95d348efc5..7ccd258ba8 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -813,8 +813,7 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const { devRect.sort(); // look for the quick exit, before we build a blitter - SkIRect ir; - devRect.roundOut(&ir); + SkIRect ir = devRect.roundOut(); if (paint.getStyle() != SkPaint::kFill_Style) { // extra space for hairlines if (paint.getStrokeWidth() == 0) { @@ -1210,11 +1209,8 @@ void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, static bool clipped_out(const SkMatrix& m, const SkRasterClip& c, const SkRect& srcR) { SkRect dstR; - SkIRect devIR; - m.mapRect(&dstR, srcR); - dstR.roundOut(&devIR); - return c.quickReject(devIR); + return c.quickReject(dstR.roundOut()); } static bool clipped_out(const SkMatrix& matrix, const SkRasterClip& clip, @@ -2282,7 +2278,7 @@ void SkDraw::validate() const { #include "SkBlitter.h" static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds, - const SkMaskFilter* filter, const SkMatrix* filterMatrix, + const SkMaskFilter* filter, const SkMatrix* filterMatrix, SkIRect* bounds) { if (devPath.isEmpty()) { return false; diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 8f49a06c15..79f04b88ec 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -290,8 +290,7 @@ bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, srcBounds.offset(srcOffset); SkRect cropRect; ctx.ctm().mapRect(&cropRect, fCropRect.rect()); - SkIRect cropRectI; - cropRect.roundOut(&cropRectI); + const SkIRect cropRectI = cropRect.roundOut(); uint32_t flags = fCropRect.flags(); if (flags & CropRect::kHasLeft_CropEdge) srcBounds.fLeft = cropRectI.fLeft; if (flags & CropRect::kHasTop_CropEdge) srcBounds.fTop = cropRectI.fTop; @@ -311,8 +310,7 @@ bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitm srcBounds.offset(*srcOffset); SkRect cropRect; ctx.ctm().mapRect(&cropRect, fCropRect.rect()); - SkIRect cropRectI; - cropRect.roundOut(&cropRectI); + const SkIRect cropRectI = cropRect.roundOut(); uint32_t flags = fCropRect.flags(); *bounds = srcBounds; if (flags & CropRect::kHasLeft_CropEdge) bounds->fLeft = cropRectI.fLeft; diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index 86f303c561..28c9a381d3 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -337,7 +337,7 @@ void SkMaskFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { SkMask srcM, dstM; srcM.fImage = NULL; - src.roundOut(&srcM.fBounds); + srcM.fBounds = src.roundOut(); srcM.fRowBytes = 0; srcM.fFormat = SkMask::kA8_Format; diff --git a/src/core/SkRasterClip.cpp b/src/core/SkRasterClip.cpp index f820c5a0a4..35197c1ad9 100644 --- a/src/core/SkRasterClip.cpp +++ b/src/core/SkRasterClip.cpp @@ -76,9 +76,6 @@ bool SkRasterClip::setRect(const SkIRect& rect) { ///////////////////////////////////////////////////////////////////////////////////// bool SkRasterClip::setConservativeRect(const SkRect& r, const SkIRect& clipR, bool isInverse) { - SkIRect ir; - r.roundOut(&ir); - SkRegion::Op op; if (isInverse) { op = SkRegion::kDifference_Op; @@ -86,7 +83,7 @@ bool SkRasterClip::setConservativeRect(const SkRect& r, const SkIRect& clipR, bo op = SkRegion::kIntersect_Op; } fBW.setRect(clipR); - fBW.op(ir, op); + fBW.op(r.roundOut(), op); return this->updateCacheAndReturnNonEmpty(); } @@ -178,7 +175,7 @@ bool SkRasterClip::op(const SkPath& path, const SkISize& size, SkRegion::Op op, ir = SkIRect::MakeSize(size); break; case kContinue_MutateResult: - path.getBounds().roundOut(&ir); + ir = path.getBounds().roundOut(); break; } return this->op(ir, op); @@ -287,7 +284,7 @@ bool SkRasterClip::op(const SkRect& r, const SkISize& size, SkRegion::Op op, boo ir = SkIRect::MakeSize(size); break; case kContinue_MutateResult: - r.roundOut(&ir); + ir = r.roundOut(); break; } return this->op(ir, op); diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 8cb416e9ae..20413a7dd7 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -167,8 +167,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) { } } else { // just use devPath - SkIRect ir; - devPath.getBounds().roundOut(&ir); + const SkIRect ir = devPath.getBounds().roundOut(); if (ir.isEmpty() || !ir.is16Bit()) { goto SK_ERROR; diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp index 1ad68e5075..67c8917f0a 100644 --- a/src/core/SkScan_Antihair.cpp +++ b/src/core/SkScan_Antihair.cpp @@ -854,8 +854,7 @@ void SkScan::AntiFillRect(const SkRect& origR, const SkRegion* clip, return; } - SkIRect outerBounds; - newR.roundOut(&outerBounds); + const SkIRect outerBounds = newR.roundOut(); if (clip->isRect()) { antifillrect(newR, blitter); diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp index 1e7e762b5a..7ca54eac33 100644 --- a/src/core/SkScan_Hairline.cpp +++ b/src/core/SkScan_Hairline.cpp @@ -377,14 +377,12 @@ void SkScan::HairLine(const SkPoint& p0, const SkPoint& p1, } else { const SkRegion* clipRgn = NULL; SkRect r; - SkIRect ir; r.set(p0.fX, p0.fY, p1.fX, p1.fY); r.sort(); r.inset(-SK_ScalarHalf, -SK_ScalarHalf); - r.roundOut(&ir); SkAAClipBlitterWrapper wrap; - if (!clip.quickContains(ir)) { + if (!clip.quickContains(r.roundOut())) { wrap.init(clip, blitter); blitter = wrap.getBlitter(); clipRgn = &wrap.getRgn(); diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp index 0d9315b2ab..1d8078d59f 100644 --- a/src/effects/SkBitmapSource.cpp +++ b/src/effects/SkBitmapSource.cpp @@ -67,9 +67,8 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& offset->fX = offset->fY = 0; return true; } - SkIRect dstIRect; - dstRect.roundOut(&dstIRect); + const SkIRect dstIRect = dstRect.roundOut(); SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstIRect.width(), dstIRect.height())); if (NULL == device.get()) { return false; diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 1612e3db96..4601ebb787 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -187,7 +187,7 @@ bool SkBlurMaskFilterImpl::filterRRectMask(SkMask* dst, const SkRRect& r, static bool prepare_to_draw_into_mask(const SkRect& bounds, SkMask* mask) { SkASSERT(mask != NULL); - bounds.roundOut(&mask->fBounds); + mask->fBounds = bounds.roundOut(); mask->fRowBytes = SkAlign4(mask->fBounds.width()); mask->fFormat = SkMask::kA8_Format; const size_t size = mask->computeImageSize(); @@ -360,7 +360,7 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma SkIPoint margin; SkMask srcM, dstM; - rrect.rect().roundOut(&srcM.fBounds); + srcM.fBounds = rrect.rect().roundOut(); srcM.fImage = NULL; srcM.fFormat = SkMask::kA8_Format; srcM.fRowBytes = 0; @@ -476,7 +476,7 @@ SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, SkIPoint margin; SkMask srcM, dstM; - rects[0].roundOut(&srcM.fBounds); + srcM.fBounds = rects[0].roundOut(); srcM.fImage = NULL; srcM.fFormat = SkMask::kA8_Format; srcM.fRowBytes = 0; diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp index 975b7047ce..23128e0cca 100644 --- a/src/effects/SkGpuBlurUtils.cpp +++ b/src/effects/SkGpuBlurUtils.cpp @@ -226,8 +226,7 @@ GrTexture* GaussianBlur(GrContext* context, SkTSwap(dstTexture, tempTexture); } - SkIRect srcIRect; - srcRect.roundOut(&srcIRect); + const SkIRect srcIRect = srcRect.roundOut(); // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is faster to just // launch a single non separable kernel vs two launches diff --git a/src/effects/SkMatrixImageFilter.cpp b/src/effects/SkMatrixImageFilter.cpp index 34231ba98b..8b07dd4a46 100644 --- a/src/effects/SkMatrixImageFilter.cpp +++ b/src/effects/SkMatrixImageFilter.cpp @@ -127,8 +127,7 @@ bool SkMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm matrix.postConcat(ctm); SkRect floatBounds; matrix.mapRect(&floatBounds, SkRect::Make(src)); - SkIRect bounds; - floatBounds.roundOut(&bounds); + SkIRect bounds = floatBounds.roundOut(); if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { return false; } diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index 30fbac184a..0c95b328c0 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -81,9 +81,8 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co } SkRect floatBounds; - SkIRect bounds; ctx.ctm().mapRect(&floatBounds, fCropRect); - floatBounds.roundOut(&bounds); + SkIRect bounds = floatBounds.roundOut(); if (!bounds.intersect(ctx.clipBounds())) { return false; } diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index bebf8f01a2..04c62d0574 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -36,8 +36,7 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, SkRect dstRect; ctx.ctm().mapRect(&dstRect, fDstRect); - SkIRect dstIRect; - dstRect.roundOut(&dstIRect); + const SkIRect dstIRect = dstRect.roundOut(); int w = dstIRect.width(); int h = dstIRect.height(); if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) { diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index b07b383781..95256e7d13 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -42,8 +42,7 @@ SkDebugCanvas::SkDebugCanvas(int windowWidth, int windowHeight) largeIRect.inset(1024, 1024); SkRect large = SkRect::Make(largeIRect); #ifdef SK_DEBUG - large.roundOut(&largeIRect); - SkASSERT(!largeIRect.isEmpty()); + SkASSERT(!large.roundOut().isEmpty()); #endif // call the base class' version to avoid adding a draw command this->INHERITED::onClipRect(large, SkRegion::kReplace_Op, kHard_ClipEdgeStyle); |