From f49dae8013cf089e18b333a686a7e30c212e4fae Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 20 Aug 2011 13:01:01 +0100 Subject: [PATCH] observer: copy glyphs around call into backend As the backend is allowed to modify the glyph array, we need to copy it for recoding. Signed-off-by: Chris Wilson --- src/cairo-surface-observer.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c index 370b05b9a..9cc597f99 100644 --- a/src/cairo-surface-observer.c +++ b/src/cairo-surface-observer.c @@ -1102,6 +1102,7 @@ _cairo_surface_observer_glyphs (void *abstract_surface, cairo_composite_rectangles_t composite; cairo_rectangle_int_t extents; cairo_int_status_t status; + cairo_glyph_t *dev_glyphs; struct timespec ts; double elapsed; int x, y; @@ -1136,14 +1137,22 @@ _cairo_surface_observer_glyphs (void *abstract_surface, add_extents (&device->log.glyphs.extents, &composite); _cairo_composite_rectangles_fini (&composite); + /* XXX We have to copy the glyphs, because the backend is allowed to + * modify! */ + dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t)); + if (unlikely (dev_glyphs == NULL)) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + memcpy (dev_glyphs, glyphs, num_glyphs * sizeof (cairo_glyph_t)); + *remaining_glyphs = 0; start_timer (&ts); status = _cairo_surface_show_text_glyphs (surface->target, op, source, - NULL, 0, - glyphs, num_glyphs, - NULL, 0, 0, - scaled_font, - clip); + NULL, 0, + dev_glyphs, num_glyphs, + NULL, 0, 0, + scaled_font, + clip); + free (dev_glyphs); if (unlikely (status)) return status;