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,
|
|
|
|
kA_ChannelSelectorType,
|
|
|
|
kKeyBits = 3 // Max value is 4, so 3 bits are required at most
|
|
|
|
};
|
|
|
|
|
2013-07-10 21:22:18 +00:00
|
|
|
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
|
|
|
|
ChannelSelectorType yChannelSelector,
|
|
|
|
SkScalar scale, SkImageFilter* displacement,
|
2013-10-15 19:02:43 +00:00
|
|
|
SkImageFilter* color = NULL,
|
|
|
|
const CropRect* cropRect = NULL);
|
2013-01-15 15:40:19 +00:00
|
|
|
|
|
|
|
~SkDisplacementMapEffect();
|
|
|
|
|
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
|
|
|
|
|
|
|
|
virtual bool onFilterImage(Proxy* proxy,
|
|
|
|
const SkBitmap& src,
|
|
|
|
const SkMatrix& ctm,
|
|
|
|
SkBitmap* dst,
|
|
|
|
SkIPoint* offset) SK_OVERRIDE;
|
2014-01-27 21:03:17 +00:00
|
|
|
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
|
|
|
|
|
2013-01-15 15:40:19 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
2013-08-05 16:53:50 +00:00
|
|
|
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
|
|
|
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
|
2013-01-15 15:40:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2014-01-30 18:58:24 +00:00
|
|
|
explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
|
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2013-01-15 15:40:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ChannelSelectorType fXChannelSelector;
|
|
|
|
ChannelSelectorType fYChannelSelector;
|
|
|
|
SkScalar fScale;
|
|
|
|
typedef SkImageFilter INHERITED;
|
|
|
|
SkImageFilter* getDisplacementInput() { return getInput(0); }
|
|
|
|
SkImageFilter* getColorInput() { return getInput(1); }
|
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
|