Skip to content

Commit 006371d

Browse files
committed
scale blur radius and pixelate size
1 parent 725a0e3 commit 006371d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

effects.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,17 @@ static void blur_once(uint32_t *dest, uint32_t *src, uint32_t *scratch,
231231
// This effect_blur function, and the associated blur_* functions,
232232
// are my own adaptations of code in yvbbrjdr's i3lock-fancy-rapid:
233233
// https://github.com/yvbbrjdr/i3lock-fancy-rapid
234-
static void effect_blur(uint32_t *dest, uint32_t *src, int width, int height,
234+
static void effect_blur(uint32_t *dest, uint32_t *src, int width, int height, int scale,
235235
int radius, int times) {
236236
uint32_t *origdest = dest;
237237

238238
uint32_t *scratch = malloc(width * height * sizeof(*scratch));
239-
blur_once(dest, src, scratch, width, height, radius);
239+
blur_once(dest, src, scratch, width, height, radius * scale);
240240
for (int i = 0; i < times - 1; ++i) {
241241
uint32_t *tmp = src;
242242
src = dest;
243243
dest = tmp;
244-
blur_once(dest, src, scratch, width, height, radius);
244+
blur_once(dest, src, scratch, width, height, radius * scale);
245245
}
246246
free(scratch);
247247

@@ -251,7 +251,8 @@ static void effect_blur(uint32_t *dest, uint32_t *src, int width, int height,
251251
memcpy(origdest, dest, width * height * sizeof(*dest));
252252
}
253253

254-
static void effect_pixelate(uint32_t *data, int width, int height, int factor) {
254+
static void effect_pixelate(uint32_t *data, int width, int height, int scale, int factor) {
255+
factor *= scale;
255256
#pragma omp parallel for
256257
for (int y = 0; y < height / factor + 1; ++y) {
257258
for (int x = 0; x < width / factor + 1; ++x) {
@@ -594,6 +595,7 @@ static cairo_surface_t *run_effect(cairo_surface_t *surface, int scale,
594595
(uint32_t *)cairo_image_surface_get_data(surface),
595596
cairo_image_surface_get_width(surface),
596597
cairo_image_surface_get_height(surface),
598+
scale,
597599
effect->e.blur.radius, effect->e.blur.times);
598600
cairo_surface_flush(surf);
599601
cairo_surface_destroy(surface);
@@ -606,6 +608,7 @@ static cairo_surface_t *run_effect(cairo_surface_t *surface, int scale,
606608
(uint32_t *)cairo_image_surface_get_data(surface),
607609
cairo_image_surface_get_width(surface),
608610
cairo_image_surface_get_height(surface),
611+
scale,
609612
effect->e.pixelate.factor);
610613
cairo_surface_flush(surface);
611614
break;

0 commit comments

Comments
 (0)