1 | /* |
---|---|
2 | * Copyright 2015 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 SkLocalMatrixImageFilter_DEFINED |
9 | #define SkLocalMatrixImageFilter_DEFINED |
10 | |
11 | #include "include/core/SkFlattenable.h" |
12 | #include "src/core/SkImageFilter_Base.h" |
13 | |
14 | /** |
15 | * Wraps another imagefilter + matrix, such that using this filter will give the same result |
16 | * as using the wrapped filter with the matrix applied to its context. |
17 | */ |
18 | class SkLocalMatrixImageFilter : public SkImageFilter_Base { |
19 | public: |
20 | static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input); |
21 | |
22 | protected: |
23 | void flatten(SkWriteBuffer&) const override; |
24 | sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override; |
25 | SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm, |
26 | MapDirection, const SkIRect* inputRect) const override; |
27 | |
28 | bool onCanHandleComplexCTM() const override { return true; } |
29 | |
30 | private: |
31 | SK_FLATTENABLE_HOOKS(SkLocalMatrixImageFilter) |
32 | |
33 | SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input); |
34 | |
35 | SkMatrix fLocalM; |
36 | |
37 | typedef SkImageFilter_Base INHERITED; |
38 | }; |
39 | |
40 | #endif |
41 |