From 33c49228d078cc963ac5e59e526c97d2fd50a01f Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 13 Mar 2015 17:09:29 +0000 Subject: Path packing for memory efficiency. Introduce the concept of 'packed' paths. These reduce the header overhead for most common paths (ones with less than 256 commands and 256 coords) to a single 32bit int once stored in the display list. The previous commit reduces the torture-test.pdf from 95 to 87Meg. This commit futher reduces it to 70Meg. --- include/mupdf/fitz/context.h | 30 ++++++++++++++++++++++++++++++ include/mupdf/fitz/path.h | 2 ++ 2 files changed, 32 insertions(+) (limited to 'include') diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h index f694bc39..e58e5f61 100644 --- a/include/mupdf/fitz/context.h +++ b/include/mupdf/fitz/context.h @@ -470,6 +470,19 @@ fz_keep_imp(fz_context *ctx, void *p, int *refs) return p; } +static inline void * +fz_keep_imp8(fz_context *ctx, void *p, int8_t *refs) +{ + if (p) + { + fz_lock(ctx, FZ_LOCK_ALLOC); + if (*refs > 0) + ++*refs; + fz_unlock(ctx, FZ_LOCK_ALLOC); + } + return p; +} + static inline int fz_drop_imp(fz_context *ctx, void *p, int *refs) { @@ -487,4 +500,21 @@ fz_drop_imp(fz_context *ctx, void *p, int *refs) return 0; } +static inline int +fz_drop_imp8(fz_context *ctx, void *p, int8_t *refs) +{ + if (p) + { + int drop; + fz_lock(ctx, FZ_LOCK_ALLOC); + if (*refs > 0) + drop = --*refs == 0; + else + drop = 0; + fz_unlock(ctx, FZ_LOCK_ALLOC); + return drop; + } + return 0; +} + #endif diff --git a/include/mupdf/fitz/path.h b/include/mupdf/fitz/path.h index 1bca1858..81b6f7bb 100644 --- a/include/mupdf/fitz/path.h +++ b/include/mupdf/fitz/path.h @@ -64,6 +64,8 @@ fz_path *fz_new_path(fz_context *ctx); fz_path *fz_keep_path(fz_context *ctx, fz_path *path); void fz_drop_path(fz_context *ctx, fz_path *path); void fz_trim_path(fz_context *ctx, fz_path *path); +int fz_packed_path_size(const fz_path *path); +int fz_pack_path(fz_context *ctx, uint8_t *pack, int max, const fz_path *path); fz_point fz_currentpoint(fz_context *ctx, fz_path *path); void fz_moveto(fz_context*, fz_path*, float x, float y); -- cgit v1.2.3