diff options
author | Dr.Smile <vabnick@gmail.com> | 2016-12-29 01:42:38 +0300 |
---|---|---|
committer | Dr.Smile <vabnick@gmail.com> | 2016-12-29 02:07:34 +0300 |
commit | 3ba18f666e87321c28d4a7281f808947c0712465 (patch) | |
tree | 69246f105f2ac9424738debac311f4f7a773c85a /libass/ass_render_api.c | |
parent | 53fee0874ab43ec53c62b3d5455a812b6d346506 (diff) | |
download | libass-3ba18f666e87321c28d4a7281f808947c0712465.tar.bz2 libass-3ba18f666e87321c28d4a7281f808947c0712465.tar.xz |
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.
Diffstat (limited to 'libass/ass_render_api.c')
-rw-r--r-- | libass/ass_render_api.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libass/ass_render_api.c b/libass/ass_render_api.c index c59c204..d4b55de 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 * |