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"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
|
|
|
|
class SK_API SkDisplacementMapEffect : public SkImageFilter {
|
|
|
|
public:
|
|
|
|
enum ChannelSelectorType {
|
|
|
|
kUnknown_ChannelSelectorType,
|
|
|
|
kR_ChannelSelectorType,
|
|
|
|
kG_ChannelSelectorType,
|
|
|
|
kB_ChannelSelectorType,
|
2014-03-10 10:51:58 +00:00
|
|
|
kA_ChannelSelectorType
|
2013-01-15 15:40:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
~SkDisplacementMapEffect();
|
|
|
|
|
2014-03-10 10:51:58 +00:00
|
|
|
static SkDisplacementMapEffect* Create(ChannelSelectorType xChannelSelector,
|
|
|
|
ChannelSelectorType yChannelSelector,
|
|
|
|
SkScalar scale, SkImageFilter* displacement,
|
|
|
|
SkImageFilter* color = NULL,
|
2015-03-18 19:11:33 +00:00
|
|
|
const CropRect* cropRect = NULL);
|
2014-03-10 10:51:58 +00:00
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
|
|
|
|
|
|
|
|
virtual bool onFilterImage(Proxy* proxy,
|
|
|
|
const SkBitmap& src,
|
2014-03-14 15:44:01 +00:00
|
|
|
const Context& ctx,
|
2013-01-15 15:40:19 +00:00
|
|
|
SkBitmap* dst,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkIPoint* offset) const override;
|
|
|
|
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
|
2014-01-27 21:03:17 +00:00
|
|
|
|
2014-02-05 17:51:22 +00:00
|
|
|
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkIRect* dst) const override;
|
2014-02-05 17:51:22 +00:00
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-03-26 01:17:31 +00:00
|
|
|
bool canFilterImageGPU() const override { return true; }
|
2014-03-14 15:44:01 +00:00
|
|
|
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkBitmap* result, SkIPoint* offset) const override;
|
2013-01-15 15:40:19 +00:00
|
|
|
#endif
|
|
|
|
|
2014-12-19 21:49:15 +00:00
|
|
|
SK_TO_STRING_OVERRIDE()
|
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
protected:
|
2014-03-10 10:51:58 +00:00
|
|
|
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
|
|
|
|
ChannelSelectorType yChannelSelector,
|
2014-07-08 16:16:22 +00:00
|
|
|
SkScalar scale, 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
|