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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 int leftRadius, int rightRadius, int width, int height, | 76 int leftRadius, int rightRadius, int width, int height, |
77 bool transpose) | 77 bool transpose) |
78 { | 78 { |
79 int diameter = leftRadius + rightRadius; | 79 int diameter = leftRadius + rightRadius; |
80 int kernelSize = diameter + 1; | 80 int kernelSize = diameter + 1; |
81 int border = SkMin32(width, diameter); | 81 int border = SkMin32(width, diameter); |
82 uint32_t scale = (1 << 24) / kernelSize; | 82 uint32_t scale = (1 << 24) / kernelSize; |
83 int new_width = width + SkMax32(leftRadius, rightRadius) * 2; | 83 int new_width = width + SkMax32(leftRadius, rightRadius) * 2; |
84 int dst_x_stride = transpose ? height : 1; | 84 int dst_x_stride = transpose ? height : 1; |
85 int dst_y_stride = transpose ? 1 : new_width; | 85 int dst_y_stride = transpose ? 1 : new_width; |
86 #ifndef SK_DISABLE_BLUR_ROUNDING | |
87 uint32_t half = 1 << 23; | 86 uint32_t half = 1 << 23; |
88 #else | |
89 uint32_t half = 0; | |
90 #endif | |
91 for (int y = 0; y < height; ++y) { | 87 for (int y = 0; y < height; ++y) { |
92 uint32_t sum = 0; | 88 uint32_t sum = 0; |
93 uint8_t* dptr = dst + y * dst_y_stride; | 89 uint8_t* dptr = dst + y * dst_y_stride; |
94 const uint8_t* right = src + y * src_y_stride; | 90 const uint8_t* right = src + y * src_y_stride; |
95 const uint8_t* left = right; | 91 const uint8_t* left = right; |
96 for (int x = 0; x < rightRadius - leftRadius; x++) { | 92 for (int x = 0; x < rightRadius - leftRadius; x++) { |
97 *dptr = 0; | 93 *dptr = 0; |
98 dptr += dst_x_stride; | 94 dptr += dst_x_stride; |
99 } | 95 } |
100 #define LEFT_BORDER_ITER \ | 96 #define LEFT_BORDER_ITER \ |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool transpose, uint8_t outer_weight) | 279 bool transpose, uint8_t outer_weight) |
284 { | 280 { |
285 int diameter = radius * 2; | 281 int diameter = radius * 2; |
286 int kernelSize = diameter + 1; | 282 int kernelSize = diameter + 1; |
287 int border = SkMin32(width, diameter); | 283 int border = SkMin32(width, diameter); |
288 int inner_weight = 255 - outer_weight; | 284 int inner_weight = 255 - outer_weight; |
289 outer_weight += outer_weight >> 7; | 285 outer_weight += outer_weight >> 7; |
290 inner_weight += inner_weight >> 7; | 286 inner_weight += inner_weight >> 7; |
291 uint32_t outer_scale = (outer_weight << 16) / kernelSize; | 287 uint32_t outer_scale = (outer_weight << 16) / kernelSize; |
292 uint32_t inner_scale = (inner_weight << 16) / (kernelSize - 2); | 288 uint32_t inner_scale = (inner_weight << 16) / (kernelSize - 2); |
293 #ifndef SK_DISABLE_BLUR_ROUNDING | |
294 uint32_t half = 1 << 23; | 289 uint32_t half = 1 << 23; |
295 #else | |
296 uint32_t half = 0; | |
297 #endif | |
298 int new_width = width + diameter; | 290 int new_width = width + diameter; |
299 int dst_x_stride = transpose ? height : 1; | 291 int dst_x_stride = transpose ? height : 1; |
300 int dst_y_stride = transpose ? 1 : new_width; | 292 int dst_y_stride = transpose ? 1 : new_width; |
301 for (int y = 0; y < height; ++y) { | 293 for (int y = 0; y < height; ++y) { |
302 uint32_t outer_sum = 0, inner_sum = 0; | 294 uint32_t outer_sum = 0, inner_sum = 0; |
303 uint8_t* dptr = dst + y * dst_y_stride; | 295 uint8_t* dptr = dst + y * dst_y_stride; |
304 const uint8_t* right = src + y * src_y_stride; | 296 const uint8_t* right = src + y * src_y_stride; |
305 const uint8_t* left = right; | 297 const uint8_t* left = right; |
306 int x = 0; | 298 int x = 0; |
307 | 299 |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 (void)autoCall.detach(); | 992 (void)autoCall.detach(); |
1001 } | 993 } |
1002 | 994 |
1003 if (style == kInner_Style) { | 995 if (style == kInner_Style) { |
1004 dst->fBounds = src.fBounds; // restore trimmed bounds | 996 dst->fBounds = src.fBounds; // restore trimmed bounds |
1005 dst->fRowBytes = src.fRowBytes; | 997 dst->fRowBytes = src.fRowBytes; |
1006 } | 998 } |
1007 | 999 |
1008 return true; | 1000 return true; |
1009 } | 1001 } |
OLD | NEW |