new backend: don't assume center of blur kernel is 1
Also fill the center of parsed kernel with 1. This shouldn't change the behavior of the old backends since they will modify the center of the kernels. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
f64ac97a91
commit
1da726047a
|
@ -18,6 +18,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include "backend/gl/gl_common.h"
|
||||
#include "backend/backend_common.h"
|
||||
|
||||
#define GLSL(version, ...) "#version " #version "\n" #__VA_ARGS__
|
||||
#define QUOTE(...) #__VA_ARGS__
|
||||
|
@ -713,11 +714,7 @@ static bool gl_init_blur(struct gl_data *gd, conv *const *const kernels, int nke
|
|||
for (int j = 0; j < height; ++j) {
|
||||
for (int k = 0; k < width; ++k) {
|
||||
double val;
|
||||
if (height / 2 == j && width / 2 == k) {
|
||||
val = 1;
|
||||
} else {
|
||||
val = kern->data[j * width + k];
|
||||
}
|
||||
if (val == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -183,9 +183,10 @@ static bool blur(backend_t *backend_data, double opacity, const region_t *reg_bl
|
|||
// be applied on source picture, to get the nearby pixels outside the
|
||||
// window.
|
||||
// TODO cache converted blur_kerns
|
||||
xcb_render_set_picture_filter(
|
||||
c, src_pict, to_u16_checked(strlen(filter)), filter,
|
||||
to_u32_checked(xd->x_blur_kernel[i]->size), xd->x_blur_kernel[i]->kernel);
|
||||
xcb_render_set_picture_filter(c, src_pict, to_u16_checked(strlen(filter)),
|
||||
filter,
|
||||
to_u32_checked(xd->x_blur_kernel[i]->size),
|
||||
xd->x_blur_kernel[i]->kernel);
|
||||
|
||||
if (i < xd->x_blur_kernel_count - 1 || i == 0) {
|
||||
// This is not the last pass, or this is the first pass
|
||||
|
@ -552,7 +553,10 @@ backend_t *backend_xrender_init(session_t *ps) {
|
|||
|
||||
xd->x_blur_kernel = ccalloc(ps->o.blur_kernel_count, struct x_convolution_kernel *);
|
||||
for (int i = 0; i < ps->o.blur_kernel_count; i++) {
|
||||
x_create_convolution_kernel(ps->o.blur_kerns[i], 1, &xd->x_blur_kernel[i]);
|
||||
int center = ps->o.blur_kerns[i]->h * ps->o.blur_kerns[i]->w / 2;
|
||||
x_create_convolution_kernel(ps->o.blur_kerns[i],
|
||||
ps->o.blur_kerns[i]->data[center],
|
||||
&xd->x_blur_kernel[i]);
|
||||
}
|
||||
xd->x_blur_kernel_count = ps->o.blur_kernel_count;
|
||||
return &xd->base;
|
||||
|
|
|
@ -139,7 +139,7 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
|
|||
for (int i = 0; i < width * height; ++i) {
|
||||
// Ignore the center element
|
||||
if (i == skip) {
|
||||
matrix->data[i] = 0;
|
||||
matrix->data[i] = 1;
|
||||
continue;
|
||||
}
|
||||
if (src == (pc = parse_readnum(src, &val))) {
|
||||
|
|
Loading…
Reference in New Issue