Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkBlurMaskFilter.h
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:
22  static SkScalar ConvertRadiusToSigma(SkScalar radius);
23 
24  enum BlurFlags {
25  kNone_BlurFlag = 0x00,
27  kIgnoreTransform_BlurFlag = 0x01,
29  kHighQuality_BlurFlag = 0x02,
31  kAll_BlurFlag = 0x03
32  };
33 
43  static sk_sp<SkMaskFilter> Make(SkBlurStyle style, SkScalar sigma,
44  const SkRect& occluder, uint32_t flags = kNone_BlurFlag);
45 
46  static sk_sp<SkMaskFilter> Make(SkBlurStyle style, SkScalar sigma,
47  uint32_t flags = kNone_BlurFlag) {
48  return Make(style, sigma, SkRect::MakeEmpty(), flags);
49  }
50 
59  static sk_sp<SkMaskFilter> MakeEmboss(SkScalar blurSigma, const SkScalar direction[3],
60  SkScalar ambient, SkScalar specular);
61 
62 #ifdef SK_SUPPORT_LEGACY_MASKFILTER_PTR
63  static SkMaskFilter* Create(SkBlurStyle style, SkScalar sigma, uint32_t flags = kNone_BlurFlag){
64  return Make(style, sigma, flags).release();
65  }
66  static SkMaskFilter* CreateEmboss(SkScalar blurSigma, const SkScalar direction[3],
67  SkScalar ambient, SkScalar specular) {
68  return MakeEmboss(blurSigma, direction, ambient, specular).release();
69  }
70  SK_ATTR_DEPRECATED("use sigma version")
71  static SkMaskFilter* CreateEmboss(const SkScalar direction[3],
72  SkScalar ambient, SkScalar specular,
73  SkScalar blurRadius);
74 #endif
75 
76  static const int kMaxDivisions = 6;
77 
78  // This method computes all the parameters for drawing a partially occluded nine-patched
79  // blurred rrect mask:
80  // rrectToDraw - the integerized rrect to draw in the mask
81  // widthHeight - how large to make the mask (rrectToDraw will be centered in this coord sys)
82  // rectXs, rectYs - the x & y coordinates of the covering geometry lattice
83  // texXs, texYs - the texture coordinate at each point in rectXs & rectYs
84  // numXs, numYs - number of coordinates in the x & y directions
85  // skipMask - bit mask that contains a 1-bit whenever one of the cells is occluded
86  // It returns true if 'devRRect' is nine-patchable
87  static bool ComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRect,
88  const SkRect& occluder,
89  SkScalar sigma, SkScalar xformedSigma,
90  SkRRect* rrectToDraw,
91  SkISize* widthHeight,
92  SkScalar rectXs[kMaxDivisions],
93  SkScalar rectYs[kMaxDivisions],
94  SkScalar texXs[kMaxDivisions],
95  SkScalar texYs[kMaxDivisions],
96  int* numXs, int* numYs, uint32_t* skipMask);
97 
98  SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
99 
100 private:
101  SkBlurMaskFilter(); // can't be instantiated
102 };
103 
104 #endif
The SkRRect class represents a rounded rect with a potentially different radii for each corner...
Definition: SkRRect.h:48
SkMaskFilter is the base class for object that perform transformations on an alpha-channel mask befor...
Definition: SkMaskFilter.h:44
BlurFlags
Definition: SkBlurMaskFilter.h:24
Definition: SkRect.h:390
Definition: SkBlurMaskFilter.h:16