| 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 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| 11 #include "SkMath.h" | 11 #include "SkMath.h" |
| 12 #include "SkTemplates.h" | 12 #include "SkTemplates.h" |
| 13 #include "SkEndian.h" | 13 #include "SkEndian.h" |
| 14 | 14 |
| 15 | 15 |
| 16 SkScalar SkBlurMask::ConvertRadiusToSigma(SkScalar radius) { | 16 SkScalar SkBlurMask::ConvertRadiusToSigma(SkScalar radius) { |
| 17 // This constant approximates the scaling done in the software path's | 17 // This constant approximates the scaling done in the software path's |
| 18 // "high quality" mode, in SkBlurMask::Blur() (1 / sqrt(3)). | 18 // "high quality" mode, in SkBlurMask::Blur() (1 / sqrt(3)). |
| 19 // IMHO, it actually should be 1: we blur "less" than we should do | 19 // IMHO, it actually should be 1: we blur "less" than we should do |
| 20 // according to the CSS and canvas specs, simply because Safari does the sam
e. | 20 // according to the CSS and canvas specs, simply because Safari does the sam
e. |
| 21 // Firefox used to do the same too, until 4.0 where they fixed it. So at so
me | 21 // Firefox used to do the same too, until 4.0 where they fixed it. So at so
me |
| 22 // point we should probably get rid of these scaling constants and rebaselin
e | 22 // point we should probably get rid of these scaling constants and rebaselin
e |
| 23 // all the blur tests. | 23 // all the blur tests. |
| 24 static const SkScalar kBLUR_SIGMA_SCALE = SkFloatToScalar(0.57735f); | 24 static const SkScalar kBLUR_SIGMA_SCALE = 0.57735f; |
| 25 | 25 |
| 26 return radius ? kBLUR_SIGMA_SCALE * radius + 0.5f : 0.0f; | 26 return radius ? kBLUR_SIGMA_SCALE * radius + 0.5f : 0.0f; |
| 27 } | 27 } |
| 28 | 28 |
| 29 #define UNROLL_SEPARABLE_LOOPS | 29 #define UNROLL_SEPARABLE_LOOPS |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * This function performs a box blur in X, of the given radius. If the | 32 * This function performs a box blur in X, of the given radius. If the |
| 33 * "transpose" parameter is true, it will transpose the pixels on write, | 33 * "transpose" parameter is true, it will transpose the pixels on write, |
| 34 * such that X and Y are swapped. Reads are always performed from contiguous | 34 * such that X and Y are swapped. Reads are always performed from contiguous |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 #undef RIGHT_BORDER_ITER | 399 #undef RIGHT_BORDER_ITER |
| 400 SkASSERT(outer_sum == 0 && inner_sum == 0); | 400 SkASSERT(outer_sum == 0 && inner_sum == 0); |
| 401 } | 401 } |
| 402 return new_width; | 402 return new_width; |
| 403 } | 403 } |
| 404 | 404 |
| 405 static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius
) | 405 static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius
) |
| 406 { | 406 { |
| 407 *loRadius = *hiRadius = SkScalarCeil(passRadius); | 407 *loRadius = *hiRadius = SkScalarCeil(passRadius); |
| 408 if (SkIntToScalar(*hiRadius) - passRadius > SkFloatToScalar(0.5f)) { | 408 if (SkIntToScalar(*hiRadius) - passRadius > 0.5f) { |
| 409 *loRadius = *hiRadius - 1; | 409 *loRadius = *hiRadius - 1; |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 #include "SkColorPriv.h" | 413 #include "SkColorPriv.h" |
| 414 | 414 |
| 415 static void merge_src_with_blur(uint8_t dst[], int dstRB, | 415 static void merge_src_with_blur(uint8_t dst[], int dstRB, |
| 416 const uint8_t src[], int srcRB, | 416 const uint8_t src[], int srcRB, |
| 417 const uint8_t blur[], int blurRB, | 417 const uint8_t blur[], int blurRB, |
| 418 int sw, int sh) { | 418 int sw, int sh) { |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 (void)autoCall.detach(); | 992 (void)autoCall.detach(); |
| 993 } | 993 } |
| 994 | 994 |
| 995 if (style == kInner_Style) { | 995 if (style == kInner_Style) { |
| 996 dst->fBounds = src.fBounds; // restore trimmed bounds | 996 dst->fBounds = src.fBounds; // restore trimmed bounds |
| 997 dst->fRowBytes = src.fRowBytes; | 997 dst->fRowBytes = src.fRowBytes; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 return true; | 1000 return true; |
| 1001 } | 1001 } |
| OLD | NEW |