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 8 #ifndef SkEmbossMaskFilter_DEFINED 9 #define SkEmbossMaskFilter_DEFINED 10 11 #include "include/core/SkFlattenable.h" 12 #include "include/core/SkMaskFilter.h" 13 #include "include/core/SkRefCnt.h" 14 #include "include/core/SkScalar.h" 15 #include "src/core/SkMask.h" 16 #include "src/core/SkMaskFilterBase.h" 17 18 #include <cstdint> 19 20 class SkMatrix; 21 class SkReadBuffer; 22 class SkWriteBuffer; 23 struct SkIPoint; 24 25 /** \class SkEmbossMaskFilter 26 27 This mask filter creates a 3D emboss look, by specifying a light and blur amount. 28 */ 29 class SkEmbossMaskFilter : public SkMaskFilterBase { 30 public: 31 struct Light { 32 SkScalar fDirection[3]; // x,y,z 33 uint16_t fPad; 34 uint8_t fAmbient; 35 uint8_t fSpecular; // exponent, 4.4 right now 36 }; 37 38 static sk_sp<SkMaskFilter> Make(SkScalar blurSigma, const Light& light); 39 40 // overrides from SkMaskFilter 41 // This method is not exported to java. 42 SkMask::Format getFormat() const override; 43 // This method is not exported to java. 44 bool filterMask(SkMaskBuilder* dst, const SkMask& src, const SkMatrix&, 45 SkIPoint* margin) const override; type()46 SkMaskFilterBase::Type type() const override { return SkMaskFilterBase::Type::kEmboss; } 47 48 protected: 49 SkEmbossMaskFilter(SkScalar blurSigma, const Light& light); 50 void flatten(SkWriteBuffer&) const override; 51 52 private: 53 SK_FLATTENABLE_HOOKS(SkEmbossMaskFilter) 54 55 Light fLight; 56 SkScalar fBlurSigma; 57 58 using INHERITED = SkMaskFilter; 59 }; 60 61 #endif 62