SkDisplacementMapEffect.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  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. #ifndef SkDisplacementMapEffect_DEFINED
  8. #define SkDisplacementMapEffect_DEFINED
  9. #include "include/core/SkImageFilter.h"
  10. class SK_API SkDisplacementMapEffect : public SkImageFilter {
  11. public:
  12. enum ChannelSelectorType {
  13. kUnknown_ChannelSelectorType,
  14. kR_ChannelSelectorType,
  15. kG_ChannelSelectorType,
  16. kB_ChannelSelectorType,
  17. kA_ChannelSelectorType,
  18. kLast_ChannelSelectorType = kA_ChannelSelectorType
  19. };
  20. ~SkDisplacementMapEffect() override;
  21. static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
  22. ChannelSelectorType yChannelSelector,
  23. SkScalar scale,
  24. sk_sp<SkImageFilter> displacement,
  25. sk_sp<SkImageFilter> color,
  26. const CropRect* cropRect = nullptr);
  27. SkRect computeFastBounds(const SkRect& src) const override;
  28. virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
  29. MapDirection, const SkIRect* inputRect) const override;
  30. SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
  31. MapDirection, const SkIRect* inputRect) const override;
  32. protected:
  33. sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
  34. SkIPoint* offset) const override;
  35. SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
  36. ChannelSelectorType yChannelSelector,
  37. SkScalar scale, sk_sp<SkImageFilter> inputs[2],
  38. const CropRect* cropRect);
  39. void flatten(SkWriteBuffer&) const override;
  40. private:
  41. SK_FLATTENABLE_HOOKS(SkDisplacementMapEffect)
  42. ChannelSelectorType fXChannelSelector;
  43. ChannelSelectorType fYChannelSelector;
  44. SkScalar fScale;
  45. typedef SkImageFilter INHERITED;
  46. const SkImageFilter* getDisplacementInput() const { return getInput(0); }
  47. const SkImageFilter* getColorInput() const { return getInput(1); }
  48. };
  49. #endif