diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-14 19:08:56 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-15 00:43:24 +0000 |
commit | 313e8f82816c839b3de47e1137a91414bb95a327 (patch) | |
tree | f680cd6ebc26e51dab5cd0b9a5337ce49197f6ac /pdf/mupdf.h | |
parent | 09c8ebeea83f11ccac07bad76e516460e2c8e0f7 (diff) | |
download | mupdf-313e8f82816c839b3de47e1137a91414bb95a327.tar.xz |
Rework pdf_store to fz_store, a part of fz_context.
Firstly, we rename pdf_store to fz_store, reflecting the fact that
there are no pdf specific dependencies on it.
Next, we rework it so that all the objects that can be stored in
the store start with an fz_storable structure. This consists of
a reference count, and a function used to free the object when
the reference count reaches zero.
All the keep/drop functions are then reimplemented by calling
fz_keep_sharable/fz_drop_sharable. The 'drop' functions as supplied
by the callers are thus now 'free' functions, only called if
the reference count drops to 0.
The store changes to keep all the items in the store in the linked
list (which becomes a doubly linked one). We still make use of
the hashtable to index into this list quickly, but we now have
the objects in an LRU ordering within the list.
Every object is put into the store, with a size record; this is
an estimate of how much memory would be freed by freeing that
object.
The store is moved into the context and given a maximum size;
when new things are inserted into the store, care is taken to
ensure that we do not expand beyond this size. We evict any
stored items (that are not in use) starting from the least
recently used.
Finding an object in the store now takes a reference to it already.
LOCK and UNLOCK comments are used to indicate where locks need to
be taken and released to ensure thread safety.
Diffstat (limited to 'pdf/mupdf.h')
-rw-r--r-- | pdf/mupdf.h | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/pdf/mupdf.h b/pdf/mupdf.h index 79560dab..890e9f8b 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -90,8 +90,6 @@ struct pdf_xref_s fz_obj **page_objs; fz_obj **page_refs; - struct pdf_store_s *store; - char scratch[65536]; }; @@ -154,24 +152,6 @@ unsigned char *pdf_get_crypt_key(pdf_xref *xref); void pdf_debug_crypt(pdf_crypt *crypt); /* - * Resource store - */ - -typedef struct pdf_store_s pdf_store; - -pdf_store *pdf_new_store(fz_context *ctx); -void pdf_free_store(fz_context *ctx, pdf_store *store); -void pdf_debug_store(fz_context *ctx, pdf_store *store); - -typedef void *(pdf_store_keep_fn)(void *); -typedef void (pdf_store_drop_fn)(fz_context *, void *); - -void pdf_store_item(fz_context *ctx, pdf_store *store, pdf_store_keep_fn *keepfn, pdf_store_drop_fn *dropfn, fz_obj *key, void *val); -void *pdf_find_item(fz_context *ctx, pdf_store *store, pdf_store_drop_fn *dropfn, fz_obj *key); -void pdf_remove_item(fz_context *ctx, pdf_store *store, pdf_store_drop_fn *dropfn, fz_obj *key); -void pdf_age_store(fz_context *ctx, pdf_store *store, int maxage); - -/* * Functions, Colorspaces, Shadings and Images */ @@ -181,6 +161,7 @@ pdf_function *pdf_load_function(pdf_xref *xref, fz_obj *ref); void pdf_eval_function(fz_context *ctx, pdf_function *func, float *in, int inlen, float *out, int outlen); pdf_function *pdf_keep_function(pdf_function *func); void pdf_drop_function(fz_context *ctx, pdf_function *func); +unsigned int pdf_function_size(pdf_function *func); fz_colorspace *pdf_load_colorspace(pdf_xref *xref, fz_obj *obj); fz_pixmap *pdf_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src); @@ -199,7 +180,7 @@ typedef struct pdf_pattern_s pdf_pattern; struct pdf_pattern_s { - int refs; + fz_storable storable; int ismask; float xstep; float ystep; @@ -221,7 +202,7 @@ typedef struct pdf_xobject_s pdf_xobject; struct pdf_xobject_s { - int refs; + fz_storable storable; fz_matrix matrix; fz_rect bbox; int isolated; @@ -257,7 +238,7 @@ struct pdf_range_s struct pdf_cmap_s { - int refs; + fz_storable storable; char cmap_name[32]; char usecmap_name[32]; @@ -283,6 +264,8 @@ struct pdf_cmap_s pdf_cmap *pdf_new_cmap(fz_context *ctx); pdf_cmap *pdf_keep_cmap(pdf_cmap *cmap); void pdf_drop_cmap(fz_context *ctx, pdf_cmap *cmap); +void pdf_free_cmap_imp(fz_context *ctx, void *cmap); +unsigned int pdf_cmap_size(pdf_cmap *cmap); void pdf_debug_cmap(pdf_cmap *cmap); int pdf_get_wmode(pdf_cmap *cmap); @@ -356,7 +339,8 @@ struct pdf_vmtx_s struct pdf_font_desc_s { - int refs; + fz_storable storable; + unsigned int size; fz_font *font; |