SkBlurMaskFilter.h revision 6fcbfcead5dc1b61fa5b4c139a1a3714e8c58091
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 15class SK_API SkBlurMaskFilter { 16public: 17 enum BlurStyle { 18 kNormal_BlurStyle, //!< fuzzy inside and outside 19 kSolid_BlurStyle, //!< solid inside, fuzzy outside 20 kOuter_BlurStyle, //!< nothing inside, fuzzy outside 21 kInner_BlurStyle, //!< fuzzy inside, nothing outside 22 23 kBlurStyleCount 24 }; 25 26 enum BlurFlags { 27 kNone_BlurFlag = 0x00, 28 /** The blur layer's radius is not affected by transforms */ 29 kIgnoreTransform_BlurFlag = 0x01, 30 /** Use a smother, higher qulity blur algorithm */ 31 kHighQuality_BlurFlag = 0x02, 32 /** mask for all blur flags */ 33 kAll_BlurFlag = 0x03 34 }; 35 36 /** 37 * DEPRECATED - radius-based 38 */ 39 static SkMaskFilter* Create(SkScalar radius, BlurStyle style, 40 uint32_t flags = kNone_BlurFlag); 41 42 /** Create a blur maskfilter. 43 @param style The BlurStyle to use 44 @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 45 @param flags Flags to use - defaults to none 46 @return The new blur maskfilter 47 */ 48 static SkMaskFilter* Create(BlurStyle style, SkScalar sigma, 49 uint32_t flags = kNone_BlurFlag); 50 51 /** Create an emboss maskfilter 52 @param blurSigma standard deviation of the Gaussian blur to apply 53 before applying lighting (e.g. 3) 54 @param direction array of 3 scalars [x, y, z] specifying the direction of the light source 55 @param ambient 0...1 amount of ambient light 56 @param specular coefficient for specular highlights (e.g. 8) 57 @return the emboss maskfilter 58 */ 59 static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3], 60 SkScalar ambient, SkScalar specular); 61 62 // DEPRECATED - radius-based 63 static SkMaskFilter* CreateEmboss(const SkScalar direction[3], 64 SkScalar ambient, SkScalar specular, 65 SkScalar blurRadius); 66 67 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 68 69private: 70 SkBlurMaskFilter(); // can't be instantiated 71}; 72 73#endif 74