| 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 all the time, we actually fill in the profile pre-inverted | 674 all the time, we actually fill in the profile pre-inverted |
| 675 (already done 255-x). | 675 (already done 255-x). |
| 676 | 676 |
| 677 It's the responsibility of the caller to delete the | 677 It's the responsibility of the caller to delete the |
| 678 memory returned in profile_out. | 678 memory returned in profile_out. |
| 679 */ | 679 */ |
| 680 | 680 |
| 681 uint8_t* SkBlurMask::ComputeBlurProfile(SkScalar sigma) { | 681 uint8_t* SkBlurMask::ComputeBlurProfile(SkScalar sigma) { |
| 682 int size = SkScalarCeilToInt(6*sigma); | 682 int size = SkScalarCeilToInt(6*sigma); |
| 683 | 683 |
| 684 float center = 0.5f * size; | 684 int center = size >> 1; |
| 685 uint8_t* profile = new uint8_t[size]; | 685 uint8_t* profile = new uint8_t[size]; |
| 686 | 686 |
| 687 float invr = 1.f/(2*sigma); | 687 float invr = 1.f/(2*sigma); |
| 688 | 688 |
| 689 profile[0] = 255; | 689 profile[0] = 255; |
| 690 for (int x = 1 ; x < size ; ++x) { | 690 for (int x = 1 ; x < size ; ++x) { |
| 691 float scaled_x = (center - x - .5f) * invr; | 691 float scaled_x = (center - x - .5f) * invr; |
| 692 float gi = gaussianIntegral(scaled_x); | 692 float gi = gaussianIntegral(scaled_x); |
| 693 profile[x] = 255 - (uint8_t) (255.f * gi); | 693 profile[x] = 255 - (uint8_t) (255.f * gi); |
| 694 } | 694 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 (void)autoCall.detach(); | 985 (void)autoCall.detach(); |
| 986 } | 986 } |
| 987 | 987 |
| 988 if (style == kInner_SkBlurStyle) { | 988 if (style == kInner_SkBlurStyle) { |
| 989 dst->fBounds = src.fBounds; // restore trimmed bounds | 989 dst->fBounds = src.fBounds; // restore trimmed bounds |
| 990 dst->fRowBytes = src.fRowBytes; | 990 dst->fRowBytes = src.fRowBytes; |
| 991 } | 991 } |
| 992 | 992 |
| 993 return true; | 993 return true; |
| 994 } | 994 } |
| OLD | NEW |