summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2022-07-26 18:04:06 -0500
committerrcombs <rcombs@rcombs.me>2023-02-18 20:36:59 -0600
commit04a208d5d200360d2ac75f8f6cfc43dd58dd9225 (patch)
treed1f30dfb2e52b66b6173cffb59025ee009678185
parent6e436e48b7672d0dcdfc73884c493d4c49bd0479 (diff)
downloadlibass-04a208d5d200360d2ac75f8f6cfc43dd58dd9225.tar.bz2
libass-04a208d5d200360d2ac75f8f6cfc43dd58dd9225.tar.xz
ass_render: charge the bitmap cache for its OutlineHashValue
This is also stored in the outline cache, but a reference from the bitmap cache can keep an entry alive long after it would otherwise have been dropped. This can lead to much higher-than-expected memory usage when rendering fonts with very complex glyphs.
-rw-r--r--libass/ass_render.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index aea484c..f95479c 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -1544,6 +1544,11 @@ get_bitmap_glyph(RenderContext *state, GlyphInfo *info,
*pos = *pos_o;
}
+static inline size_t outline_size(const ASS_Outline* outline)
+{
+ return sizeof(ASS_Vector) * outline->n_points + outline->n_segments;
+}
+
size_t ass_bitmap_construct(void *key, void *value, void *priv)
{
RenderContext *state = priv;
@@ -1567,7 +1572,8 @@ size_t ass_bitmap_construct(void *key, void *value, void *priv)
ass_outline_free(&outline[0]);
ass_outline_free(&outline[1]);
- return sizeof(BitmapHashKey) + sizeof(Bitmap) + bitmap_size(bm);
+ return sizeof(BitmapHashKey) + sizeof(Bitmap) + bitmap_size(bm) +
+ sizeof(OutlineHashValue) + outline_size(&k->outline->outline[0]) + outline_size(&k->outline->outline[1]);
}
static void measure_text_on_eol(RenderContext *state, double scale, int cur_line,