From 3ba18f666e87321c28d4a7281f808947c0712465 Mon Sep 17 00:00:00 2001 From: "Dr.Smile" Date: Thu, 29 Dec 2016 01:42:38 +0300 Subject: api: make ass_set_cache_limits() work on total bitmap cache sizes Previously was possible to set only bitmap_max_size, now requested memory amount is divided between bitmap_max_size and composite_max_size. --- libass/ass_render_api.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libass/ass_render_api.c') diff --git a/libass/ass_render_api.c b/libass/ass_render_api.c index c59c204d..d4b55de2 100644 --- a/libass/ass_render_api.c +++ b/libass/ass_render_api.c @@ -180,8 +180,18 @@ void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max, int bitmap_max) { render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX; - render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max : - BITMAP_CACHE_MAX_SIZE; + + size_t bitmap_cache, composite_cache; + if (bitmap_max) { + bitmap_cache = MEGABYTE * (size_t) bitmap_max; + composite_cache = bitmap_cache / (COMPOSITE_CACHE_RATIO + 1); + bitmap_cache -= composite_cache; + } else { + bitmap_cache = BITMAP_CACHE_MAX_SIZE; + composite_cache = COMPOSITE_CACHE_MAX_SIZE; + } + render_priv->cache.bitmap_max_size = bitmap_cache; + render_priv->cache.composite_max_size = composite_cache; } ASS_FontProvider * -- cgit v1.2.3