aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-27 21:03:17 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-27 21:03:17 +0000
commit336d1d759590d9bedcbc5a96d0fff79861cf8f7a (patch)
tree4d903712399b986c2d7b92d18ea1d6ec7aee5120 /src/effects
parent99f381ad769cc13b0f23c99c47b65c3f236e15cc (diff)
Implement a computeFastBounds() traversal for SkImageFilter.
This allows for correct culling of primitives which have image filters applied. R=reed@google.com BUG=skia: Review URL: https://codereview.chromium.org/137423005 git-svn-id: http://skia.googlecode.com/svn/trunk@13207 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkBitmapSource.cpp4
-rw-r--r--src/effects/SkBlurImageFilter.cpp11
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp8
-rw-r--r--src/effects/SkDropShadowImageFilter.cpp15
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp9
-rw-r--r--src/effects/SkOffsetImageFilter.cpp9
6 files changed, 56 insertions, 0 deletions
diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp
index daf4fb08b3..4aab92fc66 100644
--- a/src/effects/SkBitmapSource.cpp
+++ b/src/effects/SkBitmapSource.cpp
@@ -78,3 +78,7 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix
offset->fY = dstIRect.fTop;
return true;
}
+
+void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const {
+ *dst = fDstRect;
+}
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index 3e60c9bb87..5d9a077d43 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -224,6 +224,17 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
return true;
}
+
+void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ if (getInput(0)) {
+ getInput(0)->computeFastBounds(src, dst);
+ } else {
+ *dst = src;
+ }
+
+ dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)),
+ SkScalarMul(fSigma.height(), SkIntToScalar(3)));
+}
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 6ad46badb9..fc8d3dda72 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -246,6 +246,14 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
return true;
}
+void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ if (getColorInput()) {
+ getColorInput()->computeFastBounds(src, dst);
+ } else {
+ *dst = src;
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index 61093784fa..87dfa92f9b 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -95,3 +95,18 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
offset->fY = bounds.fTop;
return true;
}
+
+void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ if (getInput(0)) {
+ getInput(0)->computeFastBounds(src, dst);
+ } else {
+ *dst = src;
+ }
+
+ SkRect shadowBounds = *dst;
+ shadowBounds.offset(fDx, fDy);
+ shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)),
+ SkScalarMul(fSigmaY, SkIntToScalar(3)));
+ dst->join(shadowBounds);
+}
+
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index af45c0d3a1..5008ad1814 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -239,6 +239,15 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
return this->filterImageGeneric(dilateXProc, dilateYProc, proxy, source, ctm, dst, offset);
}
+void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ if (getInput(0)) {
+ getInput(0)->computeFastBounds(src, dst);
+ } else {
+ *dst = src;
+ }
+ dst->outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height()));
+}
+
#if SK_SUPPORT_GPU
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp
index 61f68f7afe..e69cf411e3 100644
--- a/src/effects/SkOffsetImageFilter.cpp
+++ b/src/effects/SkOffsetImageFilter.cpp
@@ -65,6 +65,15 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
return true;
}
+void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ if (getInput(0)) {
+ getInput(0)->computeFastBounds(src, dst);
+ } else {
+ *dst = src;
+ }
+ dst->offset(fOffset.fX, fOffset.fY);
+}
+
bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) {
SkVector vec;