2013-01-15 15:40:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkDisplacementMapEffect_DEFINED
|
|
|
|
#define SkDisplacementMapEffect_DEFINED
|
|
|
|
|
|
|
|
#include "SkImageFilter.h"
|
|
|
|
|
|
|
|
class SK_API SkDisplacementMapEffect : public SkImageFilter {
|
|
|
|
public:
|
|
|
|
enum ChannelSelectorType {
|
|
|
|
kUnknown_ChannelSelectorType,
|
|
|
|
kR_ChannelSelectorType,
|
|
|
|
kG_ChannelSelectorType,
|
|
|
|
kB_ChannelSelectorType,
|
2018-01-24 19:39:38 +00:00
|
|
|
kA_ChannelSelectorType,
|
|
|
|
|
|
|
|
kLast_ChannelSelectorType = kA_ChannelSelectorType
|
2013-01-15 15:40:19 +00:00
|
|
|
};
|
|
|
|
|
2016-04-15 14:17:36 +00:00
|
|
|
~SkDisplacementMapEffect() override;
|
2013-01-15 15:40:19 +00:00
|
|
|
|
2016-04-15 14:17:36 +00:00
|
|
|
static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
|
|
|
|
ChannelSelectorType yChannelSelector,
|
|
|
|
SkScalar scale,
|
|
|
|
sk_sp<SkImageFilter> displacement,
|
|
|
|
sk_sp<SkImageFilter> color,
|
|
|
|
const CropRect* cropRect = nullptr);
|
2014-03-10 10:51:58 +00:00
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
|
|
|
|
|
2016-03-21 21:51:59 +00:00
|
|
|
SkRect computeFastBounds(const SkRect& src) const override;
|
2014-01-27 21:03:17 +00:00
|
|
|
|
2016-03-21 21:51:59 +00:00
|
|
|
virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&,
|
|
|
|
MapDirection) const override;
|
2017-04-10 20:35:33 +00:00
|
|
|
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
|
2016-03-21 21:51:59 +00:00
|
|
|
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
|
2014-02-05 17:51:22 +00:00
|
|
|
|
2014-12-19 21:49:15 +00:00
|
|
|
SK_TO_STRING_OVERRIDE()
|
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
protected:
|
2016-04-11 14:23:34 +00:00
|
|
|
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
|
|
|
|
SkIPoint* offset) const override;
|
|
|
|
|
2014-03-10 10:51:58 +00:00
|
|
|
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
|
|
|
|
ChannelSelectorType yChannelSelector,
|
2016-04-15 14:17:36 +00:00
|
|
|
SkScalar scale, sk_sp<SkImageFilter> inputs[2],
|
2015-03-18 19:11:33 +00:00
|
|
|
const CropRect* cropRect);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2014-03-10 10:51:58 +00:00
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
private:
|
|
|
|
ChannelSelectorType fXChannelSelector;
|
|
|
|
ChannelSelectorType fYChannelSelector;
|
|
|
|
SkScalar fScale;
|
|
|
|
typedef SkImageFilter INHERITED;
|
2014-01-27 21:03:17 +00:00
|
|
|
const SkImageFilter* getDisplacementInput() const { return getInput(0); }
|
|
|
|
const SkImageFilter* getColorInput() const { return getInput(1); }
|
2013-01-15 15:40:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|