summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-11-25 05:10:11 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-11-25 05:10:11 +0000
commit8e8179b0529ac2757d457a10bc8883d85482ff3a (patch)
tree5ebf045a687f5a8658658546cfe5ae203ce62571
parent131e662f658cce56d4dc21e4a16b0f9b3488b65c (diff)
downloadpango-8e8179b0529ac2757d457a10bc8883d85482ff3a.tar.gz
Make renderer-cache really thread-safe this time. Last try was not quite
2006-11-25 Behdad Esfahbod <behdad@gnome.org> * pango/pangocairo-render.c (acquire_renderer), (release_renderer), (_pango_cairo_do_glyph_string), (_pango_cairo_do_layout_line), (_pango_cairo_do_layout): Make renderer-cache really thread-safe this time. Last try was not quite thread-safe theoretically, because pointer assignments are not necessarily atomic on some archs. Anyway, this one should do it.
-rw-r--r--ChangeLog9
-rw-r--r--pango/pangocairo-render.c28
2 files changed, 27 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index cbce87eb..b0102131 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-25 Behdad Esfahbod <behdad@gnome.org>
+
+ * pango/pangocairo-render.c (acquire_renderer), (release_renderer),
+ (_pango_cairo_do_glyph_string), (_pango_cairo_do_layout_line),
+ (_pango_cairo_do_layout): Make renderer-cache really thread-safe this
+ time. Last try was not quite thread-safe theoretically, because
+ pointer assignments are not necessarily atomic on some archs. Anyway,
+ this one should do it.
+
2006-11-22 Behdad Esfahbod <behdad@gnome.org>
* examples/HELLO.utf8:
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index dd4d6cf3..f39df3f5 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -398,7 +398,7 @@ static PangoCairoRenderer *cached_renderer = NULL;
static GStaticMutex cached_renderer_mutex = G_STATIC_MUTEX_INIT;
static PangoCairoRenderer *
-acquire_renderer (void)
+acquire_renderer (gboolean *free_renderer)
{
PangoCairoRenderer *renderer;
@@ -410,16 +410,21 @@ acquire_renderer (void)
cached_renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);
renderer = cached_renderer;
+ *free_renderer = FALSE;
}
else
- renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);
+ {
+ renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL);
+ *free_renderer = TRUE;
+ }
return renderer;
}
-release_renderer (PangoCairoRenderer *renderer)
+static void
+release_renderer (PangoCairoRenderer *renderer, gboolean free_renderer)
{
- if (G_LIKELY (renderer == cached_renderer))
+ if (G_LIKELY (!free_renderer))
{
renderer->cr = NULL;
renderer->do_path = FALSE;
@@ -442,7 +447,8 @@ _pango_cairo_do_glyph_string (cairo_t *cr,
PangoGlyphString *glyphs,
gboolean do_path)
{
- PangoCairoRenderer *crenderer = acquire_renderer ();
+ gboolean free_renderer;
+ PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);
PangoRenderer *renderer = (PangoRenderer *) crenderer;
crenderer->cr = cr;
@@ -470,7 +476,7 @@ _pango_cairo_do_glyph_string (cairo_t *cr,
pango_renderer_deactivate (renderer);
}
- release_renderer (crenderer);
+ release_renderer (crenderer, free_renderer);
}
static void
@@ -478,7 +484,8 @@ _pango_cairo_do_layout_line (cairo_t *cr,
PangoLayoutLine *line,
gboolean do_path)
{
- PangoCairoRenderer *crenderer = acquire_renderer ();
+ gboolean free_renderer;
+ PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);
PangoRenderer *renderer = (PangoRenderer *) crenderer;
crenderer->cr = cr;
@@ -487,7 +494,7 @@ _pango_cairo_do_layout_line (cairo_t *cr,
pango_renderer_draw_layout_line (renderer, line, 0, 0);
- release_renderer (crenderer);
+ release_renderer (crenderer, free_renderer);
}
static void
@@ -495,7 +502,8 @@ _pango_cairo_do_layout (cairo_t *cr,
PangoLayout *layout,
gboolean do_path)
{
- PangoCairoRenderer *crenderer = acquire_renderer ();
+ gboolean free_renderer;
+ PangoCairoRenderer *crenderer = acquire_renderer (&free_renderer);
PangoRenderer *renderer = (PangoRenderer *) crenderer;
crenderer->cr = cr;
@@ -504,7 +512,7 @@ _pango_cairo_do_layout (cairo_t *cr,
pango_renderer_draw_layout (renderer, layout, 0, 0);
- release_renderer (crenderer);
+ release_renderer (crenderer, free_renderer);
}
static void