SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
protected:
- FailImageFilter() : INHERITED(0) {}
+ FailImageFilter() : INHERITED(0, NULL) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
return false;
}
FailImageFilter(SkReadBuffer& buffer)
- : INHERITED(1, buffer) {}
+ : INHERITED(0, buffer) {}
private:
typedef SkImageFilter INHERITED;
class IdentityImageFilter : public SkImageFilter {
public:
- static IdentityImageFilter* Create() {
- return SkNEW(IdentityImageFilter);
+ static IdentityImageFilter* Create(SkImageFilter* input = NULL) {
+ return SkNEW_ARGS(IdentityImageFilter, (input));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
protected:
- IdentityImageFilter() : INHERITED(0) {}
+ IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
*result = src;
private:
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
- : SkImageFilter(input), fDX(dx), fDY(dy) {}
+ : SkImageFilter(1, &input), fDX(dx), fDY(dy) {}
SkScalar fDX, fDY;
};
protected:
SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect = NULL);
- // Convenience constructor for 1-input filters.
- explicit SkImageFilter(SkImageFilter* input, const CropRect* cropRect = NULL);
-
- // Convenience constructor for 2-input filters.
- SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect = NULL);
-
virtual ~SkImageFilter();
/**
* The 0,0 point of the region corresponds to the upper left corner of the
* source image.
*/
- static SkImageFilter* Create(const SkRegion& region, SkScalar innerThreshold, SkScalar outerThreshold);
+ static SkImageFilter* Create(const SkRegion& region, SkScalar innerThreshold,
+ SkScalar outerThreshold, SkImageFilter* input = NULL);
};
#endif
private:
SkColorFilterImageFilter(SkColorFilter* cf,
SkImageFilter* input,
- const CropRect* cropRect = NULL);
+ const CropRect* cropRect);
SkColorFilter* fColorFilter;
typedef SkImageFilter INHERITED;
virtual ~SkComposeImageFilter();
static SkComposeImageFilter* Create(SkImageFilter* outer, SkImageFilter* inner) {
- return SkNEW_ARGS(SkComposeImageFilter, (outer, inner));
+ SkImageFilter* inputs[2] = { outer, inner };
+ return SkNEW_ARGS(SkComposeImageFilter, (inputs));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
protected:
- SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) : INHERITED(outer, inner) {}
+ explicit SkComposeImageFilter(SkImageFilter* inputs[2]) : INHERITED(2, inputs) {}
explicit SkComposeImageFilter(SkReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkScalar scale, SkImageFilter* displacement,
SkImageFilter* color = NULL,
const CropRect* cropRect = NULL) {
+ SkImageFilter* inputs[2] = { displacement, color };
return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
- displacement, color, cropRect));
+ inputs, cropRect));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
protected:
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
- SkScalar scale, SkImageFilter* displacement,
- SkImageFilter* color = NULL,
- const CropRect* cropRect = NULL);
+ SkScalar scale, SkImageFilter* inputs[2],
+ const CropRect* cropRect);
explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
SkLightingImageFilter(SkLight* light,
SkScalar surfaceScale,
SkImageFilter* input,
- const CropRect* cropRect = NULL);
+ const CropRect* cropRect);
explicit SkLightingImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
const SkLight* light() const { return fLight; }
class SK_API SkMagnifierImageFilter : public SkImageFilter {
public:
- static SkMagnifierImageFilter* Create(const SkRect& srcRect, SkScalar inset) {
- return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset));
+ static SkMagnifierImageFilter* Create(const SkRect& srcRect, SkScalar inset,
+ SkImageFilter* input = NULL) {
+ return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset, input));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
protected:
- SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset);
+ SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input);
explicit SkMagnifierImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
protected:
SkMatrixImageFilter(const SkMatrix& transform,
SkPaint::FilterLevel,
- SkImageFilter* input = NULL);
+ SkImageFilter* input);
SkMatrixImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
const CropRect* cropRect = NULL) {
- return SkNEW_ARGS(SkMergeImageFilter, (first, second, mode, cropRect));
+ SkImageFilter* inputs[2] = { first, second };
+ SkXfermode::Mode modes[2] = { mode, mode };
+ return SkNEW_ARGS(SkMergeImageFilter, (inputs, 2, modes, cropRect));
}
static SkMergeImageFilter* Create(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[] = NULL,
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
protected:
- SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
- SkXfermode::Mode = SkXfermode::kSrcOver_Mode,
- const CropRect* cropRect = NULL);
SkMergeImageFilter(SkImageFilter* filters[], int count,
- const SkXfermode::Mode modes[] = NULL,
- const CropRect* cropRect = NULL);
+ const SkXfermode::Mode modes[],
+ const CropRect* cropRect);
explicit SkMergeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
protected:
- SkDilateImageFilter(int radiusX, int radiusY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL)
+ SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
protected:
- SkErodeImageFilter(int radiusX, int radiusY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL)
+ SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect)
: INHERITED(radiusX, radiusY, input, cropRect) {}
explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
// 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) {
- return SkNEW_ARGS(SkDownSampleImageFilter, (scale));
+ static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) {
+ return SkNEW_ARGS(SkDownSampleImageFilter, (scale, input));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter)
protected:
- SkDownSampleImageFilter(SkScalar scale) : INHERITED(0), fScale(scale) {}
+ SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input)
+ : INHERITED(1, &input), fScale(scale) {}
SkDownSampleImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
protected:
SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
- : INHERITED(input), fSrcRect(srcRect), fDstRect(dstRect) {}
+ : INHERITED(1, &input), fSrcRect(srcRect), fDstRect(dstRect) {}
explicit SkTileImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
SkImageFilter* foreground = NULL,
const CropRect* cropRect = NULL) {
- return SkNEW_ARGS(SkXfermodeImageFilter, (mode, background, foreground, cropRect));
+ SkImageFilter* inputs[2] = { background, foreground };
+ return SkNEW_ARGS(SkXfermodeImageFilter, (mode, inputs, cropRect));
}
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
#endif
protected:
- SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* background,
- SkImageFilter* foreground, const CropRect* cropRect);
+ SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2],
+ const CropRect* cropRect);
explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
}
}
-SkImageFilter::SkImageFilter(SkImageFilter* input, const CropRect* cropRect)
- : fInputCount(1),
- fInputs(new SkImageFilter*[1]),
- fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)) {
- fInputs[0] = input;
- SkSafeRef(fInputs[0]);
-}
-
-SkImageFilter::SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const CropRect* cropRect)
- : fInputCount(2), fInputs(new SkImageFilter*[2]),
- fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)) {
- fInputs[0] = input1;
- fInputs[1] = input2;
- SkSafeRef(fInputs[0]);
- SkSafeRef(fInputs[1]);
-}
-
SkImageFilter::~SkImageFilter() {
for (int i = 0; i < fInputCount; i++) {
SkSafeUnref(fInputs[i]);
class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter {
public:
- SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, SkScalar outerThreshold);
+ SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold,
+ SkScalar outerThreshold, SkImageFilter* input);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl)
SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
SkScalar innerThreshold,
- SkScalar outerThreshold) {
- return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outerThreshold));
+ SkScalar outerThreshold,
+ SkImageFilter* input) {
+ return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outerThreshold, input));
}
#if SK_SUPPORT_GPU
SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
SkScalar innerThreshold,
- SkScalar outerThreshold)
- : INHERITED(0)
+ SkScalar outerThreshold,
+ SkImageFilter* input)
+ : INHERITED(1, &input)
, fRegion(region)
, fInnerThreshold(innerThreshold)
, fOuterThreshold(outerThreshold) {
SkScalar sigmaY,
SkImageFilter* input,
const CropRect* cropRect)
- : INHERITED(input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) {
+ : INHERITED(1, &input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) {
SkASSERT(sigmaX >= 0 && sigmaY >= 0);
}
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
SkImageFilter* input, const CropRect* cropRect)
- : INHERITED(input, cropRect), fColorFilter(cf) {
+ : INHERITED(1, &input, cropRect), fColorFilter(cf) {
SkASSERT(cf);
SkSafeRef(cf);
}
SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
ChannelSelectorType yChannelSelector,
SkScalar scale,
- SkImageFilter* displacement,
- SkImageFilter* color,
+ SkImageFilter* inputs[2],
const CropRect* cropRect)
- : INHERITED(displacement, color, cropRect)
+ : INHERITED(2, inputs, cropRect)
, fXChannelSelector(xChannelSelector)
, fYChannelSelector(yChannelSelector)
, fScale(scale)
SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma,
SkColor color, SkImageFilter* input)
- : INHERITED(input)
+ : INHERITED(1, &input)
, fDx(dx)
, fDy(dy)
, fSigmaX(sigma)
SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy,
SkScalar sigmaX, SkScalar sigmaY, SkColor color,
SkImageFilter* input, const CropRect* cropRect)
- : INHERITED(input, cropRect)
+ : INHERITED(1, &input, cropRect)
, fDx(dx)
, fDy(dy)
, fSigmaX(sigmaX)
}
///////////////////////////////////////////////////////////////////////////////
-SkLightingImageFilter::SkLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkImageFilter* input, const CropRect* cropRect)
- : INHERITED(input, cropRect),
+SkLightingImageFilter::SkLightingImageFilter(SkLight* light, SkScalar surfaceScale,
+ SkImageFilter* input, const CropRect* cropRect)
+ : INHERITED(1, &input, cropRect),
fLight(light),
fSurfaceScale(SkScalarDiv(surfaceScale, SkIntToScalar(255)))
{
(fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0));
}
-// FIXME: implement single-input semantics
-SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset)
- : INHERITED(0), fSrcRect(srcRect), fInset(inset) {
+SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset,
+ SkImageFilter* input)
+ : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) {
SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
}
bool convolveAlpha,
SkImageFilter* input,
const CropRect* cropRect)
- : INHERITED(input, cropRect),
+ : INHERITED(1, &input, cropRect),
fKernelSize(kernelSize),
fGain(gain),
fBias(bias),
SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform,
SkPaint::FilterLevel filterLevel,
SkImageFilter* input)
- : INHERITED(input),
+ : INHERITED(1, &input),
fTransform(transform),
fFilterLevel(filterLevel) {
}
}
}
-SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
- SkXfermode::Mode mode,
- const CropRect* cropRect) : INHERITED(first, second, cropRect) {
- if (SkXfermode::kSrcOver_Mode != mode) {
- SkXfermode::Mode modes[] = { mode, mode };
- this->initModes(modes);
- } else {
- fModes = NULL;
- }
-}
-
SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count,
const SkXfermode::Mode modes[],
const CropRect* cropRect) : INHERITED(count, filters, cropRect) {
int radiusY,
SkImageFilter* input,
const CropRect* cropRect)
- : INHERITED(input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) {
+ : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) {
}
}
SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input,
- const CropRect* cropRect) : INHERITED(input, cropRect) {
+ const CropRect* cropRect)
+ : INHERITED(1, &input, cropRect) {
fOffset.set(dx, dy);
}
}
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect)
- : INHERITED(NULL, cropRect)
+ : INHERITED(0, NULL, cropRect)
, fShader(s) {
SkASSERT(s);
s->ref();
}
SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer)
- : INHERITED(1, buffer) {
+ : INHERITED(0, buffer) {
fShader = buffer.readShader();
}
///////////////////////////////////////////////////////////////////////////////
SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode,
- SkImageFilter* background,
- SkImageFilter* foreground,
+ SkImageFilter* inputs[2],
const CropRect* cropRect)
- : INHERITED(background, foreground, cropRect), fMode(mode) {
+ : INHERITED(2, inputs, cropRect), fMode(mode) {
SkSafeRef(fMode);
}
class MatrixTestImageFilter : public SkImageFilter {
public:
MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expectedMatrix)
- : SkImageFilter(0), fReporter(reporter), fExpectedMatrix(expectedMatrix) {
+ : SkImageFilter(0, NULL), fReporter(reporter), fExpectedMatrix(expectedMatrix) {
}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx,
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
protected:
- explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0) {
+ explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL) {
fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr());
buffer.readMatrix(&fExpectedMatrix);
}