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,
|
2014-08-26 19:27:12 +00:00
|
|
|
const CropRect* cropRect = NULL,
|
|
|
|
uint32_t uniqueID = 0);
|
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,
|
2014-02-05 22:32:02 +00:00
|
|
|
SkIPoint* offset) const SK_OVERRIDE;
|
2015-01-09 18:06:39 +00:00
|
|
|
void computeFastBounds(const SkRect& src, SkRect* dst) const SK_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&,
|
|
|
|
SkIRect* dst) const SK_OVERRIDE;
|
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-01-09 18:06:39 +00:00
|
|
|
bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
2014-03-14 15:44:01 +00:00
|
|
|
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
2014-02-05 22:32:02 +00:00
|
|
|
SkBitmap* result, SkIPoint* offset) const SK_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],
|
2014-08-26 19:27:12 +00:00
|
|
|
const CropRect* cropRect,
|
|
|
|
uint32_t uniqueID);
|
2015-01-09 18:06:39 +00:00
|
|
|
void flatten(SkWriteBuffer&) const SK_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
|