Revert "Revert of factories should return baseclass, allowing the impl to specialize (patchset #4 id:60001 of https://codereview.chromium.org/1390523005/ )"

This reverts commit 95376a0dde.

BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1389083002
This commit is contained in:
reed 2015-10-06 14:05:32 -07:00 committed by Commit bot
parent 95376a0dde
commit 5ea95df02d
18 changed files with 119 additions and 125 deletions

View File

@ -63,7 +63,7 @@ protected:
r.offset(fRadius, fRadius);
if (fRadius > 0) {
SkMorphologyImageFilter* mf = nullptr;
SkImageFilter* mf = nullptr;
switch (fStyle) {
case kDilate_MT:
mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius),

View File

@ -56,7 +56,7 @@ protected:
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 @@ protected:
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));

View File

@ -113,7 +113,7 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) {
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 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) {
}
{
SkAutoTUnref<SkDropShadowImageFilter> dsif(
SkAutoTUnref<SkImageFilter> dsif(
SkDropShadowImageFilter::Create(27.0f, 27.0f,
3.0f, 3.0f,
SK_ColorRED,
@ -134,13 +134,13 @@ static void create_paints(SkImageFilter* source, SkTArray<SkPaint>* paints) {
}
{
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 @@ protected:
pic.reset(rec.endRecording());
}
SkAutoTUnref<SkPictureImageFilter> pif(SkPictureImageFilter::Create(pic));
SkAutoTUnref<SkImageFilter> pif(SkPictureImageFilter::Create(pic));
SkTArray<SkPaint> pifPaints;
create_paints(pif, &pifPaints);

View File

@ -57,16 +57,16 @@ protected:
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));

View File

@ -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 @@ public:
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;
};

View File

@ -20,11 +20,9 @@ public:
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 @@ public:
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;
};

View File

@ -16,16 +16,17 @@ class SK_API SkMergeImageFilter : public SkImageFilter {
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 @@ public:
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).

View File

@ -51,9 +51,8 @@ private:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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;
};

View File

@ -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

View File

@ -16,7 +16,7 @@ public:
/**
* 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 @@ public:
* 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 @@ public:
* 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 @@ protected:
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 @@ protected:
* @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 @@ private:
SkRect fCropRect;
PictureResolution fPictureResolution;
SkFilterQuality fFilterQuality;
typedef SkImageFilter INHERITED;
};

View File

@ -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;

View File

@ -26,23 +26,24 @@ public:
* 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;

View File

@ -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 @@ public:
*/
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;

View File

@ -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 @@ public:
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;

View File

@ -15,12 +15,11 @@ class SK_API SkTileImageFilter : public SkImageFilter {
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 @@ public:
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;
};

View File

@ -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 @@ SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe
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;
}

View File

@ -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;
}

View File

@ -354,16 +354,11 @@ static SkBitmap make_gradient_circle(int width, int height) {
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 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
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 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
};
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);