[librsvg/librsvg-2.40] bgo#783835 - Don't divide by zero in box_blur_line() for gaussian blurs
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.40] bgo#783835 - Don't divide by zero in box_blur_line() for gaussian blurs
- Date: Tue, 27 Jun 2017 22:18:29 +0000 (UTC)
commit 735bd813d7657f24dba222fa6e5be8f66491ef77
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jun 27 17:12:51 2017 -0500
bgo#783835 - Don't divide by zero in box_blur_line() for gaussian blurs
We were making the decision to use box blurs, instead of a true
Gaussian kernel, based on the size of *both* x and y dimensions. Do
them individually instead.
rsvg-filter.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index 81cce75..b9e7428 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -1331,7 +1331,9 @@ box_blur_line (gint box_width, gint even_offset,
kernel; it's the pixel to remove from the accumulator. */
gint *ac; /* Accumulator for each channel */
- ac = g_new (gint, bpp);
+ g_assert (box_width > 0);
+
+ ac = g_new0 (gint, bpp);
/* The algorithm differs for even and odd-sized kernels.
* With the output at the center,
@@ -1688,7 +1690,6 @@ gaussian_blur_surface (cairo_surface_t *in,
gdouble sx,
gdouble sy)
{
- gboolean use_box_blur;
gint width, height;
cairo_format_t in_format, out_format;
gint in_stride;
@@ -1732,14 +1733,6 @@ gaussian_blur_surface (cairo_surface_t *in,
if (sy < 0.0)
sy = 0.0;
- /* For small radiuses, use a true gaussian kernel; otherwise use three box blurs with
- * clever offsets.
- */
- if (sx < 10.0 && sy < 10.0)
- use_box_blur = FALSE;
- else
- use_box_blur = TRUE;
-
/* Bail out by just copying? */
if ((sx == 0.0 && sy == 0.0)
|| sx > 1000 || sy > 1000) {
@@ -1759,6 +1752,15 @@ gaussian_blur_surface (cairo_surface_t *in,
int y;
guchar *row_buffer = NULL;
guchar *row1, *row2;
+ gboolean use_box_blur;
+
+ /* For small radiuses, use a true gaussian kernel; otherwise use three box blurs with
+ * clever offsets.
+ */
+ if (sx < 10.0)
+ use_box_blur = FALSE;
+ else
+ use_box_blur = TRUE;
if (use_box_blur) {
box_width = compute_box_blur_width (sx);
@@ -1814,6 +1816,15 @@ gaussian_blur_surface (cairo_surface_t *in,
guchar *col_buffer;
guchar *col1, *col2;
int x;
+ gboolean use_box_blur;
+
+ /* For small radiuses, use a true gaussian kernel; otherwise use three box blurs with
+ * clever offsets.
+ */
+ if (sy < 10.0)
+ use_box_blur = FALSE;
+ else
+ use_box_blur = TRUE;
/* twice the size so we can have the source pixels and the blurred pixels */
col_buffer = g_new (guchar, height * bpp * 2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]