| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * 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 |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkBlurMask_DEFINED | 8 #ifndef SkBlurMask_DEFINED |
| 9 #define SkBlurMask_DEFINED | 9 #define SkBlurMask_DEFINED |
| 10 | 10 |
| 11 #include "SkBlurTypes.h" | 11 #include "SkBlurTypes.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 #include "SkMask.h" | 13 #include "SkMask.h" |
| 14 #include "SkRRect.h" | 14 #include "SkRRect.h" |
| 15 | 15 |
| 16 class SkBlurMask { | 16 class SkBlurMask { |
| 17 public: | 17 public: |
| 18 static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, SkBlurS
tyle, | 18 static bool SK_WARN_UNUSED_RESULT BlurRect(SkScalar sigma, SkMask *dst, cons
t SkRect &src, |
| 19 SkIPoint *margin = nullptr, | 19 SkBlurStyle, SkIPoint *margin = n
ullptr, |
| 20 SkMask::CreateMode createMode = | 20 SkMask::CreateMode createMode = |
| 21 SkMask::kComputeBoundsAndRenderI
mage_CreateMode); | 21 SkMask::kComputeBoundsAndRende
rImage_CreateMode); |
| 22 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlu
rStyle, | 22 static bool SK_WARN_UNUSED_RESULT BlurRRect(SkScalar sigma, SkMask *dst, con
st SkRRect &src, |
| 23 SkIPoint *margin = nullptr, | 23 SkBlurStyle, SkIPoint *margin =
nullptr, |
| 24 SkMask::CreateMode createMode = | 24 SkMask::CreateMode createMode = |
| 25 SkMask::kComputeBoundsAndRenderI
mage_CreateMode); | 25 SkMask::kComputeBoundsAndRende
rImage_CreateMode); |
| 26 | 26 |
| 27 // 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 |
| 28 // 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 |
| 29 // 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, |
| 30 // 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 |
| 31 // rectangle will lie. | 31 // rectangle will lie. |
| 32 | 32 |
| 33 static bool BoxBlur(SkMask* dst, const SkMask& src, | 33 static bool SK_WARN_UNUSED_RESULT BoxBlur(SkMask* dst, const SkMask& src, |
| 34 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality
, | 34 SkScalar sigma, SkBlurStyle style,
SkBlurQuality, |
| 35 SkIPoint* margin = nullptr, bool force_quality=false); | 35 SkIPoint* margin = nullptr, |
| 36 bool forceQuality = false); |
| 36 | 37 |
| 37 // the "ground truth" blur does a gaussian convolution; it's slow | 38 // the "ground truth" blur does a gaussian convolution; it's slow |
| 38 // but useful for comparison purposes. | 39 // but useful for comparison purposes. |
| 39 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
SkBlurStyle, | 40 static bool SK_WARN_UNUSED_RESULT BlurGroundTruth(SkScalar sigma, SkMask* ds
t, |
| 40 SkIPoint* margin = nullptr); | 41 const SkMask& src, |
| 42 SkBlurStyle, SkIPoint* mar
gin = nullptr); |
| 41 | 43 |
| 42 // If radius > 0, return the corresponding sigma, else return 0 | 44 // If radius > 0, return the corresponding sigma, else return 0 |
| 43 static SkScalar ConvertRadiusToSigma(SkScalar radius); | 45 static SkScalar ConvertRadiusToSigma(SkScalar radius); |
| 44 // If sigma > 0.5, return the corresponding radius, else return 0 | 46 // If sigma > 0.5, return the corresponding radius, else return 0 |
| 45 static SkScalar ConvertSigmaToRadius(SkScalar sigma); | 47 static SkScalar ConvertSigmaToRadius(SkScalar sigma); |
| 46 | 48 |
| 47 /* Helper functions for analytic rectangle blurs */ | 49 /* Helper functions for analytic rectangle blurs */ |
| 48 | 50 |
| 49 /** Look up the intensity of the (one dimnensional) blurred half-plane. | 51 /** Look up the intensity of the (one dimnensional) blurred half-plane. |
| 50 @param profile The precomputed 1D blur profile; memory allocated by and
managed by | 52 @param profile The precomputed 1D blur profile; memory allocated by and
managed by |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 */ | 75 */ |
| 74 | 76 |
| 75 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, | 77 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, |
| 76 unsigned int width, SkScalar sigma); | 78 unsigned int width, SkScalar sigma); |
| 77 | 79 |
| 78 | 80 |
| 79 | 81 |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 #endif | 84 #endif |
| OLD | NEW |