]> granicus.if.org Git - libass/commitdiff
Use ass_drawing_add_chars for vector drawings
authorOleg Oshmyan <chortos@inbox.lv>
Thu, 29 May 2014 23:01:41 +0000 (00:01 +0100)
committerOleg Oshmyan <chortos@inbox.lv>
Fri, 6 Jun 2014 14:10:07 +0000 (15:10 +0100)
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

index 89c914cdedf11ff63abc94aad566143187534b5a..0544930e50b064721793141c87f658b0032d07b8 100644 (file)
@@ -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;