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 "include/core/SkFlattenable.h"
12#include "include/core/SkMatrix.h"
13#include "src/core/SkImageFilter_Base.h"
14
15/*! \class SkMatrixImageFilter
16 Matrix transformation image filter. This filter draws its source
17 input transformed by the given matrix.
18 */
19
20class SkMatrixImageFilter : public SkImageFilter_Base {
21public:
22 /** Construct a 2D transformation image filter.
23 * @param transform The matrix to apply when drawing the src bitmap
24 * @param filterQuality The quality of filtering to apply when scaling.
25 * @param input The input image filter. If nullptr, the src bitmap
26 * passed to filterImage() is used instead.
27 */
28
29 static sk_sp<SkImageFilter> Make(const SkMatrix& transform,
30 SkFilterQuality filterQuality,
31 sk_sp<SkImageFilter> input);
32
33 SkRect computeFastBounds(const SkRect&) const override;
34
35protected:
36 SkMatrixImageFilter(const SkMatrix& transform,
37 SkFilterQuality,
38 sk_sp<SkImageFilter> input);
39 void flatten(SkWriteBuffer&) const override;
40
41 sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;
42 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
43 MapDirection, const SkIRect* inputRect) const override;
44
45private:
46 SK_FLATTENABLE_HOOKS(SkMatrixImageFilter)
47
48 SkMatrix fTransform;
49 SkFilterQuality fFilterQuality;
50 typedef SkImageFilter_Base INHERITED;
51};
52
53#endif
54