cssshadows: Reengineer API

This way we have an API to query extents per shadow and I want that in
the next patch.
This commit is contained in:
Benjamin Otte 2016-11-19 20:13:54 +01:00
parent 2745c2502f
commit c45f8b1a25
3 changed files with 17 additions and 34 deletions

View File

@ -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 == &GTK_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);
}
}

View File

@ -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 == &GTK_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

View File

@ -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,