aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-02-16 09:11:18 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-16 09:11:18 -0800
commitafec27f13b28d900232cb1825c63cab2d6e4e103 (patch)
treef16414c3118f2b0eb50a19b10fce60554fee7d33 /src
parent944c2d901c5118abae2262f38414ccb939111355 (diff)
Image filters: change applyCropRect() to take a src rect.
Instead of taking the source bitmap and offset, we simply take the source rect bounds, and make the caller responsible for computing it. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1702683002 Review URL: https://codereview.chromium.org/1702683002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkImageFilter.cpp13
-rw-r--r--src/effects/SkBlurImageFilter.cpp12
-rw-r--r--src/effects/SkColorFilterImageFilter.cpp4
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp8
-rw-r--r--src/effects/SkDropShadowImageFilter.cpp4
-rw-r--r--src/effects/SkOffsetImageFilter.cpp4
-rw-r--r--src/effects/SkPaintImageFilter.cpp2
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp8
8 files changed, 33 insertions, 22 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 94d6ab6a16..55abb8887f 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -394,16 +394,9 @@ bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const {
return true;
}
-bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
- const SkIPoint& srcOffset, SkIRect* dstBounds,
- SkIRect* srcBounds) const {
- SkIRect storage;
- if (!srcBounds) {
- srcBounds = &storage;
- }
- src.getBounds(srcBounds);
- srcBounds->offset(srcOffset);
- this->onFilterNodeBounds(*srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection);
+bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds,
+ SkIRect* dstBounds) const {
+ this->onFilterNodeBounds(srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection);
fCropRect.applyTo(*dstBounds, ctx.ctm(), dstBounds);
// Intersect against the clip bounds, in case the crop rect has
// grown the bounds beyond the original clip. This can happen for
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index a1d6a2f80e..6ba9e0b640 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -82,8 +82,10 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- SkIRect srcBounds, dstBounds;
- if (!this->applyCropRect(this->mapContext(ctx), src, srcOffset, &dstBounds, &srcBounds)) {
+ SkIRect srcBounds = src.bounds();
+ srcBounds.offset(srcOffset);
+ SkIRect dstBounds;
+ if (!this->applyCropRect(this->mapContext(ctx), srcBounds, &dstBounds)) {
return false;
}
if (!srcBounds.intersect(dstBounds)) {
@@ -204,8 +206,10 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
- SkIRect srcBounds, dstBounds;
- if (!this->applyCropRect(this->mapContext(ctx), input, srcOffset, &dstBounds, &srcBounds)) {
+ SkIRect srcBounds = input.bounds();
+ srcBounds.offset(srcOffset);
+ SkIRect dstBounds;
+ if (!this->applyCropRect(this->mapContext(ctx), srcBounds, &dstBounds)) {
return false;
}
if (!srcBounds.intersect(dstBounds)) {
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index b0e47505a7..5b97d1bc36 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -66,7 +66,9 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
}
SkIRect bounds;
- if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) {
+ SkIRect srcBounds = src.bounds();
+ srcBounds.offset(srcOffset);
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return false;
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index ec306cca3b..2f95474a76 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -228,7 +228,9 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
SkIRect bounds;
// Since computeDisplacement does bounds checking on color pixel access, we don't need to pad
// the color bitmap to bounds here.
- if (!this->applyCropRect(ctx, color, colorOffset, &bounds)) {
+ SkIRect srcBounds = color.bounds();
+ srcBounds.offset(colorOffset);
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return false;
}
SkIRect displBounds;
@@ -396,10 +398,12 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
if (!this->filterInputGPU(0, proxy, src, ctx, &displacementBM, &displacementOffset)) {
return false;
}
+ SkIRect srcBounds = colorBM.bounds();
+ srcBounds.offset(colorOffset);
SkIRect bounds;
// Since GrDisplacementMapEffect does bounds checking on color pixel access, we don't need to
// pad the color bitmap to bounds here.
- if (!this->applyCropRect(ctx, colorBM, colorOffset, &bounds)) {
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return false;
}
SkIRect displBounds;
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index eb05cf09ec..5f8736f3a5 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -62,8 +62,10 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset))
return false;
+ SkIRect srcBounds = src.bounds();
+ srcBounds.offset(srcOffset);
SkIRect bounds;
- if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) {
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return false;
}
diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp
index 70247f2a19..2aac4f32d1 100644
--- a/src/effects/SkOffsetImageFilter.cpp
+++ b/src/effects/SkOffsetImageFilter.cpp
@@ -37,7 +37,9 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
}
SkIRect bounds;
- if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) {
+ SkIRect srcBounds = src.bounds();
+ srcBounds.offset(srcOffset);
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return false;
}
diff --git a/src/effects/SkPaintImageFilter.cpp b/src/effects/SkPaintImageFilter.cpp
index d141f34dfb..c0210513ac 100644
--- a/src/effects/SkPaintImageFilter.cpp
+++ b/src/effects/SkPaintImageFilter.cpp
@@ -39,7 +39,7 @@ bool SkPaintImageFilter::onFilterImage(Proxy* proxy,
SkBitmap* result,
SkIPoint* offset) const {
SkIRect bounds;
- if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) {
+ if (!this->applyCropRect(ctx, source.bounds(), &bounds)) {
return false;
}
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index fbceedb0dd..3f702e69c4 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -57,11 +57,15 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
}
SkIRect bounds, foregroundBounds;
- if (!applyCropRect(ctx, foreground, foregroundOffset, &foregroundBounds)) {
+ SkIRect foregroundSrcBounds = foreground.bounds();
+ foregroundSrcBounds.offset(foregroundOffset);
+ if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) {
foregroundBounds.setEmpty();
foreground.reset();
}
- if (!applyCropRect(ctx, background, backgroundOffset, &bounds)) {
+ SkIRect backgroundSrcBounds = background.bounds();
+ backgroundSrcBounds.offset(backgroundOffset);
+ if (!applyCropRect(ctx, backgroundSrcBounds, &bounds)) {
bounds.setEmpty();
background.reset();
}