From 915881fe743f9a789037695f543bc6ea189cd0cb Mon Sep 17 00:00:00 2001 From: senorblanco Date: Thu, 20 Aug 2015 07:42:11 -0700 Subject: Implement canComputeFastBounds() for image filters. Image filters have never implemented this check, which means that filters which affect transparent black falsely claim they can compute their bounds. Implemented an affectsTransparentBlack() virtual for image filters, and a similar helper function for color filters. This will affect the following GMs: imagefiltersscaled (lighting, perlin noise now filter to clip), colorfilterimagefilter (new test case), imagefiltersclipped (perlin noise now filters to clip). Note: I de-inlined SkPaint::canComputeFastBounds() to avoid adding a dependency from SkPaint.h to SkImageFilter.h.h. Skia benches show no impact from this change, but will watch the perf bots carefully. BUG=4212 Review URL: https://codereview.chromium.org/1296943002 --- src/core/SkImageFilter.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/core/SkImageFilter.cpp') diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 3214eeb40e..5f9fa64110 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -284,6 +284,23 @@ void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { } } +bool SkImageFilter::canComputeFastBounds() const { + if (this->affectsTransparentBlack()) { + return false; + } + for (int i = 0; i < fInputCount; i++) { + SkImageFilter* input = this->getInput(i); + if (input && !input->canComputeFastBounds()) { + return false; + } + } + return true; +} + +bool SkImageFilter::affectsTransparentBlack() const { + return false; +} + bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, SkBitmap*, SkIPoint*) const { return false; -- cgit v1.2.3