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 #include "SkBitmap.h" | |
13 | 12 |
14 class SK_API SkDisplacementMapEffect : public SkImageFilter { | 13 class SK_API SkDisplacementMapEffect : public SkImageFilter { |
15 public: | 14 public: |
16 enum ChannelSelectorType { | 15 enum ChannelSelectorType { |
17 kUnknown_ChannelSelectorType, | 16 kUnknown_ChannelSelectorType, |
18 kR_ChannelSelectorType, | 17 kR_ChannelSelectorType, |
19 kG_ChannelSelectorType, | 18 kG_ChannelSelectorType, |
20 kB_ChannelSelectorType, | 19 kB_ChannelSelectorType, |
21 kA_ChannelSelectorType | 20 kA_ChannelSelectorType |
22 }; | 21 }; |
23 | 22 |
24 ~SkDisplacementMapEffect(); | 23 ~SkDisplacementMapEffect(); |
25 | 24 |
26 static SkImageFilter* Create(ChannelSelectorType xChannelSelector, | 25 static SkImageFilter* Create(ChannelSelectorType xChannelSelector, |
27 ChannelSelectorType yChannelSelector, | 26 ChannelSelectorType yChannelSelector, |
28 SkScalar scale, SkImageFilter* displacement, | 27 SkScalar scale, SkImageFilter* displacement, |
29 SkImageFilter* color = NULL, | 28 SkImageFilter* color = NULL, |
30 const CropRect* cropRect = NULL); | 29 const CropRect* cropRect = NULL); |
31 | 30 |
32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) | 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) |
33 | 32 |
34 bool onFilterImageDeprecated(Proxy* proxy, | |
35 const SkBitmap& src, | |
36 const Context& ctx, | |
37 SkBitmap* dst, | |
38 SkIPoint* offset) const override; | |
39 SkRect computeFastBounds(const SkRect& src) const override; | 33 SkRect computeFastBounds(const SkRect& src) const override; |
40 | 34 |
41 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, | 35 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, |
42 MapDirection) const override; | 36 MapDirection) const override; |
43 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; | 37 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) co
nst override; |
44 | 38 |
45 #if SK_SUPPORT_GPU | |
46 bool canFilterImageGPU() const override { return true; } | |
47 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Conte
xt& ctx, | |
48 SkBitmap* result, SkIPoint* offset) const overri
de; | |
49 #endif | |
50 | |
51 SK_TO_STRING_OVERRIDE() | 39 SK_TO_STRING_OVERRIDE() |
52 | 40 |
53 protected: | 41 protected: |
| 42 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 43 SkIPoint* offset) const override; |
| 44 |
54 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, | 45 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, |
55 ChannelSelectorType yChannelSelector, | 46 ChannelSelectorType yChannelSelector, |
56 SkScalar scale, SkImageFilter* inputs[2], | 47 SkScalar scale, SkImageFilter* inputs[2], |
57 const CropRect* cropRect); | 48 const CropRect* cropRect); |
58 void flatten(SkWriteBuffer&) const override; | 49 void flatten(SkWriteBuffer&) const override; |
59 | 50 |
60 private: | 51 private: |
61 ChannelSelectorType fXChannelSelector; | 52 ChannelSelectorType fXChannelSelector; |
62 ChannelSelectorType fYChannelSelector; | 53 ChannelSelectorType fYChannelSelector; |
63 SkScalar fScale; | 54 SkScalar fScale; |
64 typedef SkImageFilter INHERITED; | 55 typedef SkImageFilter INHERITED; |
65 const SkImageFilter* getDisplacementInput() const { return getInput(0); } | 56 const SkImageFilter* getDisplacementInput() const { return getInput(0); } |
66 const SkImageFilter* getColorInput() const { return getInput(1); } | 57 const SkImageFilter* getColorInput() const { return getInput(1); } |
67 }; | 58 }; |
68 | 59 |
69 #endif | 60 #endif |
OLD | NEW |