css shadows: Exit early if clip is empty

This commit is contained in:
Alexander Larsson 2013-05-06 12:34:09 +02:00
parent 70774bf978
commit 5ba5306dc9

View File

@ -475,6 +475,15 @@ _gtk_css_shadow_value_get_geometry (const GtkCssValue *shadow,
*spread = _gtk_css_number_value_get (shadow->spread, 0);
}
static gboolean
has_empty_clip (cairo_t *cr)
{
double x1, y1, x2, y2;
cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
return x1 == x2 && y1 == y2;
}
static void
draw_shadow (const GtkCssValue *shadow,
cairo_t *cr,
@ -483,6 +492,9 @@ draw_shadow (const GtkCssValue *shadow,
{
cairo_t *shadow_cr;
if (has_empty_clip (cr))
return;
shadow_cr = gtk_css_shadow_value_start_drawing (shadow, cr);
cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
@ -530,6 +542,12 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_clip (cr);
}
if (has_empty_clip (cr))
{
cairo_restore (cr);
return;
}
box = *padding_box;
_gtk_rounded_box_move (&box, x, y);