Skia
2DGraphicsLibrary
 All Classes Namespaces 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 
51 #ifdef SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
52 
60  static sk_sp<SkMaskFilter> MakeEmboss(SkScalar blurSigma, const SkScalar direction[3],
61  SkScalar ambient, SkScalar specular);
62 #endif
63 
64  static const int kMaxDivisions = 6;
65 
66  // This method computes all the parameters for drawing a partially occluded nine-patched
67  // blurred rrect mask:
68  // rrectToDraw - the integerized rrect to draw in the mask
69  // widthHeight - how large to make the mask (rrectToDraw will be centered in this coord sys)
70  // rectXs, rectYs - the x & y coordinates of the covering geometry lattice
71  // texXs, texYs - the texture coordinate at each point in rectXs & rectYs
72  // numXs, numYs - number of coordinates in the x & y directions
73  // skipMask - bit mask that contains a 1-bit whenever one of the cells is occluded
74  // It returns true if 'devRRect' is nine-patchable
75  static bool ComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRect,
76  const SkRect& occluder,
77  SkScalar sigma, SkScalar xformedSigma,
78  SkRRect* rrectToDraw,
79  SkISize* widthHeight,
80  SkScalar rectXs[kMaxDivisions],
81  SkScalar rectYs[kMaxDivisions],
82  SkScalar texXs[kMaxDivisions],
83  SkScalar texYs[kMaxDivisions],
84  int* numXs, int* numYs, uint32_t* skipMask);
85 
86  SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
87 
88 private:
89  SkBlurMaskFilter(); // can't be instantiated
90 };
91 
92 #endif
The SkRRect class represents a rounded rect with a potentially different radii for each corner...
Definition: SkRRect.h:47
Definition: SkSize.h:13
BlurFlags
Definition: SkBlurMaskFilter.h:24
Definition: SkRect.h:404
Definition: SkBlurMaskFilter.h:16