| 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" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 RIGHT_BORDER_ITER | 397 RIGHT_BORDER_ITER |
| 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 = SkScalarCeilToInt(passRadius); |
| 408 if (SkIntToScalar(*hiRadius) - passRadius > 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, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 // For the low quality path we only attempt to cover 3*sigma of the | 505 // For the low quality path we only attempt to cover 3*sigma of the |
| 506 // Gaussian blur area (1.5*sigma on each side). The single pass box | 506 // Gaussian blur area (1.5*sigma on each side). The single pass box |
| 507 // blur's kernel size is 2*rad+1. | 507 // blur's kernel size is 2*rad+1. |
| 508 passRadius = 1.5f*sigma - 0.5f; | 508 passRadius = 1.5f*sigma - 0.5f; |
| 509 } | 509 } |
| 510 | 510 |
| 511 // highQuality: use three box blur passes as a cheap way | 511 // highQuality: use three box blur passes as a cheap way |
| 512 // to approximate a Gaussian blur | 512 // to approximate a Gaussian blur |
| 513 int passCount = (kHigh_Quality == quality) ? 3 : 1; | 513 int passCount = (kHigh_Quality == quality) ? 3 : 1; |
| 514 | 514 |
| 515 int rx = SkScalarCeil(passRadius); | 515 int rx = SkScalarCeilToInt(passRadius); |
| 516 int outerWeight = 255 - SkScalarRound((SkIntToScalar(rx) - passRadius) * 255
); | 516 int outerWeight = 255 - SkScalarRoundToInt((SkIntToScalar(rx) - passRadius)
* 255); |
| 517 | 517 |
| 518 SkASSERT(rx >= 0); | 518 SkASSERT(rx >= 0); |
| 519 SkASSERT((unsigned)outerWeight <= 255); | 519 SkASSERT((unsigned)outerWeight <= 255); |
| 520 if (rx <= 0) { | 520 if (rx <= 0) { |
| 521 return false; | 521 return false; |
| 522 } | 522 } |
| 523 | 523 |
| 524 int ry = rx; // only do square blur for now | 524 int ry = rx; // only do square blur for now |
| 525 | 525 |
| 526 int padx = passCount * rx; | 526 int padx = passCount * rx; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 | 858 |
| 859 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, | 859 bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, |
| 860 Style style, SkIPoint* margin) { | 860 Style style, SkIPoint* margin) { |
| 861 | 861 |
| 862 if (src.fFormat != SkMask::kA8_Format) { | 862 if (src.fFormat != SkMask::kA8_Format) { |
| 863 return false; | 863 return false; |
| 864 } | 864 } |
| 865 | 865 |
| 866 float variance = sigma * sigma; | 866 float variance = sigma * sigma; |
| 867 | 867 |
| 868 int windowSize = SkScalarCeil(sigma*6); | 868 int windowSize = SkScalarCeilToInt(sigma*6); |
| 869 // round window size up to nearest odd number | 869 // round window size up to nearest odd number |
| 870 windowSize |= 1; | 870 windowSize |= 1; |
| 871 | 871 |
| 872 SkAutoTMalloc<float> gaussWindow(windowSize); | 872 SkAutoTMalloc<float> gaussWindow(windowSize); |
| 873 | 873 |
| 874 int halfWindow = windowSize >> 1; | 874 int halfWindow = windowSize >> 1; |
| 875 | 875 |
| 876 gaussWindow[halfWindow] = 1; | 876 gaussWindow[halfWindow] = 1; |
| 877 | 877 |
| 878 float windowSum = 1; | 878 float windowSum = 1; |
| (...skipping 113 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 |