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() override; | 23 ~SkDisplacementMapEffect(); |
24 | 24 |
25 static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector, | 25 static SkImageFilter* Create(ChannelSelectorType xChannelSelector, |
26 ChannelSelectorType yChannelSelector, | 26 ChannelSelectorType yChannelSelector, |
27 SkScalar scale, | 27 SkScalar scale, SkImageFilter* displacement, |
28 sk_sp<SkImageFilter> displacement, | 28 SkImageFilter* color = NULL, |
29 sk_sp<SkImageFilter> color, | 29 const CropRect* cropRect = NULL); |
30 const CropRect* cropRect = nullptr); | |
31 | 30 |
32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) | 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) |
33 | 32 |
34 SkRect computeFastBounds(const SkRect& src) const override; | 33 SkRect computeFastBounds(const SkRect& src) const override; |
35 | 34 |
36 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, | 35 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, |
37 MapDirection) const override; | 36 MapDirection) const override; |
38 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; | 37 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; |
39 | 38 |
40 SK_TO_STRING_OVERRIDE() | 39 SK_TO_STRING_OVERRIDE() |
41 | 40 |
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 | |
55 protected: | 41 protected: |
56 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, | 42 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
57 SkIPoint* offset) const override; | 43 SkIPoint* offset) const override; |
58 | 44 |
59 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, | 45 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, |
60 ChannelSelectorType yChannelSelector, | 46 ChannelSelectorType yChannelSelector, |
61 SkScalar scale, sk_sp<SkImageFilter> inputs[2], | 47 SkScalar scale, SkImageFilter* inputs[2], |
62 const CropRect* cropRect); | 48 const CropRect* cropRect); |
63 void flatten(SkWriteBuffer&) const override; | 49 void flatten(SkWriteBuffer&) const override; |
64 | 50 |
65 private: | 51 private: |
66 ChannelSelectorType fXChannelSelector; | 52 ChannelSelectorType fXChannelSelector; |
67 ChannelSelectorType fYChannelSelector; | 53 ChannelSelectorType fYChannelSelector; |
68 SkScalar fScale; | 54 SkScalar fScale; |
69 typedef SkImageFilter INHERITED; | 55 typedef SkImageFilter INHERITED; |
70 const SkImageFilter* getDisplacementInput() const { return getInput(0); } | 56 const SkImageFilter* getDisplacementInput() const { return getInput(0); } |
71 const SkImageFilter* getColorInput() const { return getInput(1); } | 57 const SkImageFilter* getColorInput() const { return getInput(1); } |
72 }; | 58 }; |
73 | 59 |
74 #endif | 60 #endif |
OLD | NEW |