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 SkMaskFilter_DEFINED 9 #define SkMaskFilter_DEFINED 10 11 #include "include/core/SkBlurTypes.h" 12 #include "include/core/SkCoverageMode.h" 13 #include "include/core/SkFlattenable.h" 14 #include "include/core/SkScalar.h" 15 16 class SkMatrix; 17 struct SkRect; 18 19 /** \class SkMaskFilter 20 21 SkMaskFilter is the base class for object that perform transformations on 22 the mask before drawing it. An example subclass is Blur. 23 */ 24 class SK_API SkMaskFilter : public SkFlattenable { 25 public: 26 /** Create a blur maskfilter. 27 * @param style The SkBlurStyle to use 28 * @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 29 * @param respectCTM if true the blur's sigma is modified by the CTM. 30 * @return The new blur maskfilter 31 */ 32 static sk_sp<SkMaskFilter> MakeBlur(SkBlurStyle style, SkScalar sigma, 33 bool respectCTM = true); 34 35 /** 36 * Returns the approximate bounds that would result from filtering the src rect. 37 * The actual result may be different, but it should be contained within the 38 * returned bounds. 39 */ 40 SkRect approximateFilteredBounds(const SkRect& src) const; 41 42 static sk_sp<SkMaskFilter> Deserialize(const void* data, size_t size, 43 const SkDeserialProcs* procs = nullptr); 44 45 private: 46 static void RegisterFlattenables(); 47 friend class SkFlattenable; 48 }; 49 50 #endif 51