diff options
Diffstat (limited to 'source/fitz/font.c')
-rw-r--r-- | source/fitz/font.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/source/fitz/font.c b/source/fitz/font.c index 598931e8..5f2f85e1 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -74,12 +74,7 @@ fz_new_font(fz_context *ctx, const char *name, int use_glyph_bbox, int glyph_cou fz_font * fz_keep_font(fz_context *ctx, fz_font *font) { - if (!font) - return NULL; - fz_lock(ctx, FZ_LOCK_ALLOC); - font->refs ++; - fz_unlock(ctx, FZ_LOCK_ALLOC); - return font; + return fz_keep_imp(ctx, font, &font->refs); } static void @@ -89,7 +84,7 @@ free_resources(fz_context *ctx, fz_font *font) if (font->t3resources) { - font->t3freeres(font->t3doc, font->t3resources); + font->t3freeres(ctx, font->t3doc, font->t3resources); font->t3resources = NULL; } @@ -119,12 +114,9 @@ void fz_drop_font(fz_context *ctx, fz_font *font) { int fterr; - int i, drop; + int i; - fz_lock(ctx, FZ_LOCK_ALLOC); - drop = (font && --font->refs == 0); - fz_unlock(ctx, FZ_LOCK_ALLOC); - if (!drop) + if (!fz_drop_imp(ctx, font, &font->refs)) return; free_resources(ctx, font); @@ -214,23 +206,16 @@ void fz_new_font_context(fz_context *ctx) fz_font_context * fz_keep_font_context(fz_context *ctx) { - if (!ctx || !ctx->font) + if (!ctx) return NULL; - fz_lock(ctx, FZ_LOCK_ALLOC); - ctx->font->ctx_refs++; - fz_unlock(ctx, FZ_LOCK_ALLOC); - return ctx->font; + return fz_keep_imp(ctx, ctx->font, &ctx->font->ctx_refs); } void fz_drop_font_context(fz_context *ctx) { - int drop; - if (!ctx || !ctx->font) + if (!ctx) return; - fz_lock(ctx, FZ_LOCK_ALLOC); - drop = --ctx->font->ctx_refs; - fz_unlock(ctx, FZ_LOCK_ALLOC); - if (drop == 0) + if (fz_drop_imp(ctx, ctx->font, &ctx->font->ctx_refs)) fz_free(ctx, ctx->font); } @@ -1063,9 +1048,9 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth) FZ_DEVFLAG_LINEJOIN_UNDEFINED | FZ_DEVFLAG_MITERLIMIT_UNDEFINED | FZ_DEVFLAG_LINEWIDTH_UNDEFINED; - font->t3run(font->t3doc, font->t3resources, contents, dev, &fz_identity, NULL, 0); + font->t3run(ctx, font->t3doc, font->t3resources, contents, dev, &fz_identity, NULL, 0); font->t3flags[gid] = dev->flags; - fz_free_device(dev); + fz_drop_device(ctx, dev); } static fz_rect * @@ -1087,11 +1072,11 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, dev = fz_new_bbox_device(ctx, bounds); fz_try(ctx) { - fz_run_display_list(list, dev, &ctm, &fz_infinite_rect, NULL); + fz_run_display_list(ctx, list, dev, &ctm, &fz_infinite_rect, NULL); } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(ctx, dev); } fz_catch(ctx) { @@ -1117,7 +1102,7 @@ fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, f return; fz_concat(&ctm, &font->t3matrix, trm); - fz_run_display_list(list, dev, &ctm, &fz_infinite_rect, NULL); + fz_run_display_list(ctx, list, dev, &ctm, &fz_infinite_rect, NULL); } fz_pixmap * @@ -1168,7 +1153,7 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr } fz_always(ctx) { - fz_free_device(dev); + fz_drop_device(ctx, dev); } fz_catch(ctx) { @@ -1230,7 +1215,7 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi } fz_concat(&ctm, &font->t3matrix, trm); - font->t3run(font->t3doc, font->t3resources, contents, dev, &ctm, gstate, nested_depth); + font->t3run(ctx, font->t3doc, font->t3resources, contents, dev, &ctm, gstate, nested_depth); } #ifndef NDEBUG |