OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Android Open Source Project | 2 * Copyright 2014 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkMatrixImageFilter_DEFINED | 8 #ifndef SkMatrixImageFilter_DEFINED |
9 #define SkMatrixImageFilter_DEFINED | 9 #define SkMatrixImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 | 13 |
14 /*! \class SkMatrixImageFilter | 14 /*! \class SkMatrixImageFilter |
15 Matrix transformation image filter. This filter draws its source | 15 Matrix transformation image filter. This filter draws its source |
16 input transformed by the given matrix. | 16 input transformed by the given matrix. |
17 */ | 17 */ |
18 | 18 |
19 class SK_API SkMatrixImageFilter : public SkImageFilter { | 19 class SK_API SkMatrixImageFilter : public SkImageFilter { |
20 public: | 20 public: |
21 /** Construct a 2D transformation image filter. | 21 /** Construct a 2D transformation image filter. |
22 * @param transform The matrix to apply when drawing the src bitmap | 22 * @param transform The matrix to apply when drawing the src bitmap |
23 * @param filterQuality The quality of filtering to apply when scaling. | 23 * @param filterQuality The quality of filtering to apply when scaling. |
24 * @param input The input image filter. If nullptr, the src bitmap | 24 * @param input The input image filter. If nullptr, the src bitmap |
25 * passed to filterImage() is used instead. | 25 * passed to filterImage() is used instead. |
26 */ | 26 */ |
27 | 27 |
28 static SkMatrixImageFilter* Create(const SkMatrix& transform, | 28 static sk_sp<SkImageFilter> Make(const SkMatrix& transform, |
29 SkFilterQuality filterQuality, | 29 SkFilterQuality filterQuality, |
30 SkImageFilter* input = nullptr); | 30 sk_sp<SkImageFilter> input); |
31 | 31 |
32 SkRect computeFastBounds(const SkRect&) const override; | 32 SkRect computeFastBounds(const SkRect&) const override; |
33 | 33 |
34 SK_TO_STRING_OVERRIDE() | 34 SK_TO_STRING_OVERRIDE() |
35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter) | 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter) |
36 | 36 |
| 37 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
| 38 static SkImageFilter* Create(const SkMatrix& transform, |
| 39 SkFilterQuality filterQuality, |
| 40 SkImageFilter* input = nullptr) { |
| 41 return Make(transform, filterQuality, sk_ref_sp<SkImageFilter>(input)).r
elease(); |
| 42 } |
| 43 #endif |
| 44 |
37 protected: | 45 protected: |
38 SkMatrixImageFilter(const SkMatrix& transform, | 46 SkMatrixImageFilter(const SkMatrix& transform, |
39 SkFilterQuality, | 47 SkFilterQuality, |
40 SkImageFilter* input); | 48 sk_sp<SkImageFilter> input); |
41 void flatten(SkWriteBuffer&) const override; | 49 void flatten(SkWriteBuffer&) const override; |
42 | 50 |
43 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, | 51 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
44 SkIPoint* offset) const override; | 52 SkIPoint* offset) const override; |
45 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection
) const override; | 53 SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection
) const override; |
46 | 54 |
47 private: | 55 private: |
48 SkMatrix fTransform; | 56 SkMatrix fTransform; |
49 SkFilterQuality fFilterQuality; | 57 SkFilterQuality fFilterQuality; |
50 typedef SkImageFilter INHERITED; | 58 typedef SkImageFilter INHERITED; |
51 }; | 59 }; |
52 | 60 |
53 #endif | 61 #endif |
OLD | NEW |