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                                       uint32_t uniqueID = 0);
35    virtual ~SkMatrixImageFilter();
36
37    virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
38
39    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter)
40
41protected:
42    SkMatrixImageFilter(const SkMatrix& transform,
43                        SkPaint::FilterLevel,
44                        SkImageFilter* input,
45                        uint32_t uniqueID);
46#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
47    SkMatrixImageFilter(SkReadBuffer& buffer);
48#endif
49    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
50
51    virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
52                               SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
53    virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
54                                SkIRect* dst) const SK_OVERRIDE;
55
56private:
57    SkMatrix              fTransform;
58    SkPaint::FilterLevel  fFilterLevel;
59    typedef SkImageFilter INHERITED;
60};
61
62#endif
63