#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"
#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)
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);
}
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);
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);
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
* 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
_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;
}
if (fill == GDK_OPAQUE_STIPPLED)
- {
- if (override_foreground)
- foreground = *override_foreground;
- else
- gc_get_background (gc, &background);
- }
+ gc_get_background (gc, &background);
+
switch (fill)
{
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);
}
}
+
#define __GDK_GC_C__
#include "gdkaliasdef.c"