diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDraw.cpp | 12 | ||||
-rw-r--r-- | src/core/SkRRect.cpp | 3 | ||||
-rw-r--r-- | src/core/SkRasterizer.cpp | 3 | ||||
-rw-r--r-- | src/core/SkScan_Antihair.cpp | 2 | ||||
-rw-r--r-- | src/core/SkScan_Hairline.cpp | 11 | ||||
-rw-r--r-- | src/effects/SkPerlinNoiseShader.cpp | 18 | ||||
-rw-r--r-- | src/fonts/SkTestScalerContext.cpp | 10 |
7 files changed, 21 insertions, 38 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index bd4e40e9f1..ef268bfed3 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -2181,11 +2181,7 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds, } // init our bounds from the path - { - SkRect pathBounds = devPath.getBounds(); - pathBounds.inset(-SK_ScalarHalf, -SK_ScalarHalf); - pathBounds.roundOut(bounds); - } + *bounds = devPath.getBounds().makeOutset(SK_ScalarHalf, SK_ScalarHalf).roundOut(); SkIPoint margin = SkIPoint::Make(0, 0); if (filter) { @@ -2204,7 +2200,6 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds, // (possibly) trim the bounds to reflect the clip // (plus whatever slop the filter needs) if (clipBounds) { - SkIRect tmp = *clipBounds; // Ugh. Guard against gigantic margins from wacky filters. Without this // check we can request arbitrary amounts of slop beyond our visible // clip, and bring down the renderer (at least on finite RAM machines @@ -2212,9 +2207,8 @@ static bool compute_bounds(const SkPath& devPath, const SkIRect* clipBounds, // quality of large filters like blurs, and the corresponding memory // requests. static const int MAX_MARGIN = 128; - tmp.inset(-SkMin32(margin.fX, MAX_MARGIN), - -SkMin32(margin.fY, MAX_MARGIN)); - if (!bounds->intersect(tmp)) { + if (!bounds->intersect(clipBounds->makeOutset(SkMin32(margin.fX, MAX_MARGIN), + SkMin32(margin.fY, MAX_MARGIN)))) { return false; } } diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp index f2927644da..d8b4a20d88 100644 --- a/src/core/SkRRect.cpp +++ b/src/core/SkRRect.cpp @@ -453,9 +453,8 @@ bool SkRRect::transform(const SkMatrix& matrix, SkRRect* dst) const { /////////////////////////////////////////////////////////////////////////////// void SkRRect::inset(SkScalar dx, SkScalar dy, SkRRect* dst) const { - SkRect r = fRect; + const SkRect r = fRect.makeInset(dx, dy); - r.inset(dx, dy); if (r.isEmpty()) { dst->setEmpty(); return; diff --git a/src/core/SkRasterizer.cpp b/src/core/SkRasterizer.cpp index 3a7af95555..ab9e011761 100644 --- a/src/core/SkRasterizer.cpp +++ b/src/core/SkRasterizer.cpp @@ -27,8 +27,7 @@ bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix, if (!filter->filterMask(&dstM, srcM, matrix, &margin)) { return false; } - storage = *clipBounds; - storage.inset(-margin.fX, -margin.fY); + storage = clipBounds->makeOutset(margin.fX, margin.fY); clipBounds = &storage; } diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp index d0341510a9..a3305e2dc8 100644 --- a/src/core/SkScan_Antihair.cpp +++ b/src/core/SkScan_Antihair.cpp @@ -625,7 +625,7 @@ void SkScan::AntiHairLineRgn(const SkPoint& pt0, const SkPoint& pt1, since the 1/2 pixel boundary is important to the antihair blitter, we don't want to risk numerical fate by chopping on that edge. */ - clipBounds.inset(-SK_Scalar1, -SK_Scalar1); + clipBounds.outset(SK_Scalar1, SK_Scalar1); if (!SkLineClipper::IntersectLine(pts, clipBounds, pts)) { return; diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp index 7ca54eac33..bd597b3d68 100644 --- a/src/core/SkScan_Hairline.cpp +++ b/src/core/SkScan_Hairline.cpp @@ -267,9 +267,7 @@ static void hair_path(const SkPath& path, const SkRasterClip& rclip, const SkRegion* clip = NULL; { - SkIRect ibounds; - path.getBounds().roundOut(&ibounds); - ibounds.inset(-1, -1); + const SkIRect ibounds = path.getBounds().roundOut().makeOutset(1, 1); if (rclip.quickReject(ibounds)) { return; @@ -379,7 +377,7 @@ void SkScan::HairLine(const SkPoint& p0, const SkPoint& p1, SkRect r; r.set(p0.fX, p0.fY, p1.fX, p1.fY); r.sort(); - r.inset(-SK_ScalarHalf, -SK_ScalarHalf); + r.outset(SK_ScalarHalf, SK_ScalarHalf); SkAAClipBlitterWrapper wrap; if (!clip.quickContains(r.roundOut())) { @@ -398,14 +396,11 @@ void SkScan::AntiHairLine(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.roundOut(&ir); - ir.inset(-1, -1); SkAAClipBlitterWrapper wrap; - if (!clip.quickContains(ir)) { + if (!clip.quickContains(r.roundOut().makeOutset(1, 1))) { wrap.init(clip, blitter); blitter = wrap.getBlitter(); clipRgn = &wrap.getRgn(); diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 3c1bf2fd03..fa46cbd44a 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -78,16 +78,14 @@ struct SkPerlinNoiseShader::PaintingData { SkScalar baseFrequencyX, SkScalar baseFrequencyY, const SkMatrix& matrix) { - SkVector wavelength = SkVector::Make(SkScalarInvert(baseFrequencyX), - SkScalarInvert(baseFrequencyY)); - matrix.mapVectors(&wavelength, 1); - fBaseFrequency.fX = SkScalarInvert(wavelength.fX); - fBaseFrequency.fY = SkScalarInvert(wavelength.fY); - SkVector sizeVec = SkVector::Make(SkIntToScalar(tileSize.fWidth), - SkIntToScalar(tileSize.fHeight)); - matrix.mapVectors(&sizeVec, 1); - fTileSize.fWidth = SkScalarRoundToInt(sizeVec.fX); - fTileSize.fHeight = SkScalarRoundToInt(sizeVec.fY); + SkVector vec[2] = { + { SkScalarInvert(baseFrequencyX), SkScalarInvert(baseFrequencyY) }, + { SkIntToScalar(tileSize.fWidth), SkIntToScalar(tileSize.fHeight) }, + }; + matrix.mapVectors(vec, 2); + + fBaseFrequency.set(SkScalarInvert(vec[0].fX), SkScalarInvert(vec[0].fY)); + fTileSize.set(SkScalarRoundToInt(vec[1].fX), SkScalarRoundToInt(vec[1].fY)); this->init(seed); if (!fTileSize.isEmpty()) { this->stitch(); diff --git a/src/fonts/SkTestScalerContext.cpp b/src/fonts/SkTestScalerContext.cpp index fc1f9456e2..769f4ea66f 100644 --- a/src/fonts/SkTestScalerContext.cpp +++ b/src/fonts/SkTestScalerContext.cpp @@ -214,9 +214,8 @@ protected: void generateAdvance(SkGlyph* glyph) SK_OVERRIDE { fFace->getAdvance(glyph); - SkVector advance; - fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), - SkFixedToScalar(glyph->fAdvanceY), &advance); + const SkVector advance = fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), + SkFixedToScalar(glyph->fAdvanceY)); glyph->fAdvanceX = SkScalarToFixed(advance.fX); glyph->fAdvanceY = SkScalarToFixed(advance.fY); } @@ -224,9 +223,8 @@ protected: void generateMetrics(SkGlyph* glyph) SK_OVERRIDE { fFace->getMetrics(glyph); - SkVector advance; - fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), - SkFixedToScalar(glyph->fAdvanceY), &advance); + const SkVector advance = fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX), + SkFixedToScalar(glyph->fAdvanceY)); glyph->fAdvanceX = SkScalarToFixed(advance.fX); glyph->fAdvanceY = SkScalarToFixed(advance.fY); |