2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2006 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
#include "SkBlurMask.h"
|
2011-09-27 17:38:17 +00:00
|
|
|
#include "SkMath.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#include "SkTemplates.h"
|
2011-11-28 18:22:01 +00:00
|
|
|
#include "SkEndian.h"
|
|
|
|
|
2013-01-05 02:02:05 +00:00
|
|
|
// scale factor for the blur radius to match the behavior of the all existing blur
|
2013-01-04 20:29:03 +00:00
|
|
|
// code (both on the CPU and the GPU). This magic constant is 1/sqrt(3).
|
|
|
|
|
2013-01-05 02:02:05 +00:00
|
|
|
// TODO: get rid of this fudge factor and move any required fudging up into
|
2013-01-04 20:29:03 +00:00
|
|
|
// the calling library
|
|
|
|
|
|
|
|
#define kBlurRadiusFudgeFactor SkFloatToScalar( .57735f )
|
|
|
|
|
2012-11-27 22:57:41 +00:00
|
|
|
#define UNROLL_SEPARABLE_LOOPS
|
|
|
|
|
2012-11-15 20:27:35 +00:00
|
|
|
/**
|
|
|
|
* This function performs a box blur in X, of the given radius. If the
|
2012-11-16 02:01:17 +00:00
|
|
|
* "transpose" parameter is true, it will transpose the pixels on write,
|
2012-11-15 20:27:35 +00:00
|
|
|
* such that X and Y are swapped. Reads are always performed from contiguous
|
|
|
|
* memory in X, for speed. The destination buffer (dst) must be at least
|
2012-11-27 22:57:41 +00:00
|
|
|
* (width + leftRadius + rightRadius) * height bytes in size.
|
2012-11-15 20:27:35 +00:00
|
|
|
*/
|
|
|
|
static int boxBlur(const uint8_t* src, int src_y_stride, uint8_t* dst,
|
2012-11-16 17:22:33 +00:00
|
|
|
int leftRadius, int rightRadius, int width, int height,
|
|
|
|
bool transpose)
|
2012-11-13 20:35:21 +00:00
|
|
|
{
|
2012-11-27 22:57:41 +00:00
|
|
|
int diameter = leftRadius + rightRadius;
|
|
|
|
int kernelSize = diameter + 1;
|
|
|
|
int border = SkMin32(width, diameter);
|
2012-11-13 20:35:21 +00:00
|
|
|
uint32_t scale = (1 << 24) / kernelSize;
|
2012-11-16 17:22:33 +00:00
|
|
|
int new_width = width + SkMax32(leftRadius, rightRadius) * 2;
|
2012-11-15 20:27:35 +00:00
|
|
|
int dst_x_stride = transpose ? height : 1;
|
|
|
|
int dst_y_stride = transpose ? 1 : new_width;
|
2012-11-13 20:35:21 +00:00
|
|
|
for (int y = 0; y < height; ++y) {
|
|
|
|
int sum = 0;
|
2012-11-15 20:27:35 +00:00
|
|
|
uint8_t* dptr = dst + y * dst_y_stride;
|
|
|
|
const uint8_t* right = src + y * src_y_stride;
|
|
|
|
const uint8_t* left = right;
|
2012-11-20 17:09:40 +00:00
|
|
|
for (int x = 0; x < rightRadius - leftRadius; x++) {
|
|
|
|
*dptr = 0;
|
|
|
|
dptr += dst_x_stride;
|
2012-11-16 17:22:33 +00:00
|
|
|
}
|
2012-11-27 22:57:41 +00:00
|
|
|
#define LEFT_BORDER_ITER \
|
|
|
|
sum += *right++; \
|
|
|
|
*dptr = (sum * scale) >> 24; \
|
2012-11-15 20:27:35 +00:00
|
|
|
dptr += dst_x_stride;
|
2012-11-27 22:57:41 +00:00
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < border - 16; x += 16) {
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
2012-11-27 22:57:41 +00:00
|
|
|
#endif
|
|
|
|
for (; x < border; ++x) {
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#undef LEFT_BORDER_ITER
|
|
|
|
#define TRIVIAL_ITER \
|
|
|
|
*dptr = (sum * scale) >> 24; \
|
2012-11-15 20:27:35 +00:00
|
|
|
dptr += dst_x_stride;
|
2012-11-27 22:57:41 +00:00
|
|
|
x = width;
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < diameter - 16; x += 16) {
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
TRIVIAL_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (; x < diameter; ++x) {
|
|
|
|
TRIVIAL_ITER
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
2012-11-27 22:57:41 +00:00
|
|
|
#undef TRIVIAL_ITER
|
|
|
|
#define CENTER_ITER \
|
|
|
|
sum += *right++; \
|
|
|
|
*dptr = (sum * scale) >> 24; \
|
|
|
|
sum -= *left++; \
|
2012-11-15 20:27:35 +00:00
|
|
|
dptr += dst_x_stride;
|
2012-11-27 22:57:41 +00:00
|
|
|
|
|
|
|
x = diameter;
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < width - 16; x += 16) {
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (; x < width; ++x) {
|
|
|
|
CENTER_ITER
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
2012-11-27 22:57:41 +00:00
|
|
|
#undef CENTER_ITER
|
|
|
|
#define RIGHT_BORDER_ITER \
|
|
|
|
*dptr = (sum * scale) >> 24; \
|
|
|
|
sum -= *left++; \
|
2012-11-15 20:27:35 +00:00
|
|
|
dptr += dst_x_stride;
|
2012-11-27 22:57:41 +00:00
|
|
|
|
|
|
|
x = 0;
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < border - 16; x += 16) {
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (; x < border; ++x) {
|
|
|
|
RIGHT_BORDER_ITER
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
2012-11-27 22:57:41 +00:00
|
|
|
#undef RIGHT_BORDER_ITER
|
2012-11-20 17:09:40 +00:00
|
|
|
for (int x = 0; x < leftRadius - rightRadius; x++) {
|
|
|
|
*dptr = 0;
|
|
|
|
dptr += dst_x_stride;
|
2012-11-16 17:22:33 +00:00
|
|
|
}
|
2012-11-13 20:35:21 +00:00
|
|
|
SkASSERT(sum == 0);
|
|
|
|
}
|
2012-11-15 20:27:35 +00:00
|
|
|
return new_width;
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 22:57:41 +00:00
|
|
|
/**
|
|
|
|
* This variant of the box blur handles blurring of non-integer radii. It
|
|
|
|
* keeps two running sums: an outer sum for the rounded-up kernel radius, and
|
|
|
|
* an inner sum for the rounded-down kernel radius. For each pixel, it linearly
|
|
|
|
* interpolates between them. In float this would be:
|
|
|
|
* outer_weight * outer_sum / kernelSize +
|
|
|
|
* (1.0 - outer_weight) * innerSum / (kernelSize - 2)
|
|
|
|
*/
|
|
|
|
static int boxBlurInterp(const uint8_t* src, int src_y_stride, uint8_t* dst,
|
|
|
|
int radius, int width, int height,
|
|
|
|
bool transpose, uint8_t outer_weight)
|
|
|
|
{
|
|
|
|
int diameter = radius * 2;
|
|
|
|
int kernelSize = diameter + 1;
|
|
|
|
int border = SkMin32(width, diameter);
|
|
|
|
int inner_weight = 255 - outer_weight;
|
|
|
|
outer_weight += outer_weight >> 7;
|
|
|
|
inner_weight += inner_weight >> 7;
|
|
|
|
uint32_t outer_scale = (outer_weight << 16) / kernelSize;
|
|
|
|
uint32_t inner_scale = (inner_weight << 16) / (kernelSize - 2);
|
|
|
|
int new_width = width + diameter;
|
|
|
|
int dst_x_stride = transpose ? height : 1;
|
|
|
|
int dst_y_stride = transpose ? 1 : new_width;
|
|
|
|
for (int y = 0; y < height; ++y) {
|
|
|
|
int outer_sum = 0, inner_sum = 0;
|
|
|
|
uint8_t* dptr = dst + y * dst_y_stride;
|
|
|
|
const uint8_t* right = src + y * src_y_stride;
|
|
|
|
const uint8_t* left = right;
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
#define LEFT_BORDER_ITER \
|
|
|
|
inner_sum = outer_sum; \
|
|
|
|
outer_sum += *right++; \
|
|
|
|
*dptr = (outer_sum * outer_scale + inner_sum * inner_scale) >> 24; \
|
|
|
|
dptr += dst_x_stride;
|
|
|
|
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (;x < border - 16; x += 16) {
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (;x < border; x++) {
|
|
|
|
LEFT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#undef LEFT_BORDER_ITER
|
|
|
|
for (int x = width; x < diameter; ++x) {
|
|
|
|
*dptr = (outer_sum * outer_scale + inner_sum * inner_scale) >> 24;
|
|
|
|
dptr += dst_x_stride;
|
|
|
|
}
|
|
|
|
x = diameter;
|
|
|
|
|
|
|
|
#define CENTER_ITER \
|
|
|
|
inner_sum = outer_sum - *left; \
|
|
|
|
outer_sum += *right++; \
|
|
|
|
*dptr = (outer_sum * outer_scale + inner_sum * inner_scale) >> 24; \
|
|
|
|
dptr += dst_x_stride; \
|
|
|
|
outer_sum -= *left++;
|
|
|
|
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < width - 16; x += 16) {
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
CENTER_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (; x < width; ++x) {
|
|
|
|
CENTER_ITER
|
|
|
|
}
|
|
|
|
#undef CENTER_ITER
|
|
|
|
|
|
|
|
#define RIGHT_BORDER_ITER \
|
|
|
|
inner_sum = outer_sum - *left++; \
|
|
|
|
*dptr = (outer_sum * outer_scale + inner_sum * inner_scale) >> 24; \
|
|
|
|
dptr += dst_x_stride; \
|
|
|
|
outer_sum = inner_sum;
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
#ifdef UNROLL_SEPARABLE_LOOPS
|
|
|
|
for (; x < border - 16; x += 16) {
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (; x < border; x++) {
|
|
|
|
RIGHT_BORDER_ITER
|
|
|
|
}
|
|
|
|
#undef RIGHT_BORDER_ITER
|
|
|
|
SkASSERT(outer_sum == 0 && inner_sum == 0);
|
|
|
|
}
|
|
|
|
return new_width;
|
|
|
|
}
|
|
|
|
|
2012-11-16 17:22:33 +00:00
|
|
|
static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius)
|
|
|
|
{
|
|
|
|
*loRadius = *hiRadius = SkScalarCeil(passRadius);
|
|
|
|
if (SkIntToScalar(*hiRadius) - passRadius > SkFloatToScalar(0.5f)) {
|
|
|
|
*loRadius = *hiRadius - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
// Unrolling the integer blur kernel seems to give us a ~15% speedup on Windows,
|
|
|
|
// breakeven on Mac, and ~15% slowdown on Linux.
|
|
|
|
// Reading a word at a time when bulding the sum buffer seems to give
|
|
|
|
// us no appreciable speedup on Windows or Mac, and 2% slowdown on Linux.
|
2012-01-11 19:29:08 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
2011-11-28 18:22:01 +00:00
|
|
|
#define UNROLL_KERNEL_LOOP 1
|
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
/** The sum buffer is an array of u32 to hold the accumulated sum of all of the
|
|
|
|
src values at their position, plus all values above and to the left.
|
|
|
|
When we sample into this buffer, we need an initial row and column of 0s,
|
|
|
|
so we have an index correspondence as follows:
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
src[i, j] == sum[i+1, j+1]
|
|
|
|
sum[0, j] == sum[i, 0] == 0
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
We assume that the sum buffer's stride == its width
|
|
|
|
*/
|
2011-08-12 14:59:59 +00:00
|
|
|
static void build_sum_buffer(uint32_t sum[], int srcW, int srcH,
|
|
|
|
const uint8_t src[], int srcRB) {
|
2009-09-21 00:27:08 +00:00
|
|
|
int sumW = srcW + 1;
|
|
|
|
|
|
|
|
SkASSERT(srcRB >= srcW);
|
2008-12-17 15:59:43 +00:00
|
|
|
// mod srcRB so we can apply it after each row
|
2009-09-21 00:27:08 +00:00
|
|
|
srcRB -= srcW;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
// zero out the top row and column
|
|
|
|
memset(sum, 0, sumW * sizeof(sum[0]));
|
|
|
|
sum += sumW;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
// special case first row
|
|
|
|
uint32_t X = 0;
|
2009-09-21 00:27:08 +00:00
|
|
|
*sum++ = 0; // initialze the first column to 0
|
2011-08-12 14:59:59 +00:00
|
|
|
for (x = srcW - 1; x >= 0; --x) {
|
2008-12-17 15:59:43 +00:00
|
|
|
X = *src++ + X;
|
2009-09-21 00:27:08 +00:00
|
|
|
*sum++ = X;
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
src += srcRB;
|
|
|
|
|
|
|
|
// now do the rest of the rows
|
2011-08-12 14:59:59 +00:00
|
|
|
for (y = srcH - 1; y > 0; --y) {
|
2008-12-17 15:59:43 +00:00
|
|
|
uint32_t L = 0;
|
|
|
|
uint32_t C = 0;
|
2009-09-21 00:27:08 +00:00
|
|
|
*sum++ = 0; // initialze the first column to 0
|
2011-11-28 18:22:01 +00:00
|
|
|
|
|
|
|
for (x = srcW - 1; !SkIsAlign4((intptr_t) src) && x >= 0; x--) {
|
|
|
|
uint32_t T = sum[-sumW];
|
|
|
|
X = *src++ + L + T - C;
|
|
|
|
*sum++ = X;
|
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; x >= 4; x-=4) {
|
|
|
|
uint32_t T = sum[-sumW];
|
|
|
|
X = *src++ + L + T - C;
|
|
|
|
*sum++ = X;
|
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
T = sum[-sumW];
|
|
|
|
X = *src++ + L + T - C;
|
|
|
|
*sum++ = X;
|
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
T = sum[-sumW];
|
|
|
|
X = *src++ + L + T - C;
|
|
|
|
*sum++ = X;
|
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
T = sum[-sumW];
|
|
|
|
X = *src++ + L + T - C;
|
|
|
|
*sum++ = X;
|
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; x >= 0; --x) {
|
2009-09-21 00:27:08 +00:00
|
|
|
uint32_t T = sum[-sumW];
|
2008-12-17 15:59:43 +00:00
|
|
|
X = *src++ + L + T - C;
|
2009-09-21 00:27:08 +00:00
|
|
|
*sum++ = X;
|
2008-12-17 15:59:43 +00:00
|
|
|
L = X;
|
|
|
|
C = T;
|
|
|
|
}
|
|
|
|
src += srcRB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
/**
|
|
|
|
* This is the path for apply_kernel() to be taken when the kernel
|
|
|
|
* is wider than the source image.
|
|
|
|
*/
|
|
|
|
static void kernel_clamped(uint8_t dst[], int rx, int ry, const uint32_t sum[],
|
|
|
|
int sw, int sh) {
|
|
|
|
SkASSERT(2*rx > sw);
|
|
|
|
|
|
|
|
uint32_t scale = (1 << 24) / ((2*rx + 1)*(2*ry + 1));
|
|
|
|
|
|
|
|
int sumStride = sw + 1;
|
|
|
|
|
|
|
|
int dw = sw + 2*rx;
|
|
|
|
int dh = sh + 2*ry;
|
|
|
|
|
|
|
|
int prev_y = -2*ry;
|
|
|
|
int next_y = 1;
|
|
|
|
|
|
|
|
for (int y = 0; y < dh; y++) {
|
|
|
|
int py = SkClampPos(prev_y) * sumStride;
|
|
|
|
int ny = SkFastMin32(next_y, sh) * sumStride;
|
|
|
|
|
|
|
|
int prev_x = -2*rx;
|
|
|
|
int next_x = 1;
|
|
|
|
|
|
|
|
for (int x = 0; x < dw; x++) {
|
|
|
|
int px = SkClampPos(prev_x);
|
|
|
|
int nx = SkFastMin32(next_x, sw);
|
|
|
|
|
|
|
|
uint32_t tmp = sum[px+py] + sum[nx+ny] - sum[nx+py] - sum[px+ny];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_y += 1;
|
|
|
|
next_y += 1;
|
|
|
|
}
|
|
|
|
}
|
2011-08-12 14:59:59 +00:00
|
|
|
/**
|
|
|
|
* sw and sh are the width and height of the src. Since the sum buffer
|
|
|
|
* matches that, but has an extra row and col at the beginning (with zeros),
|
|
|
|
* we can just use sw and sh as our "max" values for pinning coordinates
|
|
|
|
* when sampling into sum[][]
|
2011-11-22 15:58:06 +00:00
|
|
|
*
|
|
|
|
* The inner loop is conceptually simple; we break it into several sections
|
|
|
|
* to improve performance. Here's the original version:
|
|
|
|
for (int x = 0; x < dw; x++) {
|
|
|
|
int px = SkClampPos(prev_x);
|
|
|
|
int nx = SkFastMin32(next_x, sw);
|
|
|
|
|
|
|
|
uint32_t tmp = sum[px+py] + sum[nx+ny] - sum[nx+py] - sum[px+ny];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
2011-11-28 18:22:01 +00:00
|
|
|
* The sections are:
|
|
|
|
* left-hand section, where prev_x is clamped to 0
|
|
|
|
* center section, where neither prev_x nor next_x is clamped
|
|
|
|
* right-hand section, where next_x is clamped to sw
|
|
|
|
* On some operating systems, the center section is unrolled for additional
|
|
|
|
* speedup.
|
2011-11-22 15:58:06 +00:00
|
|
|
*/
|
2009-09-21 00:27:08 +00:00
|
|
|
static void apply_kernel(uint8_t dst[], int rx, int ry, const uint32_t sum[],
|
|
|
|
int sw, int sh) {
|
2011-11-22 15:58:06 +00:00
|
|
|
if (2*rx > sw) {
|
|
|
|
kernel_clamped(dst, rx, ry, sum, sw, sh);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
uint32_t scale = (1 << 24) / ((2*rx + 1)*(2*ry + 1));
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int sumStride = sw + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
int dw = sw + 2*rx;
|
|
|
|
int dh = sh + 2*ry;
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int prev_y = -2*ry;
|
|
|
|
int next_y = 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
SkASSERT(2*rx <= dw - 2*rx);
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
for (int y = 0; y < dh; y++) {
|
|
|
|
int py = SkClampPos(prev_y) * sumStride;
|
|
|
|
int ny = SkFastMin32(next_y, sh) * sumStride;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
int prev_x = -2*rx;
|
|
|
|
int next_x = 1;
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
for (; x < 2*rx; x++) {
|
|
|
|
SkASSERT(prev_x <= 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
|
|
|
|
|
|
|
int px = 0;
|
|
|
|
int nx = next_x;
|
|
|
|
|
|
|
|
uint32_t tmp = sum[px+py] + sum[nx+ny] - sum[nx+py] - sum[px+ny];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
int i0 = prev_x + py;
|
|
|
|
int i1 = next_x + ny;
|
|
|
|
int i2 = next_x + py;
|
|
|
|
int i3 = prev_x + ny;
|
|
|
|
|
|
|
|
#if UNROLL_KERNEL_LOOP
|
|
|
|
for (; x < dw - 2*rx - 4; x += 4) {
|
2011-11-22 15:58:06 +00:00
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
uint32_t tmp = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
tmp = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
tmp = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
tmp = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
2011-11-22 15:58:06 +00:00
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
prev_x += 4;
|
|
|
|
next_x += 4;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (; x < dw - 2*rx; x++) {
|
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
|
|
|
|
|
|
|
uint32_t tmp = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
2011-11-22 15:58:06 +00:00
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; x < dw; x++) {
|
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x > sw);
|
|
|
|
|
|
|
|
int px = prev_x;
|
|
|
|
int nx = sw;
|
|
|
|
|
|
|
|
uint32_t tmp = sum[px+py] + sum[nx+ny] - sum[nx+py] - sum[px+ny];
|
|
|
|
*dst++ = SkToU8(tmp * scale >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_y += 1;
|
|
|
|
next_y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the path for apply_kernel_interp() to be taken when the kernel
|
|
|
|
* is wider than the source image.
|
|
|
|
*/
|
|
|
|
static void kernel_interp_clamped(uint8_t dst[], int rx, int ry,
|
|
|
|
const uint32_t sum[], int sw, int sh, U8CPU outer_weight) {
|
|
|
|
SkASSERT(2*rx > sw);
|
|
|
|
|
|
|
|
int inner_weight = 255 - outer_weight;
|
|
|
|
|
|
|
|
// round these guys up if they're bigger than 127
|
|
|
|
outer_weight += outer_weight >> 7;
|
|
|
|
inner_weight += inner_weight >> 7;
|
|
|
|
|
|
|
|
uint32_t outer_scale = (outer_weight << 16) / ((2*rx + 1)*(2*ry + 1));
|
|
|
|
uint32_t inner_scale = (inner_weight << 16) / ((2*rx - 1)*(2*ry - 1));
|
|
|
|
|
|
|
|
int sumStride = sw + 1;
|
|
|
|
|
|
|
|
int dw = sw + 2*rx;
|
|
|
|
int dh = sh + 2*ry;
|
|
|
|
|
|
|
|
int prev_y = -2*ry;
|
|
|
|
int next_y = 1;
|
|
|
|
|
|
|
|
for (int y = 0; y < dh; y++) {
|
|
|
|
int py = SkClampPos(prev_y) * sumStride;
|
|
|
|
int ny = SkFastMin32(next_y, sh) * sumStride;
|
|
|
|
|
|
|
|
int ipy = SkClampPos(prev_y + 1) * sumStride;
|
|
|
|
int iny = SkClampMax(next_y - 1, sh) * sumStride;
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int prev_x = -2*rx;
|
|
|
|
int next_x = 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
for (int x = 0; x < dw; x++) {
|
2008-12-17 15:59:43 +00:00
|
|
|
int px = SkClampPos(prev_x);
|
|
|
|
int nx = SkFastMin32(next_x, sw);
|
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
int ipx = SkClampPos(prev_x + 1);
|
|
|
|
int inx = SkClampMax(next_x - 1, sw);
|
|
|
|
|
|
|
|
uint32_t outer_sum = sum[px+py] + sum[nx+ny]
|
|
|
|
- sum[nx+py] - sum[px+ny];
|
|
|
|
uint32_t inner_sum = sum[ipx+ipy] + sum[inx+iny]
|
|
|
|
- sum[inx+ipy] - sum[ipx+iny];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
prev_y += 1;
|
|
|
|
next_y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-12 14:59:59 +00:00
|
|
|
/**
|
|
|
|
* sw and sh are the width and height of the src. Since the sum buffer
|
|
|
|
* matches that, but has an extra row and col at the beginning (with zeros),
|
|
|
|
* we can just use sw and sh as our "max" values for pinning coordinates
|
|
|
|
* when sampling into sum[][]
|
2011-11-22 15:58:06 +00:00
|
|
|
*
|
|
|
|
* The inner loop is conceptually simple; we break it into several variants
|
|
|
|
* to improve performance. Here's the original version:
|
|
|
|
for (int x = 0; x < dw; x++) {
|
|
|
|
int px = SkClampPos(prev_x);
|
|
|
|
int nx = SkFastMin32(next_x, sw);
|
|
|
|
|
|
|
|
int ipx = SkClampPos(prev_x + 1);
|
|
|
|
int inx = SkClampMax(next_x - 1, sw);
|
|
|
|
|
|
|
|
uint32_t outer_sum = sum[px+py] + sum[nx+ny]
|
|
|
|
- sum[nx+py] - sum[px+ny];
|
|
|
|
uint32_t inner_sum = sum[ipx+ipy] + sum[inx+iny]
|
|
|
|
- sum[inx+ipy] - sum[ipx+iny];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
2011-11-28 18:22:01 +00:00
|
|
|
* The sections are:
|
|
|
|
* left-hand section, where prev_x is clamped to 0
|
|
|
|
* center section, where neither prev_x nor next_x is clamped
|
|
|
|
* right-hand section, where next_x is clamped to sw
|
|
|
|
* On some operating systems, the center section is unrolled for additional
|
|
|
|
* speedup.
|
2011-11-22 15:58:06 +00:00
|
|
|
*/
|
2009-09-21 00:27:08 +00:00
|
|
|
static void apply_kernel_interp(uint8_t dst[], int rx, int ry,
|
|
|
|
const uint32_t sum[], int sw, int sh, U8CPU outer_weight) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkASSERT(rx > 0 && ry > 0);
|
|
|
|
SkASSERT(outer_weight <= 255);
|
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
if (2*rx > sw) {
|
|
|
|
kernel_interp_clamped(dst, rx, ry, sum, sw, sh, outer_weight);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
int inner_weight = 255 - outer_weight;
|
|
|
|
|
|
|
|
// round these guys up if they're bigger than 127
|
|
|
|
outer_weight += outer_weight >> 7;
|
|
|
|
inner_weight += inner_weight >> 7;
|
|
|
|
|
|
|
|
uint32_t outer_scale = (outer_weight << 16) / ((2*rx + 1)*(2*ry + 1));
|
|
|
|
uint32_t inner_scale = (inner_weight << 16) / ((2*rx - 1)*(2*ry - 1));
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int sumStride = sw + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
int dw = sw + 2*rx;
|
|
|
|
int dh = sh + 2*ry;
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int prev_y = -2*ry;
|
|
|
|
int next_y = 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
SkASSERT(2*rx <= dw - 2*rx);
|
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
for (int y = 0; y < dh; y++) {
|
|
|
|
int py = SkClampPos(prev_y) * sumStride;
|
|
|
|
int ny = SkFastMin32(next_y, sh) * sumStride;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int ipy = SkClampPos(prev_y + 1) * sumStride;
|
|
|
|
int iny = SkClampMax(next_y - 1, sh) * sumStride;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2009-09-21 00:27:08 +00:00
|
|
|
int prev_x = -2*rx;
|
|
|
|
int next_x = 1;
|
2011-11-22 15:58:06 +00:00
|
|
|
int x = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
for (; x < 2*rx; x++) {
|
|
|
|
SkASSERT(prev_x < 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-22 15:58:06 +00:00
|
|
|
int px = 0;
|
|
|
|
int nx = next_x;
|
|
|
|
|
|
|
|
int ipx = 0;
|
|
|
|
int inx = next_x - 1;
|
|
|
|
|
|
|
|
uint32_t outer_sum = sum[px+py] + sum[nx+ny]
|
|
|
|
- sum[nx+py] - sum[px+ny];
|
|
|
|
uint32_t inner_sum = sum[ipx+ipy] + sum[inx+iny]
|
|
|
|
- sum[inx+ipy] - sum[ipx+iny];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
int i0 = prev_x + py;
|
|
|
|
int i1 = next_x + ny;
|
|
|
|
int i2 = next_x + py;
|
|
|
|
int i3 = prev_x + ny;
|
|
|
|
int i4 = prev_x + 1 + ipy;
|
|
|
|
int i5 = next_x - 1 + iny;
|
|
|
|
int i6 = next_x - 1 + ipy;
|
|
|
|
int i7 = prev_x + 1 + iny;
|
|
|
|
|
|
|
|
#if UNROLL_KERNEL_LOOP
|
|
|
|
for (; x < dw - 2*rx - 4; x += 4) {
|
2011-11-22 15:58:06 +00:00
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
uint32_t outer_sum = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
uint32_t inner_sum = sum[i4++] + sum[i5++] - sum[i6++] - sum[i7++];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
outer_sum = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
inner_sum = sum[i4++] + sum[i5++] - sum[i6++] - sum[i7++];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
outer_sum = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
inner_sum = sum[i4++] + sum[i5++] - sum[i6++] - sum[i7++];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
outer_sum = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
inner_sum = sum[i4++] + sum[i5++] - sum[i6++] - sum[i7++];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
2011-11-22 15:58:06 +00:00
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
prev_x += 4;
|
|
|
|
next_x += 4;
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-28 18:22:01 +00:00
|
|
|
for (; x < dw - 2*rx; x++) {
|
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x <= sw);
|
|
|
|
|
|
|
|
uint32_t outer_sum = sum[i0++] + sum[i1++] - sum[i2++] - sum[i3++];
|
|
|
|
uint32_t inner_sum = sum[i4++] + sum[i5++] - sum[i6++] - sum[i7++];
|
2011-11-22 15:58:06 +00:00
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
2011-11-22 15:58:06 +00:00
|
|
|
|
|
|
|
for (; x < dw; x++) {
|
|
|
|
SkASSERT(prev_x >= 0);
|
|
|
|
SkASSERT(next_x > sw);
|
|
|
|
|
|
|
|
int px = prev_x;
|
|
|
|
int nx = sw;
|
|
|
|
|
|
|
|
int ipx = prev_x + 1;
|
|
|
|
int inx = sw;
|
|
|
|
|
|
|
|
uint32_t outer_sum = sum[px+py] + sum[nx+ny]
|
|
|
|
- sum[nx+py] - sum[px+ny];
|
|
|
|
uint32_t inner_sum = sum[ipx+ipy] + sum[inx+iny]
|
|
|
|
- sum[inx+ipy] - sum[ipx+iny];
|
|
|
|
*dst++ = SkToU8((outer_sum * outer_scale
|
|
|
|
+ inner_sum * inner_scale) >> 24);
|
|
|
|
|
|
|
|
prev_x += 1;
|
|
|
|
next_x += 1;
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
prev_y += 1;
|
|
|
|
next_y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "SkColorPriv.h"
|
|
|
|
|
2009-09-18 13:41:56 +00:00
|
|
|
static void merge_src_with_blur(uint8_t dst[], int dstRB,
|
|
|
|
const uint8_t src[], int srcRB,
|
|
|
|
const uint8_t blur[], int blurRB,
|
|
|
|
int sw, int sh) {
|
|
|
|
dstRB -= sw;
|
|
|
|
srcRB -= sw;
|
|
|
|
blurRB -= sw;
|
|
|
|
while (--sh >= 0) {
|
|
|
|
for (int x = sw - 1; x >= 0; --x) {
|
2008-12-17 15:59:43 +00:00
|
|
|
*dst = SkToU8(SkAlphaMul(*blur, SkAlpha255To256(*src)));
|
|
|
|
dst += 1;
|
|
|
|
src += 1;
|
|
|
|
blur += 1;
|
|
|
|
}
|
2009-09-18 13:41:56 +00:00
|
|
|
dst += dstRB;
|
|
|
|
src += srcRB;
|
|
|
|
blur += blurRB;
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clamp_with_orig(uint8_t dst[], int dstRowBytes,
|
2009-09-18 13:41:56 +00:00
|
|
|
const uint8_t src[], int srcRowBytes,
|
|
|
|
int sw, int sh,
|
2009-09-21 00:27:08 +00:00
|
|
|
SkBlurMask::Style style) {
|
2008-12-17 15:59:43 +00:00
|
|
|
int x;
|
2009-09-18 13:41:56 +00:00
|
|
|
while (--sh >= 0) {
|
2008-12-17 15:59:43 +00:00
|
|
|
switch (style) {
|
|
|
|
case SkBlurMask::kSolid_Style:
|
2009-09-18 13:41:56 +00:00
|
|
|
for (x = sw - 1; x >= 0; --x) {
|
|
|
|
int s = *src;
|
|
|
|
int d = *dst;
|
|
|
|
*dst = SkToU8(s + d - SkMulDiv255Round(s, d));
|
2008-12-17 15:59:43 +00:00
|
|
|
dst += 1;
|
|
|
|
src += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkBlurMask::kOuter_Style:
|
2009-09-18 13:41:56 +00:00
|
|
|
for (x = sw - 1; x >= 0; --x) {
|
|
|
|
if (*src) {
|
2008-12-17 15:59:43 +00:00
|
|
|
*dst = SkToU8(SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
|
2009-09-18 13:41:56 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
dst += 1;
|
|
|
|
src += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-12-28 14:59:50 +00:00
|
|
|
SkDEBUGFAIL("Unexpected blur style here");
|
2008-12-17 15:59:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
dst += dstRowBytes - sw;
|
2009-09-18 13:41:56 +00:00
|
|
|
src += srcRowBytes - sw;
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-12 14:59:59 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// we use a local funciton to wrap the class static method to work around
|
|
|
|
// a bug in gcc98
|
|
|
|
void SkMask_FreeImage(uint8_t* image);
|
2011-08-12 14:59:59 +00:00
|
|
|
void SkMask_FreeImage(uint8_t* image) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkMask::FreeImage(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkBlurMask::Blur(SkMask* dst, const SkMask& src,
|
2011-09-02 15:06:44 +00:00
|
|
|
SkScalar radius, Style style, Quality quality,
|
2012-11-13 20:35:21 +00:00
|
|
|
SkIPoint* margin, bool separable)
|
2011-09-02 15:06:44 +00:00
|
|
|
{
|
2011-08-12 14:59:59 +00:00
|
|
|
if (src.fFormat != SkMask::kA8_Format) {
|
2008-12-17 15:59:43 +00:00
|
|
|
return false;
|
2011-08-12 14:59:59 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-02-18 19:03:01 +00:00
|
|
|
// Force high quality off for small radii (performance)
|
2012-11-29 17:09:27 +00:00
|
|
|
if (radius < SkIntToScalar(3)) {
|
|
|
|
quality = kLow_Quality;
|
|
|
|
}
|
2011-02-18 19:03:01 +00:00
|
|
|
|
|
|
|
// highQuality: use three box blur passes as a cheap way to approximate a Gaussian blur
|
2012-11-29 17:09:27 +00:00
|
|
|
int passCount = (kHigh_Quality == quality) ? 3 : 1;
|
2013-01-04 20:29:03 +00:00
|
|
|
SkScalar passRadius = (kHigh_Quality == quality) ? SkScalarMul( radius, kBlurRadiusFudgeFactor): radius;
|
2011-02-18 19:03:01 +00:00
|
|
|
|
|
|
|
int rx = SkScalarCeil(passRadius);
|
|
|
|
int outer_weight = 255 - SkScalarRound((SkIntToScalar(rx) - passRadius) * 255);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
SkASSERT(rx >= 0);
|
|
|
|
SkASSERT((unsigned)outer_weight <= 255);
|
2009-09-18 13:41:56 +00:00
|
|
|
if (rx <= 0) {
|
2008-12-17 15:59:43 +00:00
|
|
|
return false;
|
2009-09-18 13:41:56 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
int ry = rx; // only do square blur for now
|
|
|
|
|
2011-02-18 19:03:01 +00:00
|
|
|
int padx = passCount * rx;
|
|
|
|
int pady = passCount * ry;
|
2011-09-02 15:06:44 +00:00
|
|
|
if (margin) {
|
|
|
|
margin->set(padx, pady);
|
|
|
|
}
|
2011-02-18 19:03:01 +00:00
|
|
|
dst->fBounds.set(src.fBounds.fLeft - padx, src.fBounds.fTop - pady,
|
|
|
|
src.fBounds.fRight + padx, src.fBounds.fBottom + pady);
|
2009-03-19 21:52:42 +00:00
|
|
|
dst->fRowBytes = dst->fBounds.width();
|
2008-12-17 15:59:43 +00:00
|
|
|
dst->fFormat = SkMask::kA8_Format;
|
|
|
|
dst->fImage = NULL;
|
|
|
|
|
2009-09-18 13:41:56 +00:00
|
|
|
if (src.fImage) {
|
2009-04-24 12:43:40 +00:00
|
|
|
size_t dstSize = dst->computeImageSize();
|
|
|
|
if (0 == dstSize) {
|
|
|
|
return false; // too big to allocate, abort
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
int sw = src.fBounds.width();
|
|
|
|
int sh = src.fBounds.height();
|
|
|
|
const uint8_t* sp = src.fImage;
|
2009-04-24 12:43:40 +00:00
|
|
|
uint8_t* dp = SkMask::AllocImage(dstSize);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
SkAutoTCallVProc<uint8_t, SkMask_FreeImage> autoCall(dp);
|
|
|
|
|
|
|
|
// build the blurry destination
|
2012-11-13 20:35:21 +00:00
|
|
|
if (separable) {
|
|
|
|
SkAutoTMalloc<uint8_t> tmpBuffer(dstSize);
|
|
|
|
uint8_t* tp = tmpBuffer.get();
|
|
|
|
int w = sw, h = sh;
|
|
|
|
|
2012-11-29 17:09:27 +00:00
|
|
|
if (outer_weight == 255) {
|
2012-11-16 17:22:33 +00:00
|
|
|
int loRadius, hiRadius;
|
|
|
|
get_adjusted_radii(passRadius, &loRadius, &hiRadius);
|
2012-11-29 17:09:27 +00:00
|
|
|
if (kHigh_Quality == quality) {
|
|
|
|
// Do three X blurs, with a transpose on the final one.
|
|
|
|
w = boxBlur(sp, src.fRowBytes, tp, loRadius, hiRadius, w, h, false);
|
|
|
|
w = boxBlur(tp, w, dp, hiRadius, loRadius, w, h, false);
|
|
|
|
w = boxBlur(dp, w, tp, hiRadius, hiRadius, w, h, true);
|
|
|
|
// Do three Y blurs, with a transpose on the final one.
|
|
|
|
h = boxBlur(tp, h, dp, loRadius, hiRadius, h, w, false);
|
|
|
|
h = boxBlur(dp, h, tp, hiRadius, loRadius, h, w, false);
|
|
|
|
h = boxBlur(tp, h, dp, hiRadius, hiRadius, h, w, true);
|
|
|
|
} else {
|
|
|
|
w = boxBlur(sp, src.fRowBytes, tp, rx, rx, w, h, true);
|
|
|
|
h = boxBlur(tp, h, dp, ry, ry, h, w, true);
|
|
|
|
}
|
2012-11-15 20:27:35 +00:00
|
|
|
} else {
|
2012-11-29 17:09:27 +00:00
|
|
|
if (kHigh_Quality == quality) {
|
|
|
|
// Do three X blurs, with a transpose on the final one.
|
|
|
|
w = boxBlurInterp(sp, src.fRowBytes, tp, rx, w, h, false, outer_weight);
|
|
|
|
w = boxBlurInterp(tp, w, dp, rx, w, h, false, outer_weight);
|
|
|
|
w = boxBlurInterp(dp, w, tp, rx, w, h, true, outer_weight);
|
|
|
|
// Do three Y blurs, with a transpose on the final one.
|
|
|
|
h = boxBlurInterp(tp, h, dp, ry, h, w, false, outer_weight);
|
|
|
|
h = boxBlurInterp(dp, h, tp, ry, h, w, false, outer_weight);
|
|
|
|
h = boxBlurInterp(tp, h, dp, ry, h, w, true, outer_weight);
|
|
|
|
} else {
|
|
|
|
w = boxBlurInterp(sp, src.fRowBytes, tp, rx, w, h, true, outer_weight);
|
|
|
|
h = boxBlurInterp(tp, h, dp, ry, h, w, true, outer_weight);
|
|
|
|
}
|
2012-11-13 20:35:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-08-12 14:59:59 +00:00
|
|
|
const size_t storageW = sw + 2 * (passCount - 1) * rx + 1;
|
|
|
|
const size_t storageH = sh + 2 * (passCount - 1) * ry + 1;
|
|
|
|
SkAutoTMalloc<uint32_t> storage(storageW * storageH);
|
2008-12-17 15:59:43 +00:00
|
|
|
uint32_t* sumBuffer = storage.get();
|
|
|
|
|
2011-02-18 19:03:01 +00:00
|
|
|
//pass1: sp is source, dp is destination
|
2008-12-17 15:59:43 +00:00
|
|
|
build_sum_buffer(sumBuffer, sw, sh, sp, src.fRowBytes);
|
2011-08-12 14:59:59 +00:00
|
|
|
if (outer_weight == 255) {
|
2008-12-17 15:59:43 +00:00
|
|
|
apply_kernel(dp, rx, ry, sumBuffer, sw, sh);
|
2011-08-12 14:59:59 +00:00
|
|
|
} else {
|
2008-12-17 15:59:43 +00:00
|
|
|
apply_kernel_interp(dp, rx, ry, sumBuffer, sw, sh, outer_weight);
|
2011-08-12 14:59:59 +00:00
|
|
|
}
|
2011-02-18 19:03:01 +00:00
|
|
|
|
2012-11-29 17:09:27 +00:00
|
|
|
if (kHigh_Quality == quality) {
|
2011-02-18 19:03:01 +00:00
|
|
|
//pass2: dp is source, tmpBuffer is destination
|
|
|
|
int tmp_sw = sw + 2 * rx;
|
|
|
|
int tmp_sh = sh + 2 * ry;
|
|
|
|
SkAutoTMalloc<uint8_t> tmpBuffer(dstSize);
|
|
|
|
build_sum_buffer(sumBuffer, tmp_sw, tmp_sh, dp, tmp_sw);
|
|
|
|
if (outer_weight == 255)
|
|
|
|
apply_kernel(tmpBuffer.get(), rx, ry, sumBuffer, tmp_sw, tmp_sh);
|
|
|
|
else
|
2011-08-12 14:59:59 +00:00
|
|
|
apply_kernel_interp(tmpBuffer.get(), rx, ry, sumBuffer,
|
|
|
|
tmp_sw, tmp_sh, outer_weight);
|
2011-02-18 19:03:01 +00:00
|
|
|
|
|
|
|
//pass3: tmpBuffer is source, dp is destination
|
|
|
|
tmp_sw += 2 * rx;
|
|
|
|
tmp_sh += 2 * ry;
|
|
|
|
build_sum_buffer(sumBuffer, tmp_sw, tmp_sh, tmpBuffer.get(), tmp_sw);
|
|
|
|
if (outer_weight == 255)
|
|
|
|
apply_kernel(dp, rx, ry, sumBuffer, tmp_sw, tmp_sh);
|
|
|
|
else
|
2011-08-12 14:59:59 +00:00
|
|
|
apply_kernel_interp(dp, rx, ry, sumBuffer, tmp_sw, tmp_sh,
|
|
|
|
outer_weight);
|
2011-02-18 19:03:01 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dst->fImage = dp;
|
|
|
|
// if need be, alloc the "real" dst (same size as src) and copy/merge
|
|
|
|
// the blur into it (applying the src)
|
2009-09-18 13:41:56 +00:00
|
|
|
if (style == kInner_Style) {
|
|
|
|
// now we allocate the "real" dst, mirror the size of src
|
2009-04-24 12:43:40 +00:00
|
|
|
size_t srcSize = src.computeImageSize();
|
|
|
|
if (0 == srcSize) {
|
|
|
|
return false; // too big to allocate, abort
|
|
|
|
}
|
|
|
|
dst->fImage = SkMask::AllocImage(srcSize);
|
2009-09-18 13:41:56 +00:00
|
|
|
merge_src_with_blur(dst->fImage, src.fRowBytes,
|
|
|
|
sp, src.fRowBytes,
|
2011-08-12 14:59:59 +00:00
|
|
|
dp + passCount * (rx + ry * dst->fRowBytes),
|
|
|
|
dst->fRowBytes, sw, sh);
|
2008-12-17 15:59:43 +00:00
|
|
|
SkMask::FreeImage(dp);
|
2009-09-18 13:41:56 +00:00
|
|
|
} else if (style != kNormal_Style) {
|
2011-08-12 14:59:59 +00:00
|
|
|
clamp_with_orig(dp + passCount * (rx + ry * dst->fRowBytes),
|
|
|
|
dst->fRowBytes, sp, src.fRowBytes, sw, sh, style);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
(void)autoCall.detach();
|
|
|
|
}
|
|
|
|
|
2009-09-18 13:41:56 +00:00
|
|
|
if (style == kInner_Style) {
|
2008-12-17 15:59:43 +00:00
|
|
|
dst->fBounds = src.fBounds; // restore trimmed bounds
|
2009-09-18 13:41:56 +00:00
|
|
|
dst->fRowBytes = src.fRowBytes;
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-13 20:35:21 +00:00
|
|
|
bool SkBlurMask::BlurSeparable(SkMask* dst, const SkMask& src,
|
|
|
|
SkScalar radius, Style style, Quality quality,
|
|
|
|
SkIPoint* margin)
|
|
|
|
{
|
|
|
|
return SkBlurMask::Blur(dst, src, radius, style, quality, margin, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkBlurMask::Blur(SkMask* dst, const SkMask& src,
|
|
|
|
SkScalar radius, Style style, Quality quality,
|
|
|
|
SkIPoint* margin)
|
|
|
|
{
|
|
|
|
return SkBlurMask::Blur(dst, src, radius, style, quality, margin, false);
|
|
|
|
}
|
2013-01-04 20:29:03 +00:00
|
|
|
|
|
|
|
/* Convolving a box with itself three times results in a piecewise
|
|
|
|
quadratic function:
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
0 x <= -1.5
|
|
|
|
9/8 + 3/2 x + 1/2 x^2 -1.5 < x <= 1.5
|
|
|
|
3/4 - x^2 -.5 < x <= .5
|
|
|
|
9/8 - 3/2 x + 1/2 x^2 0.5 < x <= 1.5
|
|
|
|
0 1.5 < x
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
To get the profile curve of the blurred step function at the rectangle
|
|
|
|
edge, we evaluate the indefinite integral, which is piecewise cubic:
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
0 x <= -1.5
|
|
|
|
5/8 + 9/8 x + 3/4 x^2 + 1/6 x^3 -1.5 < x <= -0.5
|
|
|
|
1/2 + 3/4 x - 1/3 x^3 -.5 < x <= .5
|
|
|
|
3/8 + 9/8 x - 3/4 x^2 + 1/6 x^3 .5 < x <= 1.5
|
|
|
|
1 1.5 < x
|
|
|
|
*/
|
|
|
|
|
|
|
|
static float gaussian_integral( float x ) {
|
|
|
|
if ( x > 1.5f ) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
if ( x < -1.5f ) {
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
float x2 = x*x;
|
|
|
|
float x3 = x2*x;
|
|
|
|
|
2013-01-07 18:41:28 +00:00
|
|
|
if ( x > 0.5f ) {
|
|
|
|
return 0.5625f - ( x3 / 6.0f - 3.0f * x2 * 0.25f + 1.125f * x);
|
2013-01-04 20:29:03 +00:00
|
|
|
}
|
2013-01-07 18:41:28 +00:00
|
|
|
if ( x > -0.5f ) {
|
|
|
|
return 0.5f - (0.75f * x - x3 / 3.0f);
|
2013-01-04 20:29:03 +00:00
|
|
|
}
|
2013-01-07 18:41:28 +00:00
|
|
|
return 0.4375f + (-x3 / 6.0f - 3.0f * x2 * 0.25f - 1.125f * x);
|
2013-01-04 20:29:03 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 02:02:05 +00:00
|
|
|
/*
|
2013-01-04 20:29:03 +00:00
|
|
|
compute_profile allocates and fills in an array of floating
|
2013-01-05 02:02:05 +00:00
|
|
|
point values between 0 and 255 for the profile signature of
|
2013-01-04 20:29:03 +00:00
|
|
|
a blurred half-plane with the given blur radius. Since we're
|
|
|
|
going to be doing screened multiplications (i.e., 1 - (1-x)(1-y))
|
|
|
|
all the time, we actually fill in the profile pre-inverted
|
|
|
|
(already done 255-x).
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
The function returns the size of the array allocated for the
|
2013-01-05 02:02:05 +00:00
|
|
|
profile. It's the responsibility of the caller to delete the
|
2013-01-04 20:29:03 +00:00
|
|
|
memory returned in profile_out.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int compute_profile( SkScalar radius, unsigned int **profile_out ) {
|
2013-01-07 18:41:28 +00:00
|
|
|
int size = SkScalarFloorToInt(radius * 3 + 1);
|
2013-01-04 20:29:03 +00:00
|
|
|
int center = size >> 1;
|
|
|
|
|
|
|
|
unsigned int *profile = new unsigned int [size];
|
|
|
|
|
|
|
|
float invr = 1.0f/radius;
|
|
|
|
|
|
|
|
profile[0] = 255;
|
|
|
|
for (int x = 1 ; x < size ; x++) {
|
|
|
|
float scaled_x = ( center - x ) * invr;
|
|
|
|
float gi = gaussian_integral( scaled_x );
|
|
|
|
profile[x] = 255 - (uint8_t) ( 255.f * gi );
|
|
|
|
}
|
|
|
|
|
|
|
|
*profile_out = profile;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2013-01-05 02:02:05 +00:00
|
|
|
// TODO MAYBE: Maintain a profile cache to avoid recomputing this for
|
2013-01-04 20:29:03 +00:00
|
|
|
// commonly used radii. Consider baking some of the most common blur radii
|
|
|
|
// directly in as static data?
|
|
|
|
|
|
|
|
// Implementation adapted from Michael Herf's approach:
|
|
|
|
// http://stereopsis.com/shadowrect/
|
|
|
|
|
|
|
|
bool SkBlurMask::BlurRect(SkMask *dst, const SkRect &src,
|
|
|
|
SkScalar provided_radius, Style style, Quality quality,
|
|
|
|
SkIPoint *margin) {
|
|
|
|
int profile_size;
|
|
|
|
unsigned int *profile;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
float radius = SkScalarToFloat( SkScalarMul( provided_radius, kBlurRadiusFudgeFactor ) );
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
profile_size = compute_profile( radius, &profile );
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
int pad = (int) (radius * 1.5f + 1);
|
|
|
|
if (margin) {
|
|
|
|
margin->set( pad, pad );
|
|
|
|
}
|
2013-01-07 18:41:28 +00:00
|
|
|
dst->fBounds = SkIRect::MakeWH(SkScalarFloorToInt(src.width()), SkScalarFloorToInt(src.height()));
|
2013-01-04 20:29:03 +00:00
|
|
|
dst->fBounds.outset(pad, pad);
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
dst->fRowBytes = dst->fBounds.width();
|
|
|
|
dst->fFormat = SkMask::kA8_Format;
|
|
|
|
dst->fImage = NULL;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
size_t dstSize = dst->computeImageSize();
|
|
|
|
if (0 == dstSize) {
|
|
|
|
return false; // too big to allocate, abort
|
|
|
|
}
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-07 18:41:28 +00:00
|
|
|
int sw = SkScalarFloorToInt(src.width());
|
|
|
|
int sh = SkScalarFloorToInt(src.height());
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
uint8_t* dp = SkMask::AllocImage(dstSize);
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
dst->fImage = dp;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
SkAutoTCallVProc<uint8_t, SkMask_FreeImage> autoCall(dp);
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
int dst_height = dst->fBounds.height();
|
|
|
|
int dst_width = dst->fBounds.width();
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
// nearest odd number less than the profile size represents the center
|
|
|
|
// of the (2x scaled) profile
|
|
|
|
int center = ( profile_size & ~1 ) - 1;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
int w = sw - center;
|
|
|
|
int h = sh - center;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
uint8_t *outptr = dp;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
for (int y = 0 ; y < dst_height ; y++)
|
|
|
|
{
|
|
|
|
// time to fill in a scanline of the blurry rectangle.
|
|
|
|
// to avoid floating point math, everything is multiplied by
|
|
|
|
// 2 where needed. This keeps things nice and integer-oriented.
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
int dy = abs((y << 1) - dst_height) - h; // how far are we from the original edge?
|
|
|
|
int oy = dy >> 1;
|
|
|
|
if (oy < 0) oy = 0;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
unsigned int profile_y = profile[oy];
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
for (int x = 0 ; x < (dst_width << 1) ; x += 2) {
|
|
|
|
int dx = abs( x - dst_width ) - w;
|
|
|
|
int ox = dx >> 1;
|
|
|
|
if (ox < 0) ox = 0;
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
unsigned int maskval = SkMulDiv255Round(profile[ox], profile_y);
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
*(outptr++) = maskval;
|
|
|
|
}
|
|
|
|
}
|
2013-01-05 02:02:05 +00:00
|
|
|
|
2013-01-04 20:29:03 +00:00
|
|
|
return true;
|
|
|
|
}
|