OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 SkDisplacementMapEffect_DEFINED | 8 #ifndef SkDisplacementMapEffect_DEFINED |
9 #define SkDisplacementMapEffect_DEFINED | 9 #define SkDisplacementMapEffect_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 | 12 |
13 class SK_API SkDisplacementMapEffect : public SkImageFilter { | 13 class SK_API SkDisplacementMapEffect : public SkImageFilter { |
14 public: | 14 public: |
15 enum ChannelSelectorType { | 15 enum ChannelSelectorType { |
16 kUnknown_ChannelSelectorType, | 16 kUnknown_ChannelSelectorType, |
17 kR_ChannelSelectorType, | 17 kR_ChannelSelectorType, |
18 kG_ChannelSelectorType, | 18 kG_ChannelSelectorType, |
19 kB_ChannelSelectorType, | 19 kB_ChannelSelectorType, |
20 kA_ChannelSelectorType | 20 kA_ChannelSelectorType |
21 }; | 21 }; |
22 | 22 |
23 ~SkDisplacementMapEffect(); | 23 ~SkDisplacementMapEffect() override; |
24 | 24 |
25 static SkImageFilter* Create(ChannelSelectorType xChannelSelector, | 25 static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector, |
26 ChannelSelectorType yChannelSelector, | 26 ChannelSelectorType yChannelSelector, |
27 SkScalar scale, SkImageFilter* displacement, | 27 SkScalar scale, |
28 SkImageFilter* color = NULL, | 28 sk_sp<SkImageFilter> displacement, |
29 const CropRect* cropRect = NULL); | 29 sk_sp<SkImageFilter> color, |
| 30 const CropRect* cropRect = nullptr); |
30 | 31 |
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) |
32 | 33 |
33 SkRect computeFastBounds(const SkRect& src) const override; | 34 SkRect computeFastBounds(const SkRect& src) const override; |
34 | 35 |
35 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, | 36 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, |
36 MapDirection) const override; | 37 MapDirection) const override; |
37 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; | 38 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; |
38 | 39 |
39 SK_TO_STRING_OVERRIDE() | 40 SK_TO_STRING_OVERRIDE() |
40 | 41 |
| 42 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
| 43 static SkImageFilter* Create(ChannelSelectorType xChannelSelector, |
| 44 ChannelSelectorType yChannelSelector, |
| 45 SkScalar scale, SkImageFilter* displacement, |
| 46 SkImageFilter* color = nullptr, |
| 47 const CropRect* cropRect = nullptr) { |
| 48 return Make(xChannelSelector, yChannelSelector, scale, |
| 49 sk_ref_sp<SkImageFilter>(displacement), |
| 50 sk_ref_sp<SkImageFilter>(color), |
| 51 cropRect).release(); |
| 52 } |
| 53 #endif |
| 54 |
41 protected: | 55 protected: |
42 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, | 56 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
43 SkIPoint* offset) const override; | 57 SkIPoint* offset) const override; |
44 | 58 |
45 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, | 59 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, |
46 ChannelSelectorType yChannelSelector, | 60 ChannelSelectorType yChannelSelector, |
47 SkScalar scale, SkImageFilter* inputs[2], | 61 SkScalar scale, sk_sp<SkImageFilter> inputs[2], |
48 const CropRect* cropRect); | 62 const CropRect* cropRect); |
49 void flatten(SkWriteBuffer&) const override; | 63 void flatten(SkWriteBuffer&) const override; |
50 | 64 |
51 private: | 65 private: |
52 ChannelSelectorType fXChannelSelector; | 66 ChannelSelectorType fXChannelSelector; |
53 ChannelSelectorType fYChannelSelector; | 67 ChannelSelectorType fYChannelSelector; |
54 SkScalar fScale; | 68 SkScalar fScale; |
55 typedef SkImageFilter INHERITED; | 69 typedef SkImageFilter INHERITED; |
56 const SkImageFilter* getDisplacementInput() const { return getInput(0); } | 70 const SkImageFilter* getDisplacementInput() const { return getInput(0); } |
57 const SkImageFilter* getColorInput() const { return getInput(1); } | 71 const SkImageFilter* getColorInput() const { return getInput(1); } |
58 }; | 72 }; |
59 | 73 |
60 #endif | 74 #endif |
OLD | NEW |