]> Pileus Git - ~andy/gtk/commitdiff
Add a gc_changed argument, and avoid setting the clip region if the gc has
authorMatthias Clasen <mclasen@redhat.com>
Mon, 20 Feb 2006 17:17:09 +0000 (17:17 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 20 Feb 2006 17:17:09 +0000 (17:17 +0000)
2006-02-19  Matthias Clasen  <mclasen@redhat.com>

* gdk/gdkgc.c (_gdk_gc_update_context): Add a gc_changed
argument, and avoid setting the clip region if the gc
has not changed.

* gdk/gdkgc.c: Update all callers.

* gdk/gdkpango.c (get_cairo_context): Avoid updating the
context if nothing changed.

ChangeLog
ChangeLog.pre-2-10
gdk/gdkdraw.c
gdk/gdkgc.c
gdk/gdkpango.c

index 3b9e5a48639fe6aada9a82cd791d8b0d07051dc4..04ec08cbadcef92de07d26fff8bc1ddc348be519 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-02-19  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdkgc.c (_gdk_gc_update_context): Add a gc_changed
+       argument, and avoid setting the clip region if the gc
+       has not changed. 
+
+       * gdk/gdkgc.c: Update all callers.
+
+       * gdk/gdkpango.c (get_cairo_context): Avoid updating the
+       context if nothing changed.
+
 2006-02-20  Anders Carlsson  <andersca@imendio.com>
 
         * gdk/quartz/gdkdisplay-quartz.c:
@@ -75,6 +86,7 @@
        * gtk/gtklinkbutton.c (gtk_link_button_class_init): Fix
        a cast.
 
+>>>>>>> 1.7541
 2006-02-17  Matthias Clasen  <mclasen@redhat.com>
 
        DND keynav support:
        * gtk/gtkcolorbutton.c (gtk_color_button_[un]realize):
        Remove unnecessary checks.  
 
+>>>>>>> 1.7533
 2006-02-12  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_list_icons): Give working
index 3b9e5a48639fe6aada9a82cd791d8b0d07051dc4..04ec08cbadcef92de07d26fff8bc1ddc348be519 100644 (file)
@@ -1,3 +1,14 @@
+2006-02-19  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/gdkgc.c (_gdk_gc_update_context): Add a gc_changed
+       argument, and avoid setting the clip region if the gc
+       has not changed. 
+
+       * gdk/gdkgc.c: Update all callers.
+
+       * gdk/gdkpango.c (get_cairo_context): Avoid updating the
+       context if nothing changed.
+
 2006-02-20  Anders Carlsson  <andersca@imendio.com>
 
         * gdk/quartz/gdkdisplay-quartz.c:
@@ -75,6 +86,7 @@
        * gtk/gtklinkbutton.c (gtk_link_button_class_init): Fix
        a cast.
 
+>>>>>>> 1.7541
 2006-02-17  Matthias Clasen  <mclasen@redhat.com>
 
        DND keynav support:
        * gtk/gtkcolorbutton.c (gtk_color_button_[un]realize):
        Remove unnecessary checks.  
 
+>>>>>>> 1.7533
 2006-02-12  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_list_icons): Give working
index 024215e57146f050a0f7f57c29e96fef6e50124d..cd05d2b59a062a81604da0aee44649c6575948f8 100644 (file)
@@ -881,7 +881,7 @@ real_draw_glyphs (GdkDrawable      *drawable,
   cairo_t *cr;
 
   cr = gdk_cairo_create (drawable);
-  _gdk_gc_update_context (gc, cr, NULL, NULL);
+  _gdk_gc_update_context (gc, cr, NULL, NULL, TRUE);
 
   if (matrix)
     {
@@ -1005,7 +1005,7 @@ gdk_draw_trapezoids (GdkDrawable    *drawable,
   g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
 
   cr = gdk_cairo_create (drawable);
-  _gdk_gc_update_context (gc, cr, NULL, NULL);
+  _gdk_gc_update_context (gc, cr, NULL, NULL, TRUE);
   
   for (i = 0; i < n_trapezoids; i++)
     {
index 79df5011a11058a11b4478af70f420cc153bcdb2..066f0c57d12d78f4d9d7a34be48c6a9c4c06ea2b 100644 (file)
@@ -1112,6 +1112,8 @@ gc_get_background (GdkGC    *gc,
  *   stipple from the GC. If this is present and the fill mode
  *   of the GC isn't %GDK_STIPPLED or %GDK_OPAQUE_STIPPLED
  *   the fill mode will be forced to %GDK_STIPPLED
+ * @gc_changed: pass %FALSE if the @gc has not changed since the
+ *     last call to this function
  * 
  * Set the attributes of a cairo context to match those of a #GdkGC
  * as far as possible. Some aspects of a #GdkGC, such as clip masks
@@ -1121,7 +1123,8 @@ void
 _gdk_gc_update_context (GdkGC     *gc,
                        cairo_t   *cr,
                        GdkColor  *override_foreground,
-                       GdkBitmap *override_stipple)
+                       GdkBitmap *override_stipple,
+                       gboolean   gc_changed)
 {
   GdkGCPrivate *priv;
   GdkFill fill;
@@ -1226,6 +1229,9 @@ _gdk_gc_update_context (GdkGC     *gc,
       cairo_pattern_destroy (pattern);
     }
 
+  if (!gc_changed)
+    return;
+
   cairo_reset_clip (cr);
   if (priv->clip_region)
     {
@@ -1243,5 +1249,6 @@ _gdk_gc_update_context (GdkGC     *gc,
     }
 }
 
+
 #define __GDK_GC_C__
 #include "gdkaliasdef.c"
index 9cea1cb32b6b48aabc74f197960086ed69b7f38e..22802535c51c206fe1c29079d36a6bb4af93da87 100644 (file)
@@ -57,6 +57,8 @@ struct _GdkPangoRendererPrivate
   /* Current target */
   GdkDrawable *drawable;
   GdkGC *base_gc;
+
+  gboolean gc_changed;
 };
 
 static PangoAttrType gdk_pango_attr_stipple_type;
@@ -130,6 +132,21 @@ emboss_context (cairo_t *cr)
   cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
 }
 
+static inline gboolean
+color_equal (PangoColor *c1, PangoColor *c2)
+{
+  if (!c1 && !c2)
+    return TRUE;
+
+  if (c1 && c2 &&
+      c1->red == c2->red &&
+      c1->green == c2->green &&
+      c1->blue == c2->blue)
+    return TRUE;
+
+  return FALSE;
+}
+
 static cairo_t *
 get_cairo_context (GdkPangoRenderer *gdk_renderer,
                   PangoRenderPart   part)
@@ -155,28 +172,46 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
          cairo_set_matrix (priv->cr, &cairo_matrix);
        }
     }
-  
-  priv->last_part = (PangoRenderPart)-1;
+
   if (part != priv->last_part)
     {
-      PangoColor *pango_color = pango_renderer_get_color (renderer,
-                                                         part);
-      GdkColor *color = NULL;
+      PangoColor *pango_color;
+      GdkColor *color;
       GdkColor tmp_color;
-      if (pango_color)
+      gboolean changed;
+
+      pango_color = pango_renderer_get_color (renderer, part);
+      
+      if (priv->last_part != -1)
+       changed = priv->gc_changed ||
+         priv->stipple[priv->last_part] != priv->stipple[part] ||
+         !color_equal (pango_color,
+                       pango_renderer_get_color (renderer, priv->last_part));
+      else
+       changed = TRUE;
+      
+      if (changed)
        {
-         tmp_color.red = pango_color->red;
-         tmp_color.green = pango_color->green;
-         tmp_color.blue = pango_color->blue;
-         
-         color = &tmp_color;
+         if (pango_color)
+           {
+             tmp_color.red = pango_color->red;
+             tmp_color.green = pango_color->green;
+             tmp_color.blue = pango_color->blue;
+             
+             color = &tmp_color;
+           }
+         else
+           color = NULL;
+
+         _gdk_gc_update_context (priv->base_gc,
+                                 priv->cr,
+                                 color,
+                                 priv->stipple[part],
+                                 priv->gc_changed);
        }
 
-      _gdk_gc_update_context (priv->base_gc,
-                             priv->cr,
-                             color,
-                             priv->stipple[part]);
       priv->last_part = part;
+      priv->gc_changed = FALSE;
     }
 
   return priv->cr;
@@ -482,6 +517,7 @@ gdk_pango_renderer_init (GdkPangoRenderer *renderer)
                                                GdkPangoRendererPrivate);
 
   renderer->priv->last_part = (PangoRenderPart)-1;
+  renderer->priv->gc_changed = TRUE;
 }
 
 static void
@@ -653,6 +689,8 @@ gdk_pango_renderer_set_gc (GdkPangoRenderer *gdk_renderer,
       priv->base_gc = gc;
       if (priv->base_gc)
        g_object_ref (priv->base_gc);
+
+      priv->gc_changed = TRUE;
     }
 }