| 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 BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, SkBlurS
tyle, |
| 19 SkIPoint *margin = NULL, | 19 SkIPoint *margin = nullptr, |
| 20 SkMask::CreateMode createMode = | 20 SkMask::CreateMode createMode = |
| 21 SkMask::kComputeBoundsAndRenderI
mage_CreateMode); | 21 SkMask::kComputeBoundsAndRenderI
mage_CreateMode); |
| 22 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlu
rStyle, | 22 static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlu
rStyle, |
| 23 SkIPoint *margin = NULL, | 23 SkIPoint *margin = nullptr, |
| 24 SkMask::CreateMode createMode = | 24 SkMask::CreateMode createMode = |
| 25 SkMask::kComputeBoundsAndRenderI
mage_CreateMode); | 25 SkMask::kComputeBoundsAndRenderI
mage_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 BoxBlur(SkMask* dst, const SkMask& src, |
| 34 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality
, | 34 SkScalar sigma, SkBlurStyle style, SkBlurQuality quality
, |
| 35 SkIPoint* margin = NULL, bool force_quality=false); | 35 SkIPoint* margin = nullptr, bool force_quality=false); |
| 36 | 36 |
| 37 // the "ground truth" blur does a gaussian convolution; it's slow | 37 // the "ground truth" blur does a gaussian convolution; it's slow |
| 38 // but useful for comparison purposes. | 38 // but useful for comparison purposes. |
| 39 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
SkBlurStyle, | 39 static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
SkBlurStyle, |
| 40 SkIPoint* margin = NULL); | 40 SkIPoint* margin = nullptr); |
| 41 | 41 |
| 42 // If radius > 0, return the corresponding sigma, else return 0 | 42 // If radius > 0, return the corresponding sigma, else return 0 |
| 43 static SkScalar ConvertRadiusToSigma(SkScalar radius); | 43 static SkScalar ConvertRadiusToSigma(SkScalar radius); |
| 44 // If sigma > 0.5, return the corresponding radius, else return 0 | 44 // If sigma > 0.5, return the corresponding radius, else return 0 |
| 45 static SkScalar ConvertSigmaToRadius(SkScalar sigma); | 45 static SkScalar ConvertSigmaToRadius(SkScalar sigma); |
| 46 | 46 |
| 47 /* Helper functions for analytic rectangle blurs */ | 47 /* Helper functions for analytic rectangle blurs */ |
| 48 | 48 |
| 49 /** Look up the intensity of the (one dimnensional) blurred half-plane. | 49 /** 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 | 50 @param profile The precomputed 1D blur profile; memory allocated by and
managed by |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 */ | 74 */ |
| 75 | 75 |
| 76 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, | 76 static void ComputeBlurredScanline(uint8_t* pixels, const uint8_t* profile, |
| 77 unsigned int width, SkScalar sigma); | 77 unsigned int width, SkScalar sigma); |
| 78 | 78 |
| 79 | 79 |
| 80 | 80 |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 #endif | 83 #endif |
| OLD | NEW |