[gtk+/wip/pango-shadow-cache: 4/5] needs blur
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/pango-shadow-cache: 4/5] needs blur
- Date: Fri, 29 Aug 2014 22:02:35 +0000 (UTC)
commit 639a4d31e6f7fb4ac7e221f3a17d3ae27e77910a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Aug 29 14:48:29 2014 -0700
needs blur
gtk/gtkcssshadowvalue.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 260ec17..7e8e3b0 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -312,6 +312,16 @@ fail:
static const cairo_user_data_key_t shadow_key;
+static gboolean
+needs_blur (const GtkCssValue *shadow)
+{
+ double radius = _gtk_css_number_value_get (shadow->radius, 0);
+ if (radius == 0.0)
+ return FALSE;
+
+ return TRUE;
+}
+
static cairo_t *
gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow,
cairo_t *cr)
@@ -327,12 +337,12 @@ gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow,
_gtk_css_number_value_get (shadow->hoffset, 0),
_gtk_css_number_value_get (shadow->voffset, 0));
- radius = _gtk_css_number_value_get (shadow->radius, 0);
- if (radius == 0.0)
+ if (!needs_blur (shadow))
return cr;
gdk_cairo_get_clip_rectangle (cr, &clip_rect);
+ radius = _gtk_css_number_value_get (shadow->radius, 0);
clip_radius = _gtk_cairo_blur_compute_pixels (radius);
/* Create a larger surface to center the blur. */
@@ -362,16 +372,15 @@ gtk_css_shadow_value_finish_drawing (const GtkCssValue *shadow,
cairo_t *original_cr;
cairo_surface_t *surface;
- radius = _gtk_css_number_value_get (shadow->radius, 0);
- if (radius == 0.0)
+ if (!needs_blur (shadow))
return cr;
- surface = cairo_get_target (cr);
original_cr = cairo_get_user_data (cr, &shadow_key);
/* Blur the surface. */
+ surface = cairo_get_target (cr);
+ radius = _gtk_css_number_value_get (shadow->radius, 0);
_gtk_cairo_blur_surface (surface, radius);
-
cairo_mask_surface (original_cr, surface, 0, 0);
cairo_destroy (cr);
@@ -574,7 +583,7 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
clip_box = *padding_box;
_gtk_rounded_box_shrink (&clip_box, -clip_radius, -clip_radius, -clip_radius, -clip_radius);
- if (radius == 0)
+ if (!needs_blur (shadow))
draw_shadow (shadow, cr, &box, &clip_box, FALSE);
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]