1/*
2 * Copyright 2014 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkMatrixImageFilter_DEFINED
9#define SkMatrixImageFilter_DEFINED
10
11#include "SkImageFilter.h"
12#include "SkScalar.h"
13#include "SkSize.h"
14#include "SkPoint.h"
15#include "SkPaint.h"
16
17/*! \class SkMatrixImageFilter
18    Matrix transformation image filter.  This filter draws its source
19    input transformed by the given matrix.
20 */
21
22class SK_API SkMatrixImageFilter : public SkImageFilter {
23public:
24    /** Construct a 2D transformation image filter.
25     *  @param transform    The matrix to apply when drawing the src bitmap
26     *  @param filterLevel  The quality of filtering to apply when scaling.
27     *  @param input        The input image filter.  If NULL, the src bitmap
28     *                      passed to filterImage() is used instead.
29     */
30
31    static SkMatrixImageFilter* Create(const SkMatrix& transform,
32                                       SkPaint::FilterLevel,
33                                       SkImageFilter* input = NULL);
34    virtual ~SkMatrixImageFilter();
35
36    virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
37
38    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter)
39
40protected:
41    SkMatrixImageFilter(const SkMatrix& transform,
42                        SkPaint::FilterLevel,
43                        SkImageFilter* input = NULL);
44    SkMatrixImageFilter(SkReadBuffer& buffer);
45    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
46
47    virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
48                               SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
49    virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
50                                SkIRect* dst) const SK_OVERRIDE;
51
52private:
53    SkMatrix              fTransform;
54    SkPaint::FilterLevel  fFilterLevel;
55    typedef SkImageFilter INHERITED;
56};
57
58#endif
59