From 40f4ed22806b88ba0e26c458915d4695f1f7c201 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 18 Jan 2012 15:49:09 +0000 Subject: Multi-threading support for MuPDF When we moved over to a context based system, we laid the foundation for a thread-safe mupdf. This commit should complete that process. Firstly, fz_clone_context is properly implemented so that it makes a new context, but shares certain sections (currently just the allocator, and the store). Secondly, we add locking (to parts of the code that have previously just had placeholder LOCK/UNLOCK comments). Functions to lock and unlock a mutex are added to the allocator structure; omit these (as is the case today) and no multithreading is (safely) possible. The context will refuse to clone if these are not provided. Finally we flesh out the LOCK/UNLOCK comments to be real calls of the functions - unfortunately this requires us to plumb fz_context into the fz_keep_storable function (and all the fz_keep_xxx functions that call it). This is the largest section of the patch. No changes expected to any test files. --- draw/draw_glyph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'draw') diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c index ebda003e..1edcef4a 100644 --- a/draw/draw_glyph.c +++ b/draw/draw_glyph.c @@ -115,7 +115,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_color val = fz_hash_find(cache->hash, &key); if (val) - return fz_keep_pixmap(val); + return fz_keep_pixmap(ctx, val); ctm.e = floorf(ctm.e) + key.e / 256.0f; ctm.f = floorf(ctm.f) + key.f / 256.0f; @@ -144,7 +144,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_color { fz_hash_insert(cache->hash, &key, val); fz_keep_font(key.font); - val = fz_keep_pixmap(val); + val = fz_keep_pixmap(ctx, val); } fz_catch(ctx) { -- cgit v1.2.3