summaryrefslogtreecommitdiff
path: root/src/cairo.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-12-11 00:35:20 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-12-12 12:00:41 +0000
commitaf53297a97eec505ac2a90768badda72056c6e3b (patch)
tree9b451019a186157eeb65830b7900ec93afe177ff /src/cairo.c
parent09589e20e14476df609581027d14628f52091e71 (diff)
downloadcairo-af53297a97eec505ac2a90768badda72056c6e3b.tar.gz
[cairo] Use a stack buffer for text path.
First try to allocate glyphs from the stack, similar to cairo_show_text().
Diffstat (limited to 'src/cairo.c')
-rw-r--r--src/cairo.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cairo.c b/src/cairo.c
index 308459382..e1f7e9147 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -3325,7 +3325,8 @@ cairo_text_path (cairo_t *cr, const char *utf8)
{
cairo_status_t status;
cairo_text_extents_t extents;
- cairo_glyph_t *glyphs = NULL, *last_glyph;
+ cairo_glyph_t stack_glyphs[CAIRO_STACK_ARRAY_LENGTH (cairo_glyph_t)];
+ cairo_glyph_t *glyphs, *last_glyph;
int num_glyphs;
double x, y;
@@ -3337,6 +3338,9 @@ cairo_text_path (cairo_t *cr, const char *utf8)
cairo_get_current_point (cr, &x, &y);
+ glyphs = stack_glyphs;
+ num_glyphs = ARRAY_LENGTH (stack_glyphs);
+
status = _cairo_gstate_text_to_glyphs (cr->gstate,
x, y,
utf8, strlen (utf8),
@@ -3370,7 +3374,8 @@ cairo_text_path (cairo_t *cr, const char *utf8)
cairo_move_to (cr, x, y);
BAIL:
- cairo_glyph_free (glyphs);
+ if (glyphs != stack_glyphs)
+ cairo_glyph_free (glyphs);
if (unlikely (status))
_cairo_set_error (cr, status);