factories should return baseclass, allowing the impl to specialize
waiting on https://codereview.chromium.org/1386163002/# to land
BUG=skia:4424
Review URL: https://codereview.chromium.org/1390523005
diff --git a/bench/MorphologyBench.cpp b/bench/MorphologyBench.cpp
index 51da197..fd60ebe 100644
--- a/bench/MorphologyBench.cpp
+++ b/bench/MorphologyBench.cpp
@@ -63,7 +63,7 @@
r.offset(fRadius, fRadius);
if (fRadius > 0) {
- SkMorphologyImageFilter* mf = nullptr;
+ SkImageFilter* mf = nullptr;
switch (fStyle) {
case kDilate_MT:
mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius),
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index 20c462b..f2164e8 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -56,7 +56,7 @@
SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fRedImage));
- SkAutoTUnref<SkTileImageFilter> tif(SkTileImageFilter::Create(
+ SkAutoTUnref<SkImageFilter> tif(SkTileImageFilter::Create(
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)),
imageSource));
@@ -71,7 +71,7 @@
SkRect bound2 = SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize));
- SkAutoTUnref<SkTileImageFilter> tif2(SkTileImageFilter::Create(
+ SkAutoTUnref<SkImageFilter> tif2(SkTileImageFilter::Create(
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
nullptr));
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index dcff05b..d484c42 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -113,7 +113,7 @@
static const SkDropShadowImageFilter::ShadowMode kBoth =
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode;
- SkAutoTUnref<SkDropShadowImageFilter> dsif(
+ SkAutoTUnref<SkImageFilter> dsif(
SkDropShadowImageFilter::Create(10.0f, 10.0f,
3.0f, 3.0f,
SK_ColorRED, kBoth,
@@ -123,7 +123,7 @@
}
{
- SkAutoTUnref<SkDropShadowImageFilter> dsif(
+ SkAutoTUnref<SkImageFilter> dsif(
SkDropShadowImageFilter::Create(27.0f, 27.0f,
3.0f, 3.0f,
SK_ColorRED,
@@ -134,13 +134,13 @@
}
{
- SkAutoTUnref<SkBlurImageFilter> bif(SkBlurImageFilter::Create(3, 3, source));
+ SkAutoTUnref<SkImageFilter> bif(SkBlurImageFilter::Create(3, 3, source));
add_paint(bif, paints);
}
{
- SkAutoTUnref<SkOffsetImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source));
+ SkAutoTUnref<SkImageFilter> oif(SkOffsetImageFilter::Create(15, 15, source));
add_paint(oif, paints);
}
@@ -246,7 +246,7 @@
pic.reset(rec.endRecording());
}
- SkAutoTUnref<SkPictureImageFilter> pif(SkPictureImageFilter::Create(pic));
+ SkAutoTUnref<SkImageFilter> pif(SkPictureImageFilter::Create(pic));
SkTArray<SkPaint> pifPaints;
create_paints(pif, &pifPaints);
diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp
index 7f6cfbd..ad47917 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -57,16 +57,16 @@
SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
- SkAutoTUnref<SkPictureImageFilter> pictureSource(
+ SkAutoTUnref<SkImageFilter> pictureSource(
SkPictureImageFilter::Create(fPicture));
- SkAutoTUnref<SkPictureImageFilter> pictureSourceSrcRect(
+ SkAutoTUnref<SkImageFilter> pictureSourceSrcRect(
SkPictureImageFilter::Create(fPicture, srcRect));
- SkAutoTUnref<SkPictureImageFilter> pictureSourceEmptyRect(
+ SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect(
SkPictureImageFilter::Create(fPicture, emptyRect));
- SkAutoTUnref<SkPictureImageFilter> pictureSourceResampled(
+ SkAutoTUnref<SkImageFilter> pictureSourceResampled(
SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(),
kLow_SkFilterQuality));
- SkAutoTUnref<SkPictureImageFilter> pictureSourcePixelated(
+ SkAutoTUnref<SkImageFilter> pictureSourcePixelated(
SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(),
kNone_SkFilterQuality));
diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h
index b0bd309..c7193a4 100644
--- a/include/effects/SkBlurImageFilter.h
+++ b/include/effects/SkBlurImageFilter.h
@@ -13,10 +13,8 @@
class SK_API SkBlurImageFilter : public SkImageFilter {
public:
- static SkBlurImageFilter* Create(SkScalar sigmaX,
- SkScalar sigmaY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL) {
+ static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect);
}
@@ -26,22 +24,20 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter)
protected:
+ void flatten(SkWriteBuffer&) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* offset) const override;
+ bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override;
+ bool canFilterImageGPU() const override { return true; }
+ bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, SkBitmap* result,
+ SkIPoint* offset) const override;
+
+private:
SkBlurImageFilter(SkScalar sigmaX,
SkScalar sigmaY,
SkImageFilter* input,
const CropRect* cropRect);
- void flatten(SkWriteBuffer&) const override;
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const override;
- virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst) const override;
-
- bool canFilterImageGPU() const override { return true; }
- virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const override;
-
-private:
SkSize fSigma;
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h
index 964a576..bf4425e 100644
--- a/include/effects/SkDropShadowImageFilter.h
+++ b/include/effects/SkDropShadowImageFilter.h
@@ -20,11 +20,9 @@
static const int kShadowModeCount = kLast_ShadowMode+1;
- static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy,
- SkScalar sigmaX, SkScalar sigmaY, SkColor color,
- ShadowMode shadowMode,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL) {
+ static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY,
+ SkColor color, ShadowMode shadowMode, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadowMode, input,
cropRect);
}
@@ -34,16 +32,18 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
protected:
- SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
- ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;
- bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, SkIPoint* loc) const override;
- virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
+ bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override;
private:
+ SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
+ ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect);
+
SkScalar fDx, fDy, fSigmaX, fSigmaY;
SkColor fColor;
ShadowMode fShadowMode;
+
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h
index 714a755..10c2913 100644
--- a/include/effects/SkMergeImageFilter.h
+++ b/include/effects/SkMergeImageFilter.h
@@ -16,16 +16,17 @@
public:
virtual ~SkMergeImageFilter();
- static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
- SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
- const CropRect* cropRect = NULL) {
+ static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
+ SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
+ const CropRect* cropRect = NULL) {
SkImageFilter* inputs[2] = { first, second };
SkXfermode::Mode modes[2] = { mode, mode };
return new SkMergeImageFilter(inputs, 2, modes, cropRect);
}
- static SkMergeImageFilter* Create(SkImageFilter* filters[], int count,
- const SkXfermode::Mode modes[] = NULL,
- const CropRect* cropRect = NULL) {
+
+ static SkImageFilter* Create(SkImageFilter* filters[], int count,
+ const SkXfermode::Mode modes[] = NULL,
+ const CropRect* cropRect = NULL) {
return new SkMergeImageFilter(filters, count, modes, cropRect);
}
@@ -33,16 +34,15 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
protected:
- SkMergeImageFilter(SkImageFilter* filters[], int count,
- const SkXfermode::Mode modes[],
- const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;
-
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* loc) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
private:
- uint8_t* fModes; // SkXfermode::Mode
+ SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[],
+ const CropRect* cropRect);
+
+ uint8_t* fModes; // SkXfermode::Mode
// private storage, to avoid dynamically allocating storage for our copy
// of the modes (unless the count is so large we can't fit).
diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h
index 8d17609..c927f22 100644
--- a/include/effects/SkMorphologyImageFilter.h
+++ b/include/effects/SkMorphologyImageFilter.h
@@ -13,7 +13,7 @@
#include "SkImageFilter.h"
#include "SkSize.h"
-class SK_API SkMorphologyImageFilter : public SkImageFilter {
+class SkMorphologyImageFilter : public SkImageFilter {
public:
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const override;
@@ -51,9 +51,8 @@
class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
public:
- static SkDilateImageFilter* Create(int radiusX, int radiusY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL) {
+ static SkImageFilter* Create(int radiusX, int radiusY, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
@@ -62,6 +61,7 @@
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override;
+
#if SK_SUPPORT_GPU
bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override;
@@ -70,16 +70,16 @@
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
-protected:
+private:
SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
-private:
+
typedef SkMorphologyImageFilter INHERITED;
};
class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
public:
- static SkErodeImageFilter* Create(int radiusX, int radiusY,
+ static SkImageFilter* Create(int radiusX, int radiusY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL) {
if (radiusX < 0 || radiusY < 0) {
@@ -90,6 +90,7 @@
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override;
+
#if SK_SUPPORT_GPU
bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override;
@@ -98,11 +99,10 @@
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
-protected:
+private:
SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
-private:
typedef SkMorphologyImageFilter INHERITED;
};
diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h
index 30e380d..40f2ce3 100644
--- a/include/effects/SkOffsetImageFilter.h
+++ b/include/effects/SkOffsetImageFilter.h
@@ -12,30 +12,32 @@
#include "SkPoint.h"
class SK_API SkOffsetImageFilter : public SkImageFilter {
- typedef SkImageFilter INHERITED;
-
public:
- static SkOffsetImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL) {
+ static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) {
return NULL;
}
return new SkOffsetImageFilter(dx, dy, input, cropRect);
}
+
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
protected:
- SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;
-
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* loc) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override;
private:
+ SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect*);
+
SkVector fOffset;
+
+ typedef SkImageFilter INHERITED;
};
#endif
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index 231a492..934d132 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -16,7 +16,7 @@
/**
* Refs the passed-in picture.
*/
- static SkPictureImageFilter* Create(const SkPicture* picture) {
+ static SkImageFilter* Create(const SkPicture* picture) {
return new SkPictureImageFilter(picture);
}
@@ -24,7 +24,7 @@
* Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
* the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
*/
- static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
+ static SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureResolution,
kLow_SkFilterQuality);
}
@@ -36,12 +36,13 @@
* expand the destination rect when the picture is drawn. (No scaling is implied by the
* dest rect; only the CTM is applied.)
*/
- static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture,
+ static SkImageFilter* CreateForLocalSpace(const SkPicture* picture,
const SkRect& cropRect,
SkFilterQuality filterQuality) {
return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureResolution,
filterQuality);
}
+
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
@@ -51,10 +52,8 @@
kLocalSpace_PictureResolution
};
- explicit SkPictureImageFilter(const SkPicture* picture);
- SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
- PictureResolution, SkFilterQuality);
virtual ~SkPictureImageFilter();
+
/* Constructs an SkPictureImageFilter object from an SkReadBuffer.
* Note: If the SkPictureImageFilter object construction requires bitmap
* decoding, the decoder must be set on the SkReadBuffer parameter by calling
@@ -62,11 +61,13 @@
* @param SkReadBuffer Serialized picture data.
*/
void flatten(SkWriteBuffer&) const override;
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* offset) const override;
private:
-
+ explicit SkPictureImageFilter(const SkPicture* picture);
+ SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
+ PictureResolution, SkFilterQuality);
void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBounds,
const Context&) const;
@@ -77,6 +78,7 @@
SkRect fCropRect;
PictureResolution fPictureResolution;
SkFilterQuality fFilterQuality;
+
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h
index 8b7f338..f2fe471 100644
--- a/include/effects/SkPixelXorXfermode.h
+++ b/include/effects/SkPixelXorXfermode.h
@@ -17,19 +17,18 @@
*/
class SK_API SkPixelXorXfermode : public SkXfermode {
public:
- static SkPixelXorXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); }
+ static SkXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); }
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
protected:
- explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
void flatten(SkWriteBuffer&) const override;
-
- // override from SkXfermode
SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override;
private:
+ explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
+
SkColor fOpColor;
typedef SkXfermode INHERITED;
diff --git a/include/effects/SkRectShaderImageFilter.h b/include/effects/SkRectShaderImageFilter.h
index d781628..9798af2 100644
--- a/include/effects/SkRectShaderImageFilter.h
+++ b/include/effects/SkRectShaderImageFilter.h
@@ -26,23 +26,24 @@
* primitive's bounds are used instead.
*/
SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)")
- static SkRectShaderImageFilter* Create(SkShader* s, const SkRect& rect);
+ static SkImageFilter* Create(SkShader* s, const SkRect& rect);
+ static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
- static SkRectShaderImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
- virtual ~SkRectShaderImageFilter();
bool affectsTransparentBlack() const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
protected:
- void flatten(SkWriteBuffer&) const override;
+ virtual ~SkRectShaderImageFilter();
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* loc) const override;
+ void flatten(SkWriteBuffer&) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
private:
SkRectShaderImageFilter(SkShader* s, const CropRect* rect);
+
SkShader* fShader;
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkTableMaskFilter.h b/include/effects/SkTableMaskFilter.h
index 1d53087..757ddf2 100644
--- a/include/effects/SkTableMaskFilter.h
+++ b/include/effects/SkTableMaskFilter.h
@@ -18,8 +18,6 @@
*/
class SK_API SkTableMaskFilter : public SkMaskFilter {
public:
- virtual ~SkTableMaskFilter();
-
/** Utility that sets the gamma table
*/
static void MakeGammaTable(uint8_t table[256], SkScalar gamma);
@@ -29,35 +27,37 @@
*/
static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max);
- static SkTableMaskFilter* Create(const uint8_t table[256]) {
+ static SkMaskFilter* Create(const uint8_t table[256]) {
return new SkTableMaskFilter(table);
}
- static SkTableMaskFilter* CreateGamma(SkScalar gamma) {
+ static SkMaskFilter* CreateGamma(SkScalar gamma) {
uint8_t table[256];
MakeGammaTable(table, gamma);
return new SkTableMaskFilter(table);
}
- static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) {
+ static SkMaskFilter* CreateClip(uint8_t min, uint8_t max) {
uint8_t table[256];
MakeClipTable(table, min, max);
return new SkTableMaskFilter(table);
}
SkMask::Format getFormat() const override;
- virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&,
- SkIPoint*) const override;
+ bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter)
protected:
- SkTableMaskFilter();
- explicit SkTableMaskFilter(const uint8_t table[256]);
+ virtual ~SkTableMaskFilter();
+
void flatten(SkWriteBuffer&) const override;
private:
+ SkTableMaskFilter();
+ explicit SkTableMaskFilter(const uint8_t table[256]);
+
uint8_t fTable[256];
typedef SkMaskFilter INHERITED;
diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h
index 4fa0c43..06a3ff3 100644
--- a/include/effects/SkTestImageFilters.h
+++ b/include/effects/SkTestImageFilters.h
@@ -14,7 +14,7 @@
// Fun mode that scales down (only) and then scales back up to look pixelated
class SK_API SkDownSampleImageFilter : public SkImageFilter {
public:
- static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) {
+ static SkImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) {
if (!SkScalarIsFinite(scale)) {
return NULL;
}
@@ -29,14 +29,14 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter)
protected:
- SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input)
- : INHERITED(1, &input), fScale(scale) {}
void flatten(SkWriteBuffer&) const override;
-
- virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* loc) const override;
+ bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+ SkIPoint* loc) const override;
private:
+ SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input)
+ : INHERITED(1, &input), fScale(scale) {}
+
SkScalar fScale;
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h
index 4dccf85..a2a1bb0 100644
--- a/include/effects/SkTileImageFilter.h
+++ b/include/effects/SkTileImageFilter.h
@@ -15,12 +15,11 @@
public:
/** Create a tile image filter
- @param srcRect Defines the pixels to tile
- @param dstRect Defines the pixels where tiles are drawn
+ @param src Defines the pixels to tile
+ @param dst Defines the pixels where tiles are drawn
@param input Input from which the subregion defined by srcRect will be tiled
*/
- static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect,
- SkImageFilter* input);
+ static SkImageFilter* Create(const SkRect& src, const SkRect& dst, SkImageFilter* input);
bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const override;
@@ -32,12 +31,12 @@
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
protected:
- SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
- : INHERITED(1, &input, NULL), fSrcRect(srcRect), fDstRect(dstRect) {}
-
void flatten(SkWriteBuffer& buffer) const override;
private:
+ SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
+ : INHERITED(1, &input, NULL), fSrcRect(srcRect), fDstRect(dstRect) {}
+
SkRect fSrcRect;
SkRect fDstRect;
};
diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp
index f9e7070..14837d0 100644
--- a/src/effects/SkRectShaderImageFilter.cpp
+++ b/src/effects/SkRectShaderImageFilter.cpp
@@ -13,7 +13,7 @@
#include "SkWriteBuffer.h"
#include "SkShader.h"
-SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) {
+SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) {
SkASSERT(s);
uint32_t flags = CropRect::kHasAll_CropEdge;
if (rect.width() == 0 || rect.height() == 0) {
@@ -23,7 +23,7 @@
return s ? new SkRectShaderImageFilter(s, &cropRect) : nullptr;
}
-SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) {
+SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) {
SkASSERT(s);
return s ? new SkRectShaderImageFilter(s, cropRect) : nullptr;
}
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp
index 5e633a3..c3eb2f3 100644
--- a/src/effects/SkTileImageFilter.cpp
+++ b/src/effects/SkTileImageFilter.cpp
@@ -16,8 +16,8 @@
#include "SkShader.h"
#include "SkValidationUtils.h"
-SkTileImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect,
- SkImageFilter* input) {
+SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& dstRect,
+ SkImageFilter* input) {
if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
return nullptr;
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index b1a017c..f83d315 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -354,16 +354,11 @@
static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) {
// Check that SkBlurImageFilter will accept a negative sigma, either in
// the given arguments or after CTM application.
- int width = 32, height = 32;
- SkScalar five = SkIntToScalar(5);
+ const int width = 32, height = 32;
+ const SkScalar five = SkIntToScalar(5);
- SkAutoTUnref<SkBlurImageFilter> positiveFilter(
- SkBlurImageFilter::Create(five, five)
- );
-
- SkAutoTUnref<SkBlurImageFilter> negativeFilter(
- SkBlurImageFilter::Create(-five, five)
- );
+ SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, five));
+ SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five));
SkBitmap gradient = make_gradient_circle(width, height);
SkBitmap positiveResult1, negativeResult1;
@@ -422,9 +417,9 @@
SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1),
SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
};
- SkISize kernelSize = SkISize::Make(3, 3);
- SkScalar gain = SK_Scalar1, bias = 0;
- SkScalar five = SkIntToScalar(5);
+ const SkISize kernelSize = SkISize::Make(3, 3);
+ const SkScalar gain = SK_Scalar1, bias = 0;
+ const SkScalar five = SkIntToScalar(5);
SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_circle(64, 64)));
SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientImage));
@@ -489,7 +484,7 @@
};
SkBitmap untiledResult, tiledResult;
- int width = 64, height = 64;
+ const int width = 64, height = 64;
untiledResult.allocN32Pixels(width, height);
tiledResult.allocN32Pixels(width, height);
SkCanvas tiledCanvas(tiledResult);