]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkgc.c
Add check for GNU extensions to ftw()/nftw().
[~andy/gtk] / gdk / gdkgc.c
index 72115eec27118f1c8c2cb88b1a4d7348bd667995..ec53dec702f340d3ad35aca1ccb358516006977f 100644 (file)
 #include <config.h>
 #include <string.h>
 
+#include "gdkcairo.h"
 #include "gdkgc.h"
 #include "gdkinternals.h"
 #include "gdkpixmap.h"
-#include "gdkregion-generic.h"
 #include "gdkrgb.h"
 #include "gdkprivate.h"
 #include "gdkalias.h"
@@ -53,7 +53,7 @@ struct _GdkGCPrivate
 
 #define GDK_GC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDK_TYPE_GC, GdkGCPrivate))
 
-G_DEFINE_TYPE (GdkGC, gdk_gc, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GdkGC, gdk_gc, G_TYPE_OBJECT)
 
 static void
 gdk_gc_class_init (GdkGCClass *class)
@@ -188,6 +188,10 @@ gdk_gc_finalize (GObject *object)
     gdk_region_destroy (priv->clip_region);
   if (gc->colormap)
     g_object_unref (gc->colormap);
+  if (priv->tile)
+    g_object_unref (priv->tile);
+  if (priv->stipple)
+    g_object_unref (priv->stipple);
 
   G_OBJECT_CLASS (gdk_gc_parent_class)->finalize (object);
 }
@@ -275,7 +279,6 @@ gdk_gc_set_values (GdkGC           *gc,
     gc->ts_y_origin = values->ts_y_origin;
   if (values_mask & GDK_GC_CLIP_MASK)
     {
-      GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
       if (priv->clip_region)
        {
          gdk_region_destroy (priv->clip_region);
@@ -1045,7 +1048,7 @@ make_stipple_tile_surface (cairo_t   *cr,
   alpha_surface = _gdk_drawable_ref_cairo_surface (stipple);
   
   surface = cairo_surface_create_similar (cairo_get_target (cr),
-                                         CAIRO_FORMAT_ARGB32,
+                                         CAIRO_CONTENT_COLOR_ALPHA,
                                          width, height);
 
   tmp_cr = cairo_create (surface);
@@ -1081,7 +1084,7 @@ gc_get_foreground (GdkGC    *gc,
   if (gc->colormap)
     gdk_colormap_query_color (gc->colormap, priv->fg_pixel, color);
   else
-    g_warning ("No colormap in gc_get_background");
+    g_warning ("No colormap in gc_get_foreground");
 }
 
 static void
@@ -1108,6 +1111,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
@@ -1117,7 +1122,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;
@@ -1145,12 +1151,8 @@ _gdk_gc_update_context (GdkGC     *gc,
     }
 
   if (fill == GDK_OPAQUE_STIPPLED)
-    {
-      if (override_foreground)
-       foreground = *override_foreground;
-      else
-       gc_get_background (gc, &background);
-    }
+    gc_get_background (gc, &background);
+
 
   switch (fill)
     {
@@ -1222,24 +1224,19 @@ _gdk_gc_update_context (GdkGC     *gc,
       cairo_pattern_destroy (pattern);
     }
 
+  if (!gc_changed)
+    return;
+
   cairo_reset_clip (cr);
   if (priv->clip_region)
     {
-      GdkRegionBox *boxes = priv->clip_region->rects;
-      gint n_boxes = priv->clip_region->numRects;
-      int i;
-
       cairo_save (cr);
 
       cairo_identity_matrix (cr);
-      
+      cairo_translate (cr, gc->clip_x_origin, gc->clip_y_origin);
+
       cairo_new_path (cr);
-      for (i=0; i < n_boxes; i++)
-       cairo_rectangle (cr,
-                        boxes[i].x1 + gc->clip_x_origin,
-                        boxes[i].y1 + gc->clip_y_origin,
-                        boxes[i].x2 - boxes[i].x1,
-                        boxes[i].y2 - boxes[i].y1);
+      gdk_cairo_region (cr, priv->clip_region);
 
       cairo_restore (cr);
 
@@ -1247,5 +1244,6 @@ _gdk_gc_update_context (GdkGC     *gc,
     }
 }
 
+
 #define __GDK_GC_C__
 #include "gdkaliasdef.c"