From: robertphillips Date: Wed, 7 Jan 2015 17:12:43 +0000 (-0800) Subject: Revert of It is dangerous to ignore SkRect::intersect's return value (patchset #6... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~4159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=690fc594f11a987ba0e885a7eb01aff363395f12;p=platform%2Fupstream%2FlibSkiaSharp.git Revert of It is dangerous to ignore SkRect::intersect's return value (patchset #6 id:100001 of https://codereview.chromium.org/833943002/) Reason for revert: Still more Chromium clean up to do Original issue's description: > It is dangerous to ignore SkRect::intersect's return value > > Committed: https://skia.googlesource.com/skia/+/152f524fd325b7776b01f84afbfe2fa071648a05 TBR=reed@google.com NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/825983005 --- diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 1652e61..ece8ff3 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -704,10 +704,8 @@ public: SkRect content = SkRect::MakeWH(SkIntToScalar(pageSize.width()), SkIntToScalar(pageSize.height())); initialTransform.mapRect(&content); - if (!content.intersect(0, 0, SkIntToScalar(pageSize.width()), - SkIntToScalar(pageSize.height()))) { - content.setEmpty(); - } + content.intersect(0, 0, SkIntToScalar(pageSize.width()), + SkIntToScalar(pageSize.height())); SkISize contentSize = SkISize::Make(SkScalarRoundToInt(content.width()), SkScalarRoundToInt(content.height())); diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp index 3dafed8..7fcbe0a 100644 --- a/gm/offsetimagefilter.cpp +++ b/gm/offsetimagefilter.cpp @@ -82,9 +82,8 @@ protected: scaleMatrix.setScale(scale, scale); SkRect cropRectFloat; scaleMatrix.mapRect(&cropRectFloat, SkRect::Make(cropRect)); - if (clipRect.intersect(cropRectFloat)) { - canvas->drawRect(clipRect, strokePaint); - } + clipRect.intersect(cropRectFloat); + canvas->drawRect(clipRect, strokePaint); } virtual void onDraw(SkCanvas* canvas) { diff --git a/include/core/SkRect.h b/include/core/SkRect.h index 06f8abe..cafc59a 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -267,7 +267,7 @@ struct SK_API SkIRect { intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& r) { + bool intersect(const SkIRect& r) { SkASSERT(&r); return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom); } @@ -276,7 +276,7 @@ struct SK_API SkIRect { that intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& a, const SkIRect& b) { + bool intersect(const SkIRect& a, const SkIRect& b) { if (!a.isEmpty() && !b.isEmpty() && a.fLeft < b.fRight && b.fLeft < a.fRight && @@ -296,7 +296,7 @@ struct SK_API SkIRect { If either is, then the return result is undefined. In the debug build, we assert that both rectangles are non-empty. */ - bool SK_WARN_UNUSED_RESULT intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) { + bool intersectNoEmptyCheck(const SkIRect& a, const SkIRect& b) { SkASSERT(!a.isEmpty() && !b.isEmpty()); if (a.fLeft < b.fRight && b.fLeft < a.fRight && @@ -315,8 +315,7 @@ struct SK_API SkIRect { otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(int32_t left, int32_t top, - int32_t right, int32_t bottom) { + bool intersect(int32_t left, int32_t top, int32_t right, int32_t bottom) { if (left < right && top < bottom && !this->isEmpty() && fLeft < right && left < fRight && fTop < bottom && top < fBottom) { if (fLeft < left) fLeft = left; @@ -332,8 +331,8 @@ struct SK_API SkIRect { */ static bool Intersects(const SkIRect& a, const SkIRect& b) { return !a.isEmpty() && !b.isEmpty() && // check for empties - a.fLeft < b.fRight && b.fLeft < a.fRight && - a.fTop < b.fBottom && b.fTop < a.fBottom; + a.fLeft < b.fRight && b.fLeft < a.fRight && + a.fTop < b.fBottom && b.fTop < a.fBottom; } /** @@ -657,22 +656,21 @@ struct SK_API SkRect { intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkRect& r); + bool intersect(const SkRect& r); /** If this rectangle intersects the rectangle specified by left, top, right, bottom, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(SkScalar left, SkScalar top, - SkScalar right, SkScalar bottom); + bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom); /** * If rectangles a and b intersect, return true and set this rectangle to * that intersection, otherwise return false and do not change this * rectangle. If either rectangle is empty, do nothing and return false. */ - bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b); + bool intersect(const SkRect& a, const SkRect& b); private: diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index 545a701..158f34d 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -454,10 +454,7 @@ MaskSuperBlitter::MaskSuperBlitter(SkBlitter* realBlitter, const SkIRect& ir, co fMask.fFormat = SkMask::kA8_Format; fClipRect = ir; - if (!fClipRect.intersect(clip.getBounds())) { - SkASSERT(0); - fClipRect.setEmpty(); - } + fClipRect.intersect(clip.getBounds()); // For valgrind, write 1 extra byte at the end so we don't read // uninitialized memory. See comment in add_aa_span and fStorage[]. diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 97ae436..aa57669 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -1184,9 +1184,7 @@ bool SkBlurMaskFilterImpl::canFilterMaskGPU(const SkRect& srcBounds, // Outset srcRect and clipRect by 3 * sigma, to compute affected blur area. srcRect.outset(sigma3, sigma3); clipRect.outset(sigma3, sigma3); - if (!srcRect.intersect(clipRect)) { - srcRect.setEmpty(); - } + srcRect.intersect(clipRect); *maskRect = srcRect; return true; } diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp index ca97098..3040b46 100644 --- a/src/gpu/GrReducedClip.cpp +++ b/src/gpu/GrReducedClip.cpp @@ -409,10 +409,7 @@ void GrReducedClip::ReduceClipStack(const SkClipStack& stack, if (tighterBounds) { SkIRect stackIBounds; stackBounds.roundOut(&stackIBounds); - if (!tighterBounds->intersect(queryBounds, stackIBounds)) { - SkASSERT(0); - tighterBounds->setEmpty(); - } + tighterBounds->intersect(queryBounds, stackIBounds); bounds = tighterBounds; } } else { diff --git a/src/utils/SkGatherPixelRefsAndRects.h b/src/utils/SkGatherPixelRefsAndRects.h index 9589c3e..6e11fbe 100644 --- a/src/utils/SkGatherPixelRefsAndRects.h +++ b/src/utils/SkGatherPixelRefsAndRects.h @@ -79,9 +79,8 @@ protected: SkRect mappedRect; draw.fMatrix->mapRect(&mappedRect, rect); SkRect clipRect = SkRect::Make(draw.fRC->getBounds()); - if (mappedRect.intersect(clipRect)) { - fPRCont->add(bm.pixelRef(), mappedRect); - } + mappedRect.intersect(clipRect); + fPRCont->add(bm.pixelRef(), mappedRect); } } virtual void drawOval(const SkDraw& draw, const SkRect& rect,