sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 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 SkDisplacementMapEffect_DEFINED |
| 9 | #define SkDisplacementMapEffect_DEFINED |
| 10 | |
| 11 | #include "SkImageFilter.h" |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 12 | |
| 13 | class SK_API SkDisplacementMapEffect : public SkImageFilter { |
| 14 | public: |
| 15 | enum ChannelSelectorType { |
| 16 | kUnknown_ChannelSelectorType, |
| 17 | kR_ChannelSelectorType, |
| 18 | kG_ChannelSelectorType, |
| 19 | kB_ChannelSelectorType, |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 20 | kA_ChannelSelectorType |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
robertphillips | bfe11fc | 2016-04-15 07:17:36 -0700 | [diff] [blame^] | 23 | ~SkDisplacementMapEffect() override; |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 24 | |
robertphillips | bfe11fc | 2016-04-15 07:17:36 -0700 | [diff] [blame^] | 25 | static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector, |
| 26 | ChannelSelectorType yChannelSelector, |
| 27 | SkScalar scale, |
| 28 | sk_sp<SkImageFilter> displacement, |
| 29 | sk_sp<SkImageFilter> color, |
| 30 | const CropRect* cropRect = nullptr); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 31 | |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 32 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect) |
| 33 | |
senorblanco | e5e7984 | 2016-03-21 14:51:59 -0700 | [diff] [blame] | 34 | SkRect computeFastBounds(const SkRect& src) const override; |
senorblanco@chromium.org | 336d1d7 | 2014-01-27 21:03:17 +0000 | [diff] [blame] | 35 | |
senorblanco | e5e7984 | 2016-03-21 14:51:59 -0700 | [diff] [blame] | 36 | virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, |
| 37 | MapDirection) const override; |
| 38 | SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override; |
senorblanco@chromium.org | c4b12f1 | 2014-02-05 17:51:22 +0000 | [diff] [blame] | 39 | |
robertphillips | f3f5bad | 2014-12-19 13:49:15 -0800 | [diff] [blame] | 40 | SK_TO_STRING_OVERRIDE() |
| 41 | |
robertphillips | bfe11fc | 2016-04-15 07:17:36 -0700 | [diff] [blame^] | 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 | |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 55 | protected: |
robertphillips | e6277de | 2016-04-11 07:23:34 -0700 | [diff] [blame] | 56 | sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 57 | SkIPoint* offset) const override; |
| 58 | |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 59 | SkDisplacementMapEffect(ChannelSelectorType xChannelSelector, |
| 60 | ChannelSelectorType yChannelSelector, |
robertphillips | bfe11fc | 2016-04-15 07:17:36 -0700 | [diff] [blame^] | 61 | SkScalar scale, sk_sp<SkImageFilter> inputs[2], |
senorblanco | 24e06d5 | 2015-03-18 12:11:33 -0700 | [diff] [blame] | 62 | const CropRect* cropRect); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 63 | void flatten(SkWriteBuffer&) const override; |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 64 | |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 65 | private: |
| 66 | ChannelSelectorType fXChannelSelector; |
| 67 | ChannelSelectorType fYChannelSelector; |
| 68 | SkScalar fScale; |
| 69 | typedef SkImageFilter INHERITED; |
senorblanco@chromium.org | 336d1d7 | 2014-01-27 21:03:17 +0000 | [diff] [blame] | 70 | const SkImageFilter* getDisplacementInput() const { return getInput(0); } |
| 71 | const SkImageFilter* getColorInput() const { return getInput(1); } |
sugoi@google.com | 781cc76 | 2013-01-15 15:40:19 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #endif |