SkEmbossMaskFilter.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2006 The Android Open Source Project
  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 SkEmbossMaskFilter_DEFINED
  8. #define SkEmbossMaskFilter_DEFINED
  9. #include "src/core/SkMaskFilterBase.h"
  10. /** \class SkEmbossMaskFilter
  11. This mask filter creates a 3D emboss look, by specifying a light and blur amount.
  12. */
  13. class SK_API SkEmbossMaskFilter : public SkMaskFilterBase {
  14. public:
  15. struct Light {
  16. SkScalar fDirection[3]; // x,y,z
  17. uint16_t fPad;
  18. uint8_t fAmbient;
  19. uint8_t fSpecular; // exponent, 4.4 right now
  20. };
  21. static sk_sp<SkMaskFilter> Make(SkScalar blurSigma, const Light& light);
  22. // overrides from SkMaskFilter
  23. // This method is not exported to java.
  24. SkMask::Format getFormat() const override;
  25. // This method is not exported to java.
  26. bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
  27. SkIPoint* margin) const override;
  28. protected:
  29. SkEmbossMaskFilter(SkScalar blurSigma, const Light& light);
  30. void flatten(SkWriteBuffer&) const override;
  31. private:
  32. SK_FLATTENABLE_HOOKS(SkEmbossMaskFilter)
  33. Light fLight;
  34. SkScalar fBlurSigma;
  35. typedef SkMaskFilter INHERITED;
  36. };
  37. #endif