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 SkBlurMaskFilter_DEFINED 9 #define SkBlurMaskFilter_DEFINED 10 11 // we include this since our callers will need to at least be able to ref/unref 12 #include "SkMaskFilter.h" 13 #include "SkScalar.h" 14 #include "SkBlurTypes.h" 15 16 class SK_API SkBlurMaskFilter { 17 public: 18 /** 19 * If radius > 0, return the corresponding sigma, else return 0. Use this to convert from the 20 * (legacy) idea of specify the blur "radius" to the standard notion of specifying its sigma. 21 */ 22 static SkScalar ConvertRadiusToSigma(SkScalar radius); 23 24 enum BlurFlags { 25 kNone_BlurFlag = 0x00, 26 /** The blur layer's radius is not affected by transforms */ 27 kIgnoreTransform_BlurFlag = 0x01, 28 /** Use a smother, higher qulity blur algorithm */ 29 kHighQuality_BlurFlag = 0x02, 30 /** mask for all blur flags */ 31 kAll_BlurFlag = 0x03 32 }; 33 34 /** Create a blur maskfilter. 35 * @param style The SkBlurStyle to use 36 * @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 37 * @param flags Flags to use - defaults to none 38 * @return The new blur maskfilter 39 */ 40 static SkMaskFilter* Create(SkBlurStyle style, SkScalar sigma, uint32_t flags = kNone_BlurFlag); 41 42 /** Create an emboss maskfilter 43 @param blurSigma standard deviation of the Gaussian blur to apply 44 before applying lighting (e.g. 3) 45 @param direction array of 3 scalars [x, y, z] specifying the direction of the light source 46 @param ambient 0...1 amount of ambient light 47 @param specular coefficient for specular highlights (e.g. 8) 48 @return the emboss maskfilter 49 */ 50 static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3], 51 SkScalar ambient, SkScalar specular); 52 53 SK_ATTR_DEPRECATED("use sigma version") 54 static SkMaskFilter* CreateEmboss(const SkScalar direction[3], 55 SkScalar ambient, SkScalar specular, 56 SkScalar blurRadius); 57 58 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 59 60 private: 61 SkBlurMaskFilter(); // can't be instantiated 62 }; 63 64 #endif 65