diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-03-13 17:09:29 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-03-24 19:50:01 +0000 |
commit | 33c49228d078cc963ac5e59e526c97d2fd50a01f (patch) | |
tree | 233e29c78e497ca3b4d90bb3ea03ab846b61fbc6 /include | |
parent | 5f161e45d5daacb696d02b8fad23d0c23f5bc8bc (diff) | |
download | mupdf-33c49228d078cc963ac5e59e526c97d2fd50a01f.tar.xz |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/mupdf/fitz/context.h | 30 | ||||
-rw-r--r-- | include/mupdf/fitz/path.h | 2 |
2 files changed, 32 insertions, 0 deletions
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); |