Commit cb0b4b54 authored by Benjamin Otte's avatar Benjamin Otte

css: Change CssTransformValue API

Provide API to query the matrix instead of API that applies the matrix
directly. This makes the API more flexible.

See the commits implementing shadows.
parent ce0835e5
......@@ -198,8 +198,8 @@ gtk_css_transform_apply (const GtkCssTransform *transform,
/* NB: The returned matrix may be invalid */
static void
gtk_css_transform_value_get_matrix (const GtkCssValue *value,
cairo_matrix_t *matrix)
gtk_css_transform_value_compute_matrix (const GtkCssValue *value,
cairo_matrix_t *matrix)
guint i;
......@@ -637,9 +637,9 @@ gtk_css_value_transform_transition (GtkCssValue *start,
cairo_matrix_t start_matrix, end_matrix;
cairo_matrix_init_identity (&start_matrix);
gtk_css_transform_value_get_matrix (start, &start_matrix);
gtk_css_transform_value_compute_matrix (start, &start_matrix);
cairo_matrix_init_identity (&end_matrix);
gtk_css_transform_value_get_matrix (end, &end_matrix);
gtk_css_transform_value_compute_matrix (end, &end_matrix);
result = gtk_css_transform_value_alloc (1);
result->transforms[0].type = GTK_CSS_TRANSFORM_MATRIX;
......@@ -1028,22 +1028,21 @@ _gtk_css_transform_value_parse (GtkCssParser *parser)
_gtk_css_transform_value_apply (const GtkCssValue *transform,
cairo_t *cr)
_gtk_css_transform_value_get_matrix (const GtkCssValue *transform,
cairo_matrix_t *matrix)
cairo_matrix_t matrix, invert;
cairo_matrix_t invert;
g_return_val_if_fail (transform->class == &GTK_CSS_VALUE_TRANSFORM, FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
g_return_val_if_fail (matrix != NULL, FALSE);
gtk_css_transform_value_get_matrix (transform, &matrix);
gtk_css_transform_value_compute_matrix (transform, &invert);
*matrix = invert;
invert = matrix;
if (cairo_matrix_invert (&invert) != CAIRO_STATUS_SUCCESS)
return FALSE;
cairo_transform (cr, &matrix);
return TRUE;
......@@ -28,8 +28,8 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_transform_value_new_none (void);
GtkCssValue * _gtk_css_transform_value_parse (GtkCssParser *parser);
gboolean _gtk_css_transform_value_apply (const GtkCssValue *transform,
cairo_t *cr);
gboolean _gtk_css_transform_value_get_matrix (const GtkCssValue *transform,
cairo_matrix_t *matrix);
......@@ -1032,6 +1032,7 @@ render_icon_image (GtkThemingEngine *engine,
double height)
const GtkCssValue *shadows;
cairo_matrix_t matrix;
GtkCssImage *image;
image = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SOURCE));
......@@ -1040,11 +1041,11 @@ render_icon_image (GtkThemingEngine *engine,
shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
cairo_translate (cr, x, y);
cairo_translate (cr, width / 2, height / 2);
if (_gtk_css_transform_value_apply (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_TRANSFORM), cr))
if (_gtk_css_transform_value_get_matrix (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_TRANSFORM), &matrix))
cairo_translate (cr, x, y);
cairo_translate (cr, width / 2, height / 2);
cairo_transform (cr, &matrix);
cairo_translate (cr, -width / 2, -height / 2);
if (!_gtk_css_shadows_value_is_none (shadows))
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