From c45f8b1a25c4ef06773c06d30c30199097d29d96 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 19 Nov 2016 20:13:54 +0100 Subject: [PATCH] cssshadows: Reengineer API This way we have an API to query extents per shadow and I want that in the next patch. --- gtk/gtkcssshadowsvalue.c | 18 +++--------------- gtk/gtkcssshadowvalue.c | 26 ++++++++++++-------------- gtk/gtkcssshadowvalueprivate.h | 7 ++----- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c index b58dde3f11..e2be207ad6 100644 --- a/gtk/gtkcssshadowsvalue.c +++ b/gtk/gtkcssshadowsvalue.c @@ -320,9 +320,8 @@ _gtk_css_shadows_value_get_extents (const GtkCssValue *shadows, GtkBorder *border) { guint i; - GtkBorder b = { 0 }; + GtkBorder b = { 0 }, sb; const GtkCssValue *shadow; - gdouble hoffset, voffset, spread, radius, clip_radius; g_return_if_fail (shadows->class == >K_CSS_VALUE_SHADOWS); @@ -335,19 +334,8 @@ _gtk_css_shadows_value_get_extents (const GtkCssValue *shadows, if (_gtk_css_shadow_value_get_inset (shadow)) continue; - _gtk_css_shadow_value_get_geometry (shadow, - &hoffset, &voffset, - &radius, &spread); - clip_radius = _gtk_cairo_blur_compute_pixels (radius); + gtk_css_shadow_value_get_extents (shadow, &sb); - b.top = MAX (0, ceil (clip_radius + spread - voffset)); - b.right = MAX (0, ceil (clip_radius + spread + hoffset)); - b.bottom = MAX (0, ceil (clip_radius + spread + voffset)); - b.left = MAX (0, ceil (clip_radius + spread - hoffset)); - - border->top = MAX (border->top, b.top); - border->right = MAX (border->right, b.right); - border->bottom = MAX (border->bottom, b.bottom); - border->left = MAX (border->left, b.left); + b.top = MAX (b.top, sb.top); } } diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index eb8fc9e658..a17b213e3d 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -605,23 +605,21 @@ _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow) } void -_gtk_css_shadow_value_get_geometry (const GtkCssValue *shadow, - gdouble *hoffset, - gdouble *voffset, - gdouble *radius, - gdouble *spread) +gtk_css_shadow_value_get_extents (const GtkCssValue *shadow, + GtkBorder *border) { - g_return_if_fail (shadow->class == >K_CSS_VALUE_SHADOW); + gdouble hoffset, voffset, spread, radius, clip_radius; - if (hoffset != NULL) - *hoffset = _gtk_css_number_value_get (shadow->hoffset, 0); - if (voffset != NULL) - *voffset = _gtk_css_number_value_get (shadow->voffset, 0); + spread = _gtk_css_number_value_get (shadow->spread, 0); + radius = _gtk_css_number_value_get (shadow->radius, 0); + clip_radius = _gtk_cairo_blur_compute_pixels (radius); + hoffset = _gtk_css_number_value_get (shadow->hoffset, 0); + voffset = _gtk_css_number_value_get (shadow->voffset, 0); - if (radius != NULL) - *radius = _gtk_css_number_value_get (shadow->radius, 0); - if (spread != NULL) - *spread = _gtk_css_number_value_get (shadow->spread, 0); + border->top = MAX (0, ceil (clip_radius + spread - voffset)); + border->right = MAX (0, ceil (clip_radius + spread + hoffset)); + border->bottom = MAX (0, ceil (clip_radius + spread + voffset)); + border->left = MAX (0, ceil (clip_radius + spread - hoffset)); } static gboolean diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h index 5fab1cc905..5b89944525 100644 --- a/gtk/gtkcssshadowvalueprivate.h +++ b/gtk/gtkcssshadowvalueprivate.h @@ -37,11 +37,8 @@ GtkCssValue * _gtk_css_shadow_value_parse (GtkCssParser gboolean _gtk_css_shadow_value_get_inset (const GtkCssValue *shadow); -void _gtk_css_shadow_value_get_geometry (const GtkCssValue *shadow, - gdouble *hoffset, - gdouble *voffset, - gdouble *radius, - gdouble *spread); +void gtk_css_shadow_value_get_extents (const GtkCssValue *shadow, + GtkBorder *border); void _gtk_css_shadow_value_paint_layout (const GtkCssValue *shadow, cairo_t *cr,