rendernode: Clarify some Cairo stuff
authorBenjamin Otte <otte@redhat.com>
Mon, 13 Feb 2023 00:31:12 +0000 (01:31 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 3 Mar 2023 17:24:46 +0000 (11:24 -0600)
Split out a function to make it more obvious what's going on.

gsk/gskrendernodeimpl.c

index a84085c9c6b585a1291e6fd4fd50c953f5831fdf..d0bd24b7247290d1d6b149b5ae43d5354a4a3055 100644 (file)
@@ -58,6 +58,16 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
   cairo->height = ceilf (graphene->origin.y + graphene->size.height) - cairo->y;
 }
 
+static void
+_graphene_rect_init_from_clip_extents (graphene_rect_t *rect,
+                                       cairo_t         *cr)
+{
+  double x1c, y1c, x2c, y2c;
+
+  cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
+  graphene_rect_init (rect, x1c, y1c, x2c - x1c, y2c - y1c);
+}
+
 /* {{{ GSK_COLOR_NODE */
 
 /**
@@ -2069,15 +2079,15 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
   GskInsetShadowNode *self = (GskInsetShadowNode *) node;
   GskRoundedRect box, clip_box;
   int clip_radius;
-  double x1c, y1c, x2c, y2c;
+  graphene_rect_t clip_rect;
   double blur_radius;
 
   /* We don't need to draw invisible shadows */
   if (gdk_rgba_is_clear (&self->color))
     return;
 
-  cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
-  if (!gsk_rounded_rect_intersects_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
+  _graphene_rect_init_from_clip_extents (&clip_rect, cr);
+  if (!gsk_rounded_rect_intersects_rect (&self->outline, &clip_rect))
     return;
 
   blur_radius = self->blur_radius / 2;
@@ -2365,7 +2375,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
   GskOutsetShadowNode *self = (GskOutsetShadowNode *) node;
   GskRoundedRect box, clip_box;
   int clip_radius;
-  double x1c, y1c, x2c, y2c;
+  graphene_rect_t clip_rect;
   float top, right, bottom, left;
   double blur_radius;
 
@@ -2373,8 +2383,8 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
   if (gdk_rgba_is_clear (&self->color))
     return;
 
-  cairo_clip_extents (cr, &x1c, &y1c, &x2c, &y2c);
-  if (gsk_rounded_rect_contains_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
+  _graphene_rect_init_from_clip_extents (&clip_rect, cr);
+  if (!gsk_rounded_rect_intersects_rect (&self->outline, &clip_rect))
     return;
 
   blur_radius = self->blur_radius / 2;