aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-05-17 11:17:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-17 17:06:24 +0000
commit120784394c160d009bc3aa88dd217c13c105a6ca (patch)
treec2f3406ff37360a511af362138938e754c057619 /include
parentffb3d688b0e76ad7d1517657b00e4525cc603f40 (diff)
Fix srcBounds computation in SkMatrixConvolutionImageFilter
Note that this does change the behavior of the cropRect for the repeated case. The cropRect now only acts as a hard clip on the output. BUG= skia:7766 Change-Id: I1d66678bc797cd4835701cd20c36e68b22ac880a Reviewed-on: https://skia-review.googlesource.com/127338 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkColorFilter.h2
-rw-r--r--include/core/SkImageFilter.h28
-rw-r--r--include/effects/SkComposeImageFilter.h3
-rw-r--r--include/effects/SkDisplacementMapEffect.h7
-rw-r--r--include/effects/SkDropShadowImageFilter.h3
-rw-r--r--include/effects/SkImageSource.h3
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h7
-rw-r--r--include/effects/SkMorphologyImageFilter.h3
-rw-r--r--include/effects/SkOffsetImageFilter.h3
-rw-r--r--include/effects/SkTileImageFilter.h6
10 files changed, 50 insertions, 15 deletions
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 97c8220c6b..e8b09bae9c 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -135,7 +135,7 @@ public:
#endif
bool affectsTransparentBlack() const {
- return this->filterColor(0) != 0;
+ return this->filterColor(SK_ColorTRANSPARENT) != SK_ColorTRANSPARENT;
}
virtual void toString(SkString* str) const = 0;
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 2528009e24..70f5513843 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -155,8 +155,13 @@ public:
* be exact, but should never be smaller than the real answer. The default
* implementation recursively unions all input bounds, or returns the
* source rect if no inputs.
+ *
+ * In kReverse mode, 'inputRect' is the device-space bounds of the input pixels. In kForward
+ * mode it should always be null. If 'inputRect' is null in kReverse mode the resulting
+ * answer may be incorrect.
*/
- SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, MapDirection) const;
+ SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect = nullptr) const;
#if SK_SUPPORT_GPU
static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context,
@@ -320,12 +325,16 @@ protected:
* and returns the union of those results. If a derived class has special
* recursion requirements (e.g., it has an input which does not participate
* in bounds computation), it can be overridden here.
+ * In kReverse mode, 'inputRect' is the device-space bounds of the input pixels. In kForward
+ * mode it should always be null. If 'inputRect' is null in kReverse mode the resulting
+ * answer may be incorrect.
*
* Note that this function is *not* responsible for mapping the rect for
* this node's filter bounds requirements (i.e., calling
* onFilterNodeBounds()); that is handled by filterBounds().
*/
- virtual SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection) const;
+ virtual SkIRect onFilterBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const;
/**
* Performs a forwards or reverse mapping of the given rect to accommodate
@@ -339,8 +348,12 @@ protected:
* inverse of the other. For example, blurring expands the given rect
* in both forward and reverse directions. Unlike
* onFilterBounds(), this function is non-recursive.
+ * In kReverse mode, 'inputRect' will be the device space bounds of the input pixels. In
+ * kForward mode, 'inputRect' should always be null. If 'inputRect' is null in kReverse mode
+ * the resulting answer may be incorrect.
*/
- virtual SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const;
+ virtual SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const;
// Helper function which invokes filter processing on the input at the
// specified "index". If the input is null, it returns "src" and leaves
@@ -416,6 +429,15 @@ protected:
return sk_ref_sp(const_cast<SkImageFilter*>(this));
}
+ // If 'srcBounds' will sample outside the border of 'originalSrcBounds' (i.e., the sample
+ // will wrap around to the other side) we must preserve the far side of the src along that
+ // axis (e.g., if we will sample beyond the left edge of the src, the right side must be
+ // preserved for the repeat sampling to work).
+ static SkIRect DetermineRepeatedSrcBound(const SkIRect& srcBounds,
+ const SkIVector& filterOffset,
+ const SkISize& filterSize,
+ const SkIRect& originalSrcBounds);
+
private:
// For makeColorSpace().
friend class SkColorSpaceXformer;
diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h
index dd44df5d9c..0bfb7d8c5c 100644
--- a/include/effects/SkComposeImageFilter.h
+++ b/include/effects/SkComposeImageFilter.h
@@ -27,7 +27,8 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
bool onCanHandleComplexCTM() const override { return true; }
private:
diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h
index af4d6fd10e..daf03d742c 100644
--- a/include/effects/SkDisplacementMapEffect.h
+++ b/include/effects/SkDisplacementMapEffect.h
@@ -35,10 +35,11 @@ public:
SkRect computeFastBounds(const SkRect& src) const override;
- virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&,
- MapDirection) const override;
+ virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
void toString(SkString* str) const override;
diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h
index f6b27db271..d1ee44c168 100644
--- a/include/effects/SkDropShadowImageFilter.h
+++ b/include/effects/SkDropShadowImageFilter.h
@@ -37,7 +37,8 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
private:
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
diff --git a/include/effects/SkImageSource.h b/include/effects/SkImageSource.h
index 25b169c20d..6ef855ab93 100644
--- a/include/effects/SkImageSource.h
+++ b/include/effects/SkImageSource.h
@@ -31,7 +31,8 @@ protected:
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
private:
explicit SkImageSource(sk_sp<SkImage>);
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 94ea716842..5361fef928 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -85,7 +85,8 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
bool affectsTransparentBlack() const override;
private:
@@ -100,19 +101,23 @@ private:
template <class PixelFetcher, bool convolveAlpha>
void filterPixels(const SkBitmap& src,
SkBitmap* result,
+ SkIVector& offset,
const SkIRect& rect,
const SkIRect& bounds) const;
template <class PixelFetcher>
void filterPixels(const SkBitmap& src,
SkBitmap* result,
+ SkIVector& offset,
const SkIRect& rect,
const SkIRect& bounds) const;
void filterInteriorPixels(const SkBitmap& src,
SkBitmap* result,
+ SkIVector& offset,
const SkIRect& rect,
const SkIRect& bounds) const;
void filterBorderPixels(const SkBitmap& src,
SkBitmap* result,
+ SkIVector& offset,
const SkIRect& rect,
const SkIRect& bounds) const;
diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h
index b75fe26d8a..d88a31dc65 100644
--- a/include/effects/SkMorphologyImageFilter.h
+++ b/include/effects/SkMorphologyImageFilter.h
@@ -16,7 +16,8 @@
class SK_API SkMorphologyImageFilter : public SkImageFilter {
public:
SkRect computeFastBounds(const SkRect& src) const override;
- SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
/**
* All morphology procs have the same signature: src is the source buffer, dst the
diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h
index 9356c70fd2..2d7b14f652 100644
--- a/include/effects/SkOffsetImageFilter.h
+++ b/include/effects/SkOffsetImageFilter.h
@@ -27,7 +27,8 @@ protected:
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
- SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
private:
SkOffsetImageFilter(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input, const CropRect*);
diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h
index f37982bbb9..f62d8a02d4 100644
--- a/include/effects/SkTileImageFilter.h
+++ b/include/effects/SkTileImageFilter.h
@@ -21,8 +21,10 @@ public:
const SkRect& dst,
sk_sp<SkImageFilter> input);
- SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
- SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
+ MapDirection, const SkIRect* inputRect) const override;
SkRect computeFastBounds(const SkRect& src) const override;
void toString(SkString* str) const override;