Ensure blur nodes have a positive blur radius
authorTimm Bäder <mail@baedert.org>
Sun, 17 Oct 2021 10:15:34 +0000 (12:15 +0200)
committerTimm Bäder <mail@baedert.org>
Sun, 17 Oct 2021 10:15:34 +0000 (12:15 +0200)
gsk/gskrendernodeimpl.c
gtk/gtksnapshot.c

index 28cb14ae642ec1bad5672ac55e983478c1fcec82..d318fe9eec293127b060e6c6974036faf7d0318c 100644 (file)
@@ -4858,7 +4858,7 @@ gsk_blur_node_diff (GskRenderNode  *node1,
 /**
  * gsk_blur_node_new:
  * @child: the child node to blur
- * @radius: the blur radius
+ * @radius: the blur radius. Must be positive
  *
  * Creates a render node that blurs the child.
  *
@@ -4873,6 +4873,7 @@ gsk_blur_node_new (GskRenderNode *child,
   float clip_radius;
 
   g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
+  g_return_val_if_fail (radius >= 0, NULL);
 
   self = gsk_render_node_alloc (GSK_BLUR_NODE);
   node = (GskRenderNode *) self;
index 8b8627fb92752b9e9a74e7c93f00c3a0788dbd20..114c06fa8489f31999097c5561220ae2bc449553 100644 (file)
@@ -520,6 +520,9 @@ gtk_snapshot_collect_blur (GtkSnapshot      *snapshot,
   if (radius == 0.0)
     return node;
 
+  if (radius < 0)
+    return node;
+
   blur_node = gsk_blur_node_new (node, radius);
 
   gsk_render_node_unref (node);
@@ -530,7 +533,7 @@ gtk_snapshot_collect_blur (GtkSnapshot      *snapshot,
 /**
  * gtk_snapshot_push_blur:
  * @snapshot: a `GtkSnapshot`
- * @radius: the blur radius to use
+ * @radius: the blur radius to use. Must be positive
  *
  * Blurs an image.
  *