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