OLD | NEW |
---|---|
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkBlurMask_DEFINED | 8 #ifndef SkBlurMask_DEFINED |
11 #define SkBlurMask_DEFINED | 9 #define SkBlurMask_DEFINED |
12 | 10 |
11 #include "SkBlurTypes.h" | |
13 #include "SkShader.h" | 12 #include "SkShader.h" |
14 #include "SkMask.h" | 13 #include "SkMask.h" |
15 #include "SkRRect.h" | 14 #include "SkRRect.h" |
16 | 15 |
17 class SkBlurMask { | 16 class SkBlurMask { |
18 public: | 17 public: |
19 enum Style { | 18 static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, SkBlurS tyle, |
20 kNormal_Style, //!< fuzzy inside and outside | |
scroggo
2014/04/28 15:47:44
+1 to removing duplicate code!
| |
21 kSolid_Style, //!< solid inside, fuzzy outside | |
22 kOuter_Style, //!< nothing inside, fuzzy outside | |
23 kInner_Style, //!< fuzzy inside, nothing outside | |
24 | |
25 kStyleCount | |
26 }; | |
27 | |
28 enum Quality { | |
29 kLow_Quality, //!< box blur | |
30 kHigh_Quality //!< three pass box blur (similar to gaussian) | |
31 }; | |
32 | |
33 static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, | |
34 Style style, | |
35 SkIPoint *margin = NULL, | 19 SkIPoint *margin = NULL, |
36 SkMask::CreateMode createMode = | 20 SkMask::CreateMode createMode = |
37 SkMask::kComputeBoundsAndRenderI mage_CreateMode); | 21 SkMask::kComputeBoundsAndRenderI mage_CreateMode); |
38 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, | 22 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlu rStyle, |
39 Style style, | |
40 SkIPoint *margin = NULL, | 23 SkIPoint *margin = NULL, |
41 SkMask::CreateMode createMode = | 24 SkMask::CreateMode createMode = |
42 SkMask::kComputeBoundsAndRenderI mage_CreateMode); | 25 SkMask::kComputeBoundsAndRenderI mage_CreateMode); |
43 static bool BoxBlur(SkMask* dst, const SkMask& src, | 26 static bool BoxBlur(SkMask* dst, const SkMask& src, SkScalar sigma, SkBlurSt yle, SkBlurQuality, |
44 SkScalar sigma, Style style, Quality quality, | |
45 SkIPoint* margin = NULL); | 27 SkIPoint* margin = NULL); |
46 | 28 |
47 // the "ground truth" blur does a gaussian convolution; it's slow | 29 // the "ground truth" blur does a gaussian convolution; it's slow |
48 // but useful for comparison purposes. | 30 // but useful for comparison purposes. |
49 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, | 31 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, SkBlurStyle, |
50 Style style, | |
51 SkIPoint* margin = NULL); | 32 SkIPoint* margin = NULL); |
52 | 33 |
53 static SkScalar ConvertRadiusToSigma(SkScalar radius); | 34 static SkScalar ConvertRadiusToSigma(SkScalar radius); |
54 | 35 |
55 /* Helper functions for analytic rectangle blurs */ | 36 /* Helper functions for analytic rectangle blurs */ |
56 | 37 |
57 /** Look up the intensity of the (one dimnensional) blurred half-plane. | 38 /** Look up the intensity of the (one dimnensional) blurred half-plane. |
58 @param profile The precomputed 1D blur profile; memory allocated by and managed by | 39 @param profile The precomputed 1D blur profile; memory allocated by and managed by |
59 ComputeBlurProfile below. | 40 ComputeBlurProfile below. |
60 @param loc the location to look up; The lookup will clamp invalid inputs , but | 41 @param loc the location to look up; The lookup will clamp invalid inputs , but |
(...skipping 21 matching lines...) Expand all Loading... | |
82 */ | 63 */ |
83 | 64 |
84 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, | 65 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, |
85 unsigned int width, SkScalar sigma); | 66 unsigned int width, SkScalar sigma); |
86 | 67 |
87 | 68 |
88 | 69 |
89 }; | 70 }; |
90 | 71 |
91 #endif | 72 #endif |
OLD | NEW |