aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkMatrixConvolutionImageFilter.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 10:51:58 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 10:51:58 +0000
commitcac5fd597f6e2495f50aaa6bcbe3dadc56f0b977 (patch)
treeaeeee764feb84da585a469d005bfaf0e4a69bc13 /include/effects/SkMatrixConvolutionImageFilter.h
parentb471a32460a44043e1f00d28cbefc87579dc30c5 (diff)
Factory methods for heap-allocated SkImageFilter objects.
This is part of an effort to ensure that all SkPaint effects can only be allocated on the heap. This patch makes the constructors of SkImageFilter and its subclasses non-public and instead provides factory methods for creating these objects on the heap. We temporarily keep constructor of publicly visible classes public behind a flag. BUG=skia:2187 R=scroggo@google.com, mtklein@chromium.org, reed@google.com, senorblanco@google.com, senorblanco@chromium.org, bsalomon@google.com, sugoi@chromium.org, zork@chromium.org Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/182983003 git-svn-id: http://skia.googlecode.com/svn/trunk@13718 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects/SkMatrixConvolutionImageFilter.h')
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h77
1 files changed, 47 insertions, 30 deletions
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 59af83e025..524d05d9ca 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -28,38 +28,42 @@ public:
kClampToBlack_TileMode, /*!< Fill with transparent black. */
};
+ virtual ~SkMatrixConvolutionImageFilter();
+
/** Construct a matrix convolution image filter.
- @param kernelSize The kernel size in pixels, in each dimension (N by M).
- @param kernel The image processing kernel. Must contain N * M
- elements, in row order.
- @param gain A scale factor applied to each pixel after
- convolution. This can be used to normalize the
- kernel, if it does not sum to 1.
- @param bias A bias factor added to each pixel after convolution.
- @param target An offset applied to each pixel coordinate before
- convolution. This can be used to center the kernel
- over the image (e.g., a 3x3 kernel should have a
- target of {1, 1}).
- @param tileMode How accesses outside the image are treated. (@see
- TileMode).
+ @param kernelSize The kernel size in pixels, in each dimension (N by M).
+ @param kernel The image processing kernel. Must contain N * M
+ elements, in row order.
+ @param gain A scale factor applied to each pixel after
+ convolution. This can be used to normalize the
+ kernel, if it does not sum to 1.
+ @param bias A bias factor added to each pixel after convolution.
+ @param kernelOffset An offset applied to each pixel coordinate before
+ convolution. This can be used to center the kernel
+ over the image (e.g., a 3x3 kernel should have an
+ offset of {1, 1}).
+ @param tileMode How accesses outside the image are treated. (@see
+ TileMode).
@param convolveAlpha If true, all channels are convolved. If false,
- only the RGB channels are convolved, and
- alpha is copied from the source image.
- @param input The input image filter. If NULL, the src bitmap
- passed to filterImage() is used instead.
- @param cropRect The rectangle to which the output processing will be limited.
+ only the RGB channels are convolved, and
+ alpha is copied from the source image.
+ @param input The input image filter. If NULL, the src bitmap
+ passed to filterImage() is used instead.
+ @param cropRect The rectangle to which the output processing will be limited.
*/
-
- SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& target,
- TileMode tileMode,
- bool convolveAlpha,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL);
- virtual ~SkMatrixConvolutionImageFilter();
+ static SkMatrixConvolutionImageFilter* Create(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha,
+ input, cropRect));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
@@ -77,12 +81,25 @@ protected:
const SkIRect& bounds) const SK_OVERRIDE;
#endif
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL);
+
private:
SkISize fKernelSize;
SkScalar* fKernel;
SkScalar fGain;
SkScalar fBias;
- SkIPoint fTarget;
+ SkIPoint fKernelOffset;
TileMode fTileMode;
bool fConvolveAlpha;
typedef SkImageFilter INHERITED;