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