Add a gc_changed argument, and avoid setting the clip region if the gc has

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.
This commit is contained in:
Matthias Clasen 2006-02-20 17:17:09 +00:00 committed by Matthias Clasen
parent ba8e91b9fc
commit 3c9432eeb6
5 changed files with 89 additions and 18 deletions

View 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:
@ -113,6 +125,7 @@
* 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

View 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:
@ -113,6 +125,7 @@
* 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

View 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++)
{

View 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"

View 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)
@ -156,13 +173,25 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
}
}
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;
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)
{
if (pango_color)
{
tmp_color.red = pango_color->red;
@ -171,12 +200,18 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
color = &tmp_color;
}
else
color = NULL;
_gdk_gc_update_context (priv->base_gc,
priv->cr,
color,
priv->stipple[part]);
priv->stipple[part],
priv->gc_changed);
}
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;
}
}