Commit af2c40bd authored by Alexander Larsson's avatar Alexander Larsson

css: Add a scale argument to css-value compute vfunc

We need to be able to compute different GtkCssImage values
depending on the scale, and we need this at compute time so that
we don't need to read any images other than the scale in used (to
e.g. calculate the image size). GtkStyleProviderPrivate is shared
for all style contexts, so its not right.
parent 38e1748d
......@@ -46,6 +46,7 @@ static GtkCssValue *
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -58,7 +59,7 @@ gtk_css_value_array_compute (GtkCssValue *value,
result = NULL;
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
......
......@@ -44,6 +44,7 @@ static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -58,10 +59,10 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
x = y = NULL;
if (value->x)
x = _gtk_css_value_compute (value->x, property_id, provider, values, parent_values, &x_deps);
x = _gtk_css_value_compute (value->x, property_id, provider, scale, values, parent_values, &x_deps);
if (value->y)
y = _gtk_css_value_compute (value->y, property_id, provider, values, parent_values, &y_deps);
y = _gtk_css_value_compute (value->y, property_id, provider, scale, values, parent_values, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
......
......@@ -45,6 +45,7 @@ static GtkCssValue *
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -61,7 +62,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
{
if (value->values[i])
{
computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
changed |= (computed->values[i] != value->values[i]);
}
......
......@@ -101,6 +101,7 @@ gtk_css_value_color_free (GtkCssValue *color)
static GtkCssValue *
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
{
......@@ -124,6 +125,7 @@ gtk_css_value_color_get_fallback (guint property_id,
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
scale,
values,
parent_values,
NULL);
......@@ -297,6 +299,7 @@ static GtkCssValue *
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -335,7 +338,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
NULL);
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, values, parent_values);
return gtk_css_value_color_get_fallback (property_id, provider, scale, values, parent_values);
return resolved;
}
......
......@@ -113,6 +113,7 @@ maybe_unref_section (gpointer section)
void
_gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *parent_values,
guint id,
GtkCssValue *specified,
......@@ -142,7 +143,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
else
_gtk_css_value_ref (specified);
value = _gtk_css_value_compute (specified, id, provider, values, parent_values, &dependencies);
value = _gtk_css_value_compute (specified, id, provider, scale, values, parent_values, &dependencies);
_gtk_css_computed_values_set_value (values, id, value, dependencies, section);
......@@ -445,6 +446,7 @@ gtk_css_computed_values_create_css_animations (GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animations;
......@@ -489,7 +491,7 @@ gtk_css_computed_values_create_css_animations (GtkCssComputedValues *values,
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, values, parent_values);
keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, values, parent_values);
animation = _gtk_css_animation_new (name,
keyframes,
......@@ -514,11 +516,12 @@ _gtk_css_computed_values_create_animations (GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source)
{
if (source != NULL)
gtk_css_computed_values_create_css_transitions (values, timestamp, source);
gtk_css_computed_values_create_css_animations (values, parent_values, timestamp, provider, source);
gtk_css_computed_values_create_css_animations (values, parent_values, timestamp, provider, scale, source);
}
GtkBitmask *
......
......@@ -66,6 +66,7 @@ GtkCssComputedValues * _gtk_css_computed_values_new (void);
void _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *parent_values,
guint id,
GtkCssValue *specified,
......@@ -94,6 +95,7 @@ void _gtk_css_computed_values_create_animations (GtkCssCom
GtkCssComputedValues *parent_values,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *source);
GtkBitmask * _gtk_css_computed_values_advance (GtkCssComputedValues *values,
gint64 timestamp);
......
......@@ -40,6 +40,7 @@ static GtkCssValue *
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -47,8 +48,8 @@ gtk_css_value_corner_compute (GtkCssValue *corner,
GtkCssValue *x, *y;
GtkCssDependencies x_deps, y_deps;
x = _gtk_css_value_compute (corner->x, property_id, provider, values, parent_values, &x_deps);
y = _gtk_css_value_compute (corner->y, property_id, provider, values, parent_values, &y_deps);
x = _gtk_css_value_compute (corner->x, property_id, provider, scale, values, parent_values, &x_deps);
y = _gtk_css_value_compute (corner->y, property_id, provider, scale, values, parent_values, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
if (x == corner->x && y == corner->y)
{
......
......@@ -53,6 +53,7 @@ static GtkCssValue *
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -38,6 +38,7 @@ static GtkCssValue *
gtk_css_value_engine_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -41,6 +41,7 @@ static GtkCssValue *
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -164,6 +165,7 @@ static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -62,6 +62,7 @@ static GtkCssImage *
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -146,6 +147,7 @@ GtkCssImage *
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -163,7 +165,7 @@ _gtk_css_image_compute (GtkCssImage *image,
klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->compute (image, property_id, provider, values, parent_values, dependencies);
return klass->compute (image, property_id, provider, scale, values, parent_values, dependencies);
}
GtkCssImage *
......
......@@ -34,6 +34,7 @@ static GtkCssImage *
gtk_css_image_gradient_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -420,6 +420,7 @@ static GtkCssImage *
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -431,7 +432,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, values, parent_values, dependencies);
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, scale, values, parent_values, dependencies);
g_array_set_size (copy->stops, linear->stops->len);
for (i = 0; i < linear->stops->len; i++)
......@@ -442,12 +443,12 @@ gtk_css_image_linear_compute (GtkCssImage *image,
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
scopy = &g_array_index (copy->stops, GtkCssImageLinearColorStop, i);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, values, parent_values, &child_deps);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, values, parent_values, &child_deps);
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
}
else
......
......@@ -58,6 +58,7 @@ struct _GtkCssImageClass
GtkCssImage *(* compute) (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies);
......@@ -95,6 +96,7 @@ double _gtk_css_image_get_aspect_ratio (GtkCssImage *
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies);
......
......@@ -120,6 +120,7 @@ static GtkCssImage *
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -48,7 +49,7 @@ gtk_css_value_image_compute (GtkCssValue *value,
if (image == NULL)
return _gtk_css_value_ref (value);
computed = _gtk_css_image_compute (image, property_id, provider, values, parent_values, dependencies);
computed = _gtk_css_image_compute (image, property_id, provider, scale, values, parent_values, dependencies);
if (computed == image)
{
......
......@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -51,6 +52,7 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
return _gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
provider,
scale,
values,
parent_values,
dependencies);
......
......@@ -40,6 +40,7 @@ static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -80,6 +81,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
scale,
values,
parent_values,
dependencies);
......
......@@ -427,6 +427,7 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
GtkCssKeyframes *
_gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
{
......@@ -455,6 +456,7 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
KEYFRAMES_VALUE (resolved, k, p) = _gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
resolved->property_ids[p],
provider,
scale,
values,
parent_values,
NULL);
......
......@@ -38,6 +38,7 @@ void _gtk_css_keyframes_print (GtkCssKeyframes
GtkCssKeyframes * _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values);
......
......@@ -140,6 +140,7 @@ _gtk_css_lookup_set_computed (GtkCssLookup *lookup,
void
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values)
{
......@@ -164,6 +165,7 @@ _gtk_css_lookup_resolve (GtkCssLookup *lookup,
_gtk_bitmask_get (lookup->missing, i))
_gtk_css_computed_values_compute_value (values,
provider,
scale,
parent_values,
i,
lookup->values[i].value,
......
......@@ -55,6 +55,7 @@ void _gtk_css_lookup_set_computed (GtkCssLookup
GtkCssValue *value);
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values);
......
......@@ -59,6 +59,7 @@ static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -40,6 +40,7 @@ static GtkCssValue *
gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -47,8 +48,8 @@ gtk_css_value_position_compute (GtkCssValue *position,
GtkCssValue *x, *y;
GtkCssDependencies x_deps, y_deps;
x = _gtk_css_value_compute (position->x, property_id, provider, values, parent_values, &x_deps);
y = _gtk_css_value_compute (position->y, property_id, provider, values, parent_values, &y_deps);
x = _gtk_css_value_compute (position->x, property_id, provider, scale, values, parent_values, &x_deps);
y = _gtk_css_value_compute (position->y, property_id, provider, scale, values, parent_values, &y_deps);
*dependencies = _gtk_css_dependencies_union (x_deps, y_deps);
if (x == position->x && y == position->y)
{
......
......@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_rgba_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -51,6 +51,7 @@ static GtkCssValue *
gtk_css_value_shadows_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -65,7 +66,7 @@ gtk_css_value_shadows_compute (GtkCssValue *value,
result = gtk_css_shadows_value_new (value->values, value->len);
for (i = 0; i < value->len; i++)
{
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
}
......
......@@ -70,6 +70,7 @@ static GtkCssValue *
gtk_css_value_shadow_compute (GtkCssValue *shadow,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -78,23 +79,23 @@ gtk_css_value_shadow_compute (GtkCssValue *shadow,
GtkCssDependencies child_deps;
child_deps = 0;
hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, values, parent_values, &child_deps);
hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, values, parent_values, &child_deps);
voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
radius = _gtk_css_value_compute (shadow->radius, property_id, provider, values, parent_values, &child_deps);
radius = _gtk_css_value_compute (shadow->radius, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, values, parent_values, &child_deps),
spread = _gtk_css_value_compute (shadow->spread, property_id, provider, scale, values, parent_values, &child_deps),
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
child_deps = 0;
color = _gtk_css_value_compute (shadow->color, property_id, provider, values, parent_values, &child_deps);
color = _gtk_css_value_compute (shadow->color, property_id, provider, scale, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
......
......@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -38,6 +38,7 @@ static GtkCssValue *
gtk_css_value_typed_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......
......@@ -88,6 +88,7 @@ GtkCssValue *
_gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
......@@ -103,7 +104,7 @@ _gtk_css_value_compute (GtkCssValue *value,
dependencies = &fallback;
*dependencies = 0;
return value->class->compute (value, property_id, provider, values, parent_values, dependencies);
return value->class->compute (value, property_id, provider, scale, values, parent_values, dependencies);
}
gboolean
......
......@@ -43,6 +43,7 @@ struct _GtkCssValueClass {
GtkCssValue * (* compute) (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies);
......@@ -68,6 +69,7 @@ void _gtk_css_value_unref (GtkCssValue
GtkCssValue *_gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies);
......
......@@ -3295,6 +3295,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
priv->parent ? style_data_lookup (priv->parent)->store : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
current && gtk_style_context_should_create_transitions (context) ? current->store : NULL);
if (_gtk_css_computed_values_is_static (data->store))
change &= ~GTK_CSS_CHANGE_ANIMATE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment