Put SimpleOffsetFilter on heap.

Effects want to live on the heap!

BUG=skia:
R=senorblanco@chromium.org, dominikg@chromium.org, scroggo@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/203273002

git-svn-id: http://skia.googlecode.com/svn/trunk@13848 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-03-18 10:28:27 +00:00
parent a1dfa0cf05
commit 2077427227

View File

@ -26,8 +26,9 @@
// perform a draw and this one does.
class SimpleOffsetFilter : public SkImageFilter {
public:
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
: SkImageFilter(input), fDX(dx), fDY(dy) {}
static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input) {
return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input));
}
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE {
@ -70,6 +71,9 @@ protected:
}
private:
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
: SkImageFilter(input), fDX(dx), fDY(dy) {}
SkScalar fDX, fDY;
};
@ -157,11 +161,12 @@ protected:
0, 0, 0, 0.5f, 0 };
SkAutoTUnref<SkColorMatrixFilter> matrixCF(SkColorMatrixFilter::Create(matrix));
SkAutoTUnref<SkImageFilter> matrixFilter(SkColorFilterImageFilter::Create(matrixCF));
SimpleOffsetFilter offsetFilter(SkIntToScalar(10), SkIntToScalar(10), matrixFilter);
SkAutoTUnref<SkImageFilter> offsetFilter(
SimpleOffsetFilter::Create(10.0f, 10.f, matrixFilter));
SkAutoTUnref<SkXfermode> arith(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0));
SkAutoTUnref<SkXfermodeImageFilter> arithFilter(
SkXfermodeImageFilter::Create(arith, matrixFilter, &offsetFilter));
SkXfermodeImageFilter::Create(arith, matrixFilter, offsetFilter));
SkPaint paint;
paint.setImageFilter(arithFilter);