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