From d698daa0be6c510917f9f852fd1a00465ecb2847 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 29 Jul 2010 03:05:19 +0200 Subject: [PATCH] Parse vector clip mask only after cache miss --- libass/ass_parse.c | 14 -------------- libass/ass_render.c | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/libass/ass_parse.c b/libass/ass_parse.c index dc872b9..2fb33da 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -233,20 +233,6 @@ static char *parse_vector_clip(ASS_Renderer *render_priv, char *p) while (*p != ')' && *p != '}' && p != 0) ass_drawing_add_char(drawing, *p++); skipopt(')'); - if (ass_drawing_parse(drawing, 1)) { - // We need to translate the clip according to screen borders - if (render_priv->settings.left_margin != 0 || - render_priv->settings.top_margin != 0) { - FT_Vector trans = { - .x = int_to_d6(render_priv->settings.left_margin), - .y = -int_to_d6(render_priv->settings.top_margin), - }; - FT_Outline_Translate(&drawing->glyph->outline, trans.x, trans.y); - } - ass_msg(render_priv->library, MSGL_DBG2, - "Parsed vector clip: scale %d, scales (%f, %f) string [%s]\n", - scale, drawing->scale_x, drawing->scale_y, drawing->text); - } return p; } diff --git a/libass/ass_render.c b/libass/ass_render.c index 59d13ed..cf11f92 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -598,8 +598,29 @@ static void blend_vector_clip(ASS_Renderer *render_priv, } else { GlyphHashValue v; - // Not found in cache, rasterize it - glyph = (FT_Glyph) drawing->glyph; + // Not found in cache, parse and rasterize it + glyph = (FT_Glyph) *ass_drawing_parse(drawing, 1); + if (!glyph) { + ass_msg(render_priv->library, MSGL_WARN, + "Clip vector parsing failed. Skipping."); + goto blend_vector_exit; + } + + // We need to translate the clip according to screen borders + if (render_priv->settings.left_margin != 0 || + render_priv->settings.top_margin != 0) { + FT_Vector trans = { + .x = int_to_d6(render_priv->settings.left_margin), + .y = -int_to_d6(render_priv->settings.top_margin), + }; + FT_Outline_Translate(&drawing->glyph->outline, + trans.x, trans.y); + } + + ass_msg(render_priv->library, MSGL_DBG2, + "Parsed vector clip: scales (%f, %f) string [%s]\n", + drawing->scale_x, drawing->scale_y, drawing->text); + error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1); if (error) { ass_msg(render_priv->library, MSGL_WARN, -- 2.40.0