mupdf
Loading...
Searching...
No Matches
fz_store_hash Struct Reference

#include <store.h>

Collaboration diagram for fz_store_hash:

Public Attributes

fz_store_drop_fndrop
union { 
   struct { 
      const void *   ptr 
      int   i 
   }   pi
   struct { 
      const void *   ptr 
      int   i 
      fz_irect   r 
   }   pir
   struct { 
      int   id 
      char   has_shape 
      char   has_group_alpha 
      float   m [4] 
      void *   ptr 
      int   doc_id 
   }   im
   struct { 
      unsigned char   src_md5 [16] 
      unsigned char   dst_md5 [16] 
      unsigned int   ri:2 
      unsigned int   bp:1 
      unsigned int   format:1 
      unsigned int   proof:1 
      unsigned int   src_extras:5 
      unsigned int   dst_extras:5 
      unsigned int   copy_spots:1 
      unsigned int   bgr:1 
   }   link
u

Detailed Description

The store can be seen as a dictionary that maps keys to fz_storable values. In order to allow keys of different types to be stored, we have a structure full of functions for each key 'type'; this fz_store_type pointer is stored with each key, and tells the store how to perform certain operations (like taking/ dropping a reference, comparing two keys, outputting details for debugging etc).

The store uses a hash table internally for speed where possible. In order for this to work, we need a mechanism for turning a generic 'key' into 'a hashable string'. For this purpose the type structure contains a make_hash_key function pointer that maps from a void * to a fz_store_hash structure. If make_hash_key function returns 0, then the key is determined not to be hashable, and the value is not stored in the hash table.

Some objects can be used both as values within the store, and as a component of keys within the store. We refer to these objects as "key storable" objects. In this case, we need to take additional care to ensure that we do not end up keeping an item within the store, purely because its value is referred to by another key in the store.

An example of this are fz_images in PDF files. Each fz_image is placed into the store to enable it to be easily reused. When the image is rendered, a pixmap is generated from the image, and the pixmap is placed into the store so it can be reused on subsequent renders. The image forms part of the key for the pixmap.

When we close the pdf document (and any associated pages/display lists etc), we drop the images from the store. This may leave us in the position of the images having non-zero reference counts purely because they are used as part of the keys for the pixmaps.

We therefore use special reference counting functions to keep track of these "key storable" items, and hence store the number of references to these items that are used in keys.

When the number of references to an object == the number of references to an object from keys in the store, we know that we can remove all the items which have that object as part of the key. This is done by running a pass over the store, 'reaping' those items.

Reap passes are slower than we would like as they touch every item in the store. We therefore provide a way to 'batch' such reap passes together, using fz_defer_reap_start/ fz_defer_reap_end to bracket a region in which many may be triggered.

Member Data Documentation

◆ bgr

unsigned int fz_store_hash::bgr

◆ bp

unsigned int fz_store_hash::bp

◆ copy_spots

unsigned int fz_store_hash::copy_spots

◆ doc_id

int fz_store_hash::doc_id

◆ drop

fz_store_drop_fn* fz_store_hash::drop

◆ dst_extras

unsigned int fz_store_hash::dst_extras

◆ dst_md5

unsigned char fz_store_hash::dst_md5[16]

◆ format

unsigned int fz_store_hash::format

◆ has_group_alpha

char fz_store_hash::has_group_alpha

◆ has_shape

char fz_store_hash::has_shape

◆ i

int fz_store_hash::i

◆ id

int fz_store_hash::id

◆ [struct]

struct { ... } fz_store_hash::im

◆ [struct]

struct { ... } fz_store_hash::link

◆ m

float fz_store_hash::m[4]

◆ [struct]

struct { ... } fz_store_hash::pi

◆ [struct]

struct { ... } fz_store_hash::pir

◆ proof

unsigned int fz_store_hash::proof

◆ ptr [1/2]

void* fz_store_hash::ptr

◆ ptr [2/2]

const void* fz_store_hash::ptr

◆ r

fz_irect fz_store_hash::r

◆ ri

unsigned int fz_store_hash::ri

◆ src_extras

unsigned int fz_store_hash::src_extras

◆ src_md5

unsigned char fz_store_hash::src_md5[16]

◆ [union]

union { ... } fz_store_hash::u

The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/mupdf/checkouts/1.28.0/include/mupdf/fitz/store.h