[gtk+/wip/css-icons] css: Change CssTransformValue API



commit 0fb8eb01c6abdd4fda5e0c3f26a2dd6c7b05aea8
Author: Benjamin Otte <otte redhat com>
Date:   Mon May 12 03:51:14 2014 +0200

    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.

 gtk/gtkcsstransformvalue.c        |   23 +++++++++++------------
 gtk/gtkcsstransformvalueprivate.h |    4 ++--
 gtk/gtkthemingengine.c            |    9 +++++----
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkcsstransformvalue.c b/gtk/gtkcsstransformvalue.c
index 9fcbfb9..3034403 100644
--- a/gtk/gtkcsstransformvalue.c
+++ b/gtk/gtkcsstransformvalue.c
@@ -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)
 }
 
 gboolean
-_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;
 }
 
diff --git a/gtk/gtkcsstransformvalueprivate.h b/gtk/gtkcsstransformvalueprivate.h
index 2c57c3f..49411ff 100644
--- a/gtk/gtkcsstransformvalueprivate.h
+++ b/gtk/gtkcsstransformvalueprivate.h
@@ -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);
 
 G_END_DECLS
 
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index f85baba..64b9f8f 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -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))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]