| 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 | |
| 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 | 26 |
| 44 // forceQuality will prevent BoxBlur from falling back to the low quality ap
proach when sigma | 27 // forceQuality will prevent BoxBlur from falling back to the low quality ap
proach when sigma |
| 45 // is very small -- this can be used predict the margin bump ahead of time w
ithout completely | 28 // is very small -- this can be used predict the margin bump ahead of time w
ithout completely |
| 46 // replicating the internal logic. This permits not only simpler caching of
blurred results, | 29 // replicating the internal logic. This permits not only simpler caching of
blurred results, |
| 47 // but also being able to predict precisely at what pixels the blurred profi
le of e.g. a | 30 // but also being able to predict precisely at what pixels the blurred profi
le of e.g. a |
| 48 // rectangle will lie. | 31 // rectangle will lie. |
| 49 | 32 |
| 50 static bool BoxBlur(SkMask* dst, const SkMask& src, | 33 static bool BoxBlur(SkMask* dst, const SkMask& src, |
| 51 SkScalar sigma, Style style, Quality quality, | 34 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality
, |
| 52 SkIPoint* margin = NULL, bool forceQuality = false); | 35 SkIPoint* margin = NULL, bool forceQuality = false); |
| 53 | 36 |
| 54 // the "ground truth" blur does a gaussian convolution; it's slow | 37 // the "ground truth" blur does a gaussian convolution; it's slow |
| 55 // but useful for comparison purposes. | 38 // but useful for comparison purposes. |
| 56 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, | 39 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
SkBlurStyle, |
| 57 Style style, | |
| 58 SkIPoint* margin = NULL); | 40 SkIPoint* margin = NULL); |
| 59 | 41 |
| 60 static SkScalar ConvertRadiusToSigma(SkScalar radius); | 42 static SkScalar ConvertRadiusToSigma(SkScalar radius); |
| 61 | 43 |
| 62 /* Helper functions for analytic rectangle blurs */ | 44 /* Helper functions for analytic rectangle blurs */ |
| 63 | 45 |
| 64 /** Look up the intensity of the (one dimnensional) blurred half-plane. | 46 /** Look up the intensity of the (one dimnensional) blurred half-plane. |
| 65 @param profile The precomputed 1D blur profile; memory allocated by and
managed by | 47 @param profile The precomputed 1D blur profile; memory allocated by and
managed by |
| 66 ComputeBlurProfile below. | 48 ComputeBlurProfile below. |
| 67 @param loc the location to look up; The lookup will clamp invalid inputs
, but | 49 @param loc the location to look up; The lookup will clamp invalid inputs
, but |
| (...skipping 21 matching lines...) Expand all Loading... |
| 89 */ | 71 */ |
| 90 | 72 |
| 91 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, | 73 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, |
| 92 unsigned int width, SkScalar sigma); | 74 unsigned int width, SkScalar sigma); |
| 93 | 75 |
| 94 | 76 |
| 95 | 77 |
| 96 }; | 78 }; |
| 97 | 79 |
| 98 #endif | 80 #endif |
| OLD | NEW |