[gtk+/cellarea-style-transitions: 1/9] stylecontext: store device space coordinates for transitions



commit c5cdc73d9e411648d891f4023f53449c1e15b23a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 10 23:55:50 2011 +0200

    stylecontext: store device space coordinates for transitions
    
    This is so transitions take into account user-space transforms
    on the cairo_t at the gtk_render_*() call time.

 gtk/gtkstylecontext.c |   42 ++++++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index ca0c96e..12654e5 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3168,7 +3168,6 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
   while (l)
     {
       AnimationInfo *info;
-      gint rel_x, rel_y;
       GSList *cur;
       guint i;
 
@@ -3183,20 +3182,12 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
         continue;
 
       info->invalidation_region = cairo_region_create ();
-      _gtk_widget_get_translation_to_window (widget, info->window, &rel_x, &rel_y);
 
       for (i = 0; i < info->rectangles->len; i++)
         {
           cairo_rectangle_int_t *rect;
 
           rect = &g_array_index (info->rectangles, cairo_rectangle_int_t, i);
-
-	  /* These are widget relative coordinates,
-	   * so have them inverted to be window relative
-	   */
-          rect->x -= rel_x;
-          rect->y -= rel_y;
-
           cairo_region_union_rectangle (info->invalidation_region, rect);
         }
 
@@ -3208,6 +3199,7 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
 
 static void
 store_animation_region (GtkStyleContext *context,
+                        cairo_t         *cr,
                         gdouble          x,
                         gdouble          y,
                         gdouble          width,
@@ -3237,6 +3229,12 @@ store_animation_region (GtkStyleContext *context,
         {
           cairo_rectangle_int_t rect;
 
+          /* store device coordinates so the coordinates
+           * can be used right away in window invalidation
+           */
+          cairo_user_to_device (cr, &x, &y);
+          cairo_user_to_device_distance (cr, &width, &height);
+
           rect.x = (gint) x;
           rect.y = (gint) y;
           rect.width = (gint) width;
@@ -3703,7 +3701,7 @@ gtk_render_check (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_check (priv->theming_engine, cr,
@@ -3754,7 +3752,7 @@ gtk_render_option (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_option (priv->theming_engine, cr,
@@ -3803,7 +3801,7 @@ gtk_render_arrow (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, size, size);
+  store_animation_region (context, cr, x, y, size, size);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_arrow (priv->theming_engine, cr,
@@ -3855,7 +3853,7 @@ gtk_render_background (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_background (priv->theming_engine, cr, x, y, width, height);
@@ -3908,7 +3906,7 @@ gtk_render_frame (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_frame (priv->theming_engine, cr, x, y, width, height);
@@ -3958,7 +3956,7 @@ gtk_render_expander (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_expander (priv->theming_engine, cr, x, y, width, height);
@@ -4005,7 +4003,7 @@ gtk_render_focus (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_focus (priv->theming_engine, cr, x, y, width, height);
@@ -4047,7 +4045,7 @@ gtk_render_layout (GtkStyleContext *context,
 
   pango_layout_get_extents (layout, &extents, NULL);
 
-  store_animation_region (context,
+  store_animation_region (context, cr,
                           x + extents.x,
                           y + extents.y,
                           extents.width,
@@ -4141,7 +4139,7 @@ gtk_render_slider (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_slider (priv->theming_engine, cr, x, y, width, height, orientation);
@@ -4206,7 +4204,7 @@ gtk_render_frame_gap (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_frame_gap (priv->theming_engine, cr,
@@ -4260,7 +4258,7 @@ gtk_render_extension (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_extension (priv->theming_engine, cr, x, y, width, height, gap_side);
@@ -4310,7 +4308,7 @@ gtk_render_handle (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_handle (priv->theming_engine, cr, x, y, width, height);
@@ -4355,7 +4353,7 @@ gtk_render_activity (GtkStyleContext *context,
 
   cairo_save (cr);
 
-  store_animation_region (context, x, y, width, height);
+  store_animation_region (context, cr, x, y, width, height);
 
   _gtk_theming_engine_set_context (priv->theming_engine, context);
   engine_class->render_activity (priv->theming_engine, cr, x, y, width, height);



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