aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-11-10 18:52:17 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-10 18:52:28 +0000
commit77e75005076070957112b5f8f7d1ca8235f81bd1 (patch)
tree48fe23bae671aabbcc32b60e313d826981216f90 /src/core
parenta3dd5ec3a769fb833ce77878cd4e551c15e5074d (diff)
Revert "Extract code for safely creating SkMasks."
This reverts commit 66f2b5eab2ba03950b9d502ed3fc1863d55a9664. Reason for revert: breaking lots of bots Original change's description: > Extract code for safely creating SkMasks. > > This is in preparation for adding a faster small radii blur. > > Change-Id: I8afd4642ebafa63a45031a7a0bd7a720951dc102 > Reviewed-on: https://skia-review.googlesource.com/70040 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Herb Derby <herb@google.com> TBR=herb@google.com,fmalita@chromium.org,fmalita@google.com Change-Id: I83a6953f9ae240cc5f09206e3f77490882869a9f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/70104 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkMaskBlurFilter.cpp62
1 files changed, 25 insertions, 37 deletions
diff --git a/src/core/SkMaskBlurFilter.cpp b/src/core/SkMaskBlurFilter.cpp
index 604a44b47e..282f395792 100644
--- a/src/core/SkMaskBlurFilter.cpp
+++ b/src/core/SkMaskBlurFilter.cpp
@@ -542,33 +542,6 @@ bool SkMaskBlurFilter::hasNoBlur() const {
return (3 * fSigmaW <= 1) && (3 * fSigmaH <= 1);
}
-static SkMask prepare_destination(int radiusX, int radiusY, const SkMask& src) {
- SkSafeMath safe;
-
- SkMask dst;
- // dstW = srcW + 2 * radiusX;
- int dstW = safe.add(src.fBounds.width(), safe.add(radiusX, radiusX));
- // dstH = srcH + 2 * radiusY;
- int dstH = safe.add(src.fBounds.height(), safe.add(radiusY, radiusY));
-
- dst.fBounds.set(0, 0, dstW, dstH);
- dst.fBounds.offset(src.fBounds.x(), src.fBounds.y());
- dst.fBounds.offset(-SkTo<int32_t>(radiusX), -SkTo<int32_t>(radiusY));
-
- dst.fImage = nullptr;
- dst.fRowBytes = SkTo<uint32_t>(dstW);
- dst.fFormat = SkMask::kA8_Format;
-
- size_t toAlloc = safe.mul(dstW, dstH);
-
- if (safe) {
- dst.fImage = SkMask::AllocImage(toAlloc);
- } else{
- dst.fBounds = SkIRect::MakeEmpty();
- }
- return dst;
-}
-
SkIPoint SkMaskBlurFilter::blur(const SkMask& src, SkMask* dst) const {
// 1024 is a place holder guess until more analysis can be done.
@@ -577,23 +550,38 @@ SkIPoint SkMaskBlurFilter::blur(const SkMask& src, SkMask* dst) const {
PlanningInterface* planW = make_plan(&alloc, fSigmaW);
PlanningInterface* planH = make_plan(&alloc, fSigmaH);
- size_t borderW = planW->border(),
- borderH = planH->border();
+ size_t borderW = planW->border();
+ size_t borderH = planH->border();
+
+ auto srcW = SkTo<size_t>(src.fBounds.width());
+ auto srcH = SkTo<size_t>(src.fBounds.height());
+
+ SkSafeMath safe;
+
+ // size_t dstW = srcW + 2 * borderW;
+ size_t dstW = safe.add(srcW, safe.add(borderW, borderW));
+ //size_t dstH = srcH + 2 * borderH;
+ size_t dstH = safe.add(srcH, safe.add(borderH, borderH));
+
+ dst->fBounds.set(0, 0, dstW, dstH);
+ dst->fBounds.offset(src.fBounds.x(), src.fBounds.y());
+ dst->fBounds.offset(-SkTo<int32_t>(borderW), -SkTo<int32_t>(borderH));
+
+ dst->fImage = nullptr;
+ dst->fRowBytes = SkTo<uint32_t>(dstW);
+ dst->fFormat = SkMask::kA8_Format;
if (src.fImage == nullptr) {
return {SkTo<int32_t>(borderW), SkTo<int32_t>(borderH)};
}
- *dst = prepare_destination(borderW, borderH, src);
- if (dst->fImage == nullptr) {
+ size_t toAlloc = safe.mul(dstW, dstH);
+ if (!safe) {
+ dst->fBounds = SkIRect::MakeEmpty();
+ // There is no border offset because we are not drawing.
return {0, 0};
}
-
- auto srcW = SkTo<size_t>(src.fBounds.width());
- auto srcH = SkTo<size_t>(src.fBounds.height());
-
- size_t dstW = dst->fBounds.width(),
- dstH = dst->fBounds.height();
+ dst->fImage = SkMask::AllocImage(toAlloc);
auto bufferSize = std::max(planW->bufferSize(), planH->bufferSize());
auto buffer = alloc.makeArrayDefault<uint32_t>(bufferSize);