aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-04-01 16:41:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-01 16:41:10 -0700
commit6db0a7bdceb6be85721bfb0db8dea7fd27db5970 (patch)
treeb963703827c0a0b99e40b6a4d7e5a9afed9947a1 /include
parent2d9c6f81353597aebf5934547e5cba7a872196fb (diff)
Image filters: optimize crop rect application.
If a filter does not affect transparent black, there's no reason to allow the crop rect to expand beyond the optimal size determined by onFilterNodeBounds(). So don't enlarge the bounds unless the filter affects transparent black. In order to determine which filters affect transparent black, I've pulled the inverse of the canComputeFastBounds() logic into a non-recursive, affectsTransparentBlack() virtual, and left canComputeFastBounds() as a non-virtual, recursive function that calls it. BUG=599933 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1848953002 TBR=reed@google.com Review URL: https://codereview.chromium.org/1848953002
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImageFilter.h11
-rw-r--r--include/effects/SkColorFilterImageFilter.h2
-rw-r--r--include/effects/SkLightingImageFilter.h2
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h2
-rw-r--r--include/effects/SkPaintImageFilter.h2
5 files changed, 12 insertions, 7 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index d1b1483386..4493d282dd 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -88,12 +88,16 @@ public:
/**
* Apply this cropRect to the imageBounds. If a given edge of the cropRect is not
- * set, then the corresponding edge from imageBounds will be used.
+ * set, then the corresponding edge from imageBounds will be used. If "embiggen"
+ * is true, the crop rect is allowed to enlarge the size of the rect, otherwise
+ * it may only reduce the rect. Filters that can affect transparent black should
+ * pass "true", while all other filters should pass "false".
*
* Note: imageBounds is in "device" space, as the output cropped rectangle will be,
* so the matrix is ignored for those. It is only applied the croprect's bounds.
*/
- void applyTo(const SkIRect& imageBounds, const SkMatrix&, SkIRect* cropped) const;
+ void applyTo(const SkIRect& imageBounds, const SkMatrix&, bool embiggen,
+ SkIRect* cropped) const;
private:
SkRect fRect;
@@ -249,7 +253,7 @@ public:
virtual SkRect computeFastBounds(const SkRect&) const;
// Can this filter DAG compute the resulting bounds of an object-space rectangle?
- virtual bool canComputeFastBounds() const;
+ bool canComputeFastBounds() const;
/**
* If this filter can be represented by another filter + a localMatrix, return that filter,
@@ -466,6 +470,7 @@ private:
SkBitmap* result, SkIPoint* offset) const;
bool usesSrcInput() const { return fUsesSrcInput; }
+ virtual bool affectsTransparentBlack() const { return false; }
typedef SkFlattenable INHERITED;
int fInputCount;
diff --git a/include/effects/SkColorFilterImageFilter.h b/include/effects/SkColorFilterImageFilter.h
index 90e6e4bd71..ebe263930d 100644
--- a/include/effects/SkColorFilterImageFilter.h
+++ b/include/effects/SkColorFilterImageFilter.h
@@ -25,7 +25,7 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
bool onIsColorFilterNode(SkColorFilter**) const override;
- bool canComputeFastBounds() const override;
+ bool affectsTransparentBlack() const override;
private:
SkColorFilterImageFilter(SkColorFilter* cf,
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h
index 33cfceccb2..fb356c52e4 100644
--- a/include/effects/SkLightingImageFilter.h
+++ b/include/effects/SkLightingImageFilter.h
@@ -49,7 +49,7 @@ protected:
void flatten(SkWriteBuffer&) const override;
const SkImageFilterLight* light() const { return fLight.get(); }
SkScalar surfaceScale() const { return fSurfaceScale; }
- bool canComputeFastBounds() const override { return false; }
+ bool affectsTransparentBlack() const override { return true; }
private:
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index a4abb0d0cf..092af08f0c 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -80,7 +80,7 @@ protected:
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* loc) const override;
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
- bool canComputeFastBounds() const override;
+ bool affectsTransparentBlack() const override;
#if SK_SUPPORT_GPU
bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
diff --git a/include/effects/SkPaintImageFilter.h b/include/effects/SkPaintImageFilter.h
index 2876c0431b..35a76b80fb 100644
--- a/include/effects/SkPaintImageFilter.h
+++ b/include/effects/SkPaintImageFilter.h
@@ -26,7 +26,7 @@ public:
return sk_sp<SkImageFilter>(new SkPaintImageFilter(paint, cropRect));
}
- bool canComputeFastBounds() const override;
+ bool affectsTransparentBlack() const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter)