From 76404b71acce6f1b5087eaffc59de4011799453b Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Fri, 30 May 2014 00:01:41 +0100 Subject: [PATCH] Use ass_drawing_add_chars for vector drawings This not only provides a performance improvement but also conveniently fixes the following issue: we used to interpret backslash-escapes in vector drawings, but we shouldn't. --- libass/ass_render.c | 48 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/libass/ass_render.c b/libass/ass_render.c index 89c914c..0544930 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1888,7 +1888,7 @@ static int ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, EventImages *event_images) { - char *p, *tag_end; + char *p, *q; FT_Vector pen; unsigned code; DBBox bbox; @@ -1916,40 +1916,36 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, drawing = render_priv->state.drawing; text_info->length = 0; p = event->Text; - tag_end = NULL; // Event parsing. while (1) { // get next char, executing style override // this affects render_context - do { - code = 0; - if (!tag_end && *p == '{') { - tag_end = strchr(p, '}'); - if (drawing->i) { - // A drawing definition has just ended. - // Exit and create the drawing now lest we - // accidentally let it consume later text - // or be affected by later override tags. - // See Google Code issues #47 and #101. - break; - } - } - if (tag_end) { - while (p < tag_end) - p = parse_tag(render_priv, p, tag_end, 1.); + code = 0; + while (*p) { + if ((*p == '{') && (q = strchr(p, '}'))) { + while (p < q) + p = parse_tag(render_priv, p, q, 1.); assert(*p == '}'); p++; - tag_end = NULL; + } else if (render_priv->state.drawing_scale) { + q = p; + if (*p == '{') + q++; + while ((*q != '{') && (*q != 0)) + q++; + ass_drawing_add_chars(drawing, p, q - p); + code = 0xfffc; // object replacement character + p = q; + break; } else { code = get_next_char(render_priv, &p); - if (code && render_priv->state.drawing_scale) { - ass_drawing_add_char(drawing, (char) code); - continue; // skip everything in drawing mode - } break; } - } while (*p); + } + + if (code == 0) + break; if (text_info->length >= text_info->max_glyphs) { // Raise maximum number of glyphs @@ -1972,7 +1968,6 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, render_priv->font_scale; drawing->scale = render_priv->state.drawing_scale; drawing->pbo = render_priv->state.pbo; - code = 0xfffc; // object replacement character info->drawing = drawing; } @@ -1982,9 +1977,6 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event, return 1; } - if (code == 0) - break; - // Fill glyph information info->symbol = code; info->font = render_priv->state.font; -- 2.40.0