Bug 6955: Fix by adding freeze/thaw around scaled_font glyph cache in _cairo_xlib_surface_show_glyphs

This commit is contained in:
Carl Worth 2006-06-22 22:32:57 -07:00
parent 6a58658b73
commit 7e457cb4c1
4 changed files with 39 additions and 1 deletions

View file

@ -363,6 +363,18 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
return CAIRO_STATUS_SUCCESS;
}
void
_cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font)
{
_cairo_cache_freeze (scaled_font->glyphs);
}
void
_cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font)
{
_cairo_cache_thaw (scaled_font->glyphs);
}
void
_cairo_scaled_font_set_metrics (cairo_scaled_font_t *scaled_font,
cairo_font_extents_t *fs_metrics)

View file

@ -2579,7 +2579,7 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst,
int num_glyphs,
cairo_scaled_font_t *scaled_font)
{
cairo_int_status_t status;
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
cairo_xlib_surface_t *dst = (cairo_xlib_surface_t*) abstract_dst;
composite_operation_t operation;
@ -2635,6 +2635,17 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst,
(font_private != NULL && font_private->dpy != dst->dpy))
return CAIRO_INT_STATUS_UNSUPPORTED;
/* After passing all those tests, we're now committed to rendering
* these glyphs or to fail trying. We first upload any glyphs to
* the X server that it doesn't have already, then we draw
* them. We tie into the scaled_font's glyph cache and remove
* glyphs from the X server when they are ejected from the
* scaled_font cache. Because of this we first freeze the
* scaled_font's cache so that we don't cause any of our glyphs to
* be ejected and removed from the X server before we have a
* chance to render them. */
_cairo_scaled_font_freeze_cache (scaled_font);
/* PictOpClear doesn't seem to work with CompositeText; it seems to ignore
* the mask (the glyphs). This code below was executed as a side effect
* of going through the _clip_and_composite fallback code for old_show_glyphs,
@ -2726,6 +2737,8 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst,
}
FAIL:
_cairo_scaled_font_thaw_cache (scaled_font);
if (src)
_cairo_pattern_release_surface (src_pattern, &src->base, &attributes);
if (src_pattern == &solid_pattern.base)

View file

@ -1378,6 +1378,12 @@ _cairo_color_get_rgba_premultiplied (cairo_color_t *color,
/* cairo-font.c */
cairo_private void
_cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font);
cairo_private void
_cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
cairo_status_t status);

View file

@ -40,6 +40,13 @@
* We replicate this bug by using the cairo_scaled_font_set_max_glyphs_per_font
* function to artifically induce cache pressure. (This function was added
* for this very purpose.)
*
* 2006-06-22 Carl Worth <cworth@cworth.org>
*
* Bug was simple enough to solve by just adding a freeze/thaw pair
* around the scaled_font's glyph cache in
* _cairo_xlib_surface_show_glyphs, (I went ahead and added
* _cairo_sacled_font_freeze/thaw_cache functions for this).
*/
cairo_test_t test = {