blob: c01197c5d76e64cae521075842f6a766028d8a0c [file] [log] [blame]
sugoi@google.com781cc762013-01-15 15:40:19 +00001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkImageFilter.h"
sugoi@google.com781cc762013-01-15 15:40:19 +000012
13class SK_API SkDisplacementMapEffect : public SkImageFilter {
14public:
15 enum ChannelSelectorType {
16 kUnknown_ChannelSelectorType,
17 kR_ChannelSelectorType,
18 kG_ChannelSelectorType,
19 kB_ChannelSelectorType,
Robert Phillipsb0ae5662018-01-24 14:39:38 -050020 kA_ChannelSelectorType,
21
22 kLast_ChannelSelectorType = kA_ChannelSelectorType
sugoi@google.com781cc762013-01-15 15:40:19 +000023 };
24
robertphillipsbfe11fc2016-04-15 07:17:36 -070025 ~SkDisplacementMapEffect() override;
sugoi@google.com781cc762013-01-15 15:40:19 +000026
robertphillipsbfe11fc2016-04-15 07:17:36 -070027 static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
28 ChannelSelectorType yChannelSelector,
29 SkScalar scale,
30 sk_sp<SkImageFilter> displacement,
31 sk_sp<SkImageFilter> color,
32 const CropRect* cropRect = nullptr);
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000033
senorblancoe5e79842016-03-21 14:51:59 -070034 SkRect computeFastBounds(const SkRect& src) const override;
senorblanco@chromium.org336d1d72014-01-27 21:03:17 +000035
Robert Phillips12078432018-05-17 11:17:39 -040036 virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
37 MapDirection, const SkIRect* inputRect) const override;
Robert Phillips12078432018-05-17 11:17:39 -040038 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
39 MapDirection, const SkIRect* inputRect) const override;
senorblanco@chromium.orgc4b12f12014-02-05 17:51:22 +000040
sugoi@google.com781cc762013-01-15 15:40:19 +000041protected:
robertphillipse6277de2016-04-11 07:23:34 -070042 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
43 SkIPoint* offset) const override;
44
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000045 SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
46 ChannelSelectorType yChannelSelector,
robertphillipsbfe11fc2016-04-15 07:17:36 -070047 SkScalar scale, sk_sp<SkImageFilter> inputs[2],
senorblanco24e06d52015-03-18 12:11:33 -070048 const CropRect* cropRect);
mtklein36352bf2015-03-25 18:17:31 -070049 void flatten(SkWriteBuffer&) const override;
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000050
sugoi@google.com781cc762013-01-15 15:40:19 +000051private:
Mike Klein4fee3232018-10-18 17:27:16 -040052 SK_FLATTENABLE_HOOKS(SkDisplacementMapEffect)
Cary Clark4dc5a452018-05-21 11:56:57 -040053
sugoi@google.com781cc762013-01-15 15:40:19 +000054 ChannelSelectorType fXChannelSelector;
55 ChannelSelectorType fYChannelSelector;
56 SkScalar fScale;
57 typedef SkImageFilter INHERITED;
senorblanco@chromium.org336d1d72014-01-27 21:03:17 +000058 const SkImageFilter* getDisplacementInput() const { return getInput(0); }
59 const SkImageFilter* getColorInput() const { return getInput(1); }
sugoi@google.com781cc762013-01-15 15:40:19 +000060};
61
62#endif