mupdf
Loading...
Searching...
No Matches
store.h
Go to the documentation of this file.
1// Copyright (C) 2004-2021 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_FITZ_STORE_H
24#define MUPDF_FITZ_STORE_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/output.h"
29#include "mupdf/fitz/log.h"
30#include "mupdf/fitz/types.h"
31
53typedef struct fz_storable fz_storable;
54
62
70
81
92
96#define FZ_INIT_STORABLE(S_,RC,DROP) \
97 do { fz_storable *S = &(S_)->storable; S->refs = (RC); \
98 S->drop = (DROP); S->droppable = NULL; \
99 } while (0)
100
101#define FZ_INIT_AWKWARD_STORABLE(S_,RC,DROP,DROPPABLE) \
102 do { fz_storable *S = &(S_)->storable; S->refs = (RC); \
103 S->drop = (DROP); S->droppable = (DROPPABLE); \
104 } while (0)
105
109#define FZ_INIT_KEY_STORABLE(KS_,RC,DROP) \
110 do { fz_key_storable *KS = &(KS_)->key_storable; KS->store_key_refs = 0;\
111 FZ_INIT_STORABLE(KS,RC,DROP); \
112 } while (0)
113
121
130
138
147
155
164
218typedef struct
219{
221 union
222 {
223 struct
224 {
225 const void *ptr;
226 int i;
227 } pi; /* 8 or 12 bytes */
228 struct
229 {
230 const void *ptr;
231 int i;
233 } pir; /* 24 or 28 bytes */
234 struct
235 {
236 int id;
239 float m[4];
240 void *ptr;
242 } im; /* 32 or 36 bytes */
243 struct
244 {
245 unsigned char src_md5[16];
246 unsigned char dst_md5[16];
247 unsigned int ri:2;
248 unsigned int bp:1;
249 unsigned int format:1;
250 unsigned int proof:1;
251 unsigned int src_extras:5;
252 unsigned int dst_extras:5;
253 unsigned int copy_spots:1;
254 unsigned int bgr:1;
255 } link; /* 36 bytes */
256 } u;
257 /* 0 or 4 bytes padding */
258} fz_store_hash; /* 40 or 48 bytes */
259
265typedef struct
266{
267 const char *name;
268 int (*make_hash_key)(fz_context *ctx, fz_store_hash *hash, void *key);
269 void *(*keep_key)(fz_context *ctx, void *key);
270 void (*drop_key)(fz_context *ctx, void *key);
271 int (*cmp_key)(fz_context *ctx, void *a, void *b);
272 void (*format_key)(fz_context *ctx, char *buf, size_t size, void *key);
273 int (*needs_reap)(fz_context *ctx, void *key);
275
282void fz_new_store_context(fz_context *ctx, size_t max);
283
291
299
319void *fz_store_item(fz_context *ctx, void *key, void *val, size_t itemsize, const fz_store_type *type);
320
334void *fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type);
335
349void fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type);
350
355
368int fz_store_scavenge(fz_context *ctx, size_t size, int *phase);
369
380int fz_store_scavenge_external(fz_context *ctx, size_t size, int *phase);
381
392int fz_shrink_store(fz_context *ctx, unsigned int percent);
393
400typedef int (fz_store_filter_fn)(fz_context *ctx, void *arg, void *key);
401
408void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, const fz_store_type *type);
409
415
421
436
450
451#ifdef ENABLE_STORE_LOGGING
452
453void fz_log_dump_store(fz_context *ctx, const char *fmt, ...);
454
455#define FZ_LOG_STORE(CTX, ...) fz_log_module(CTX, "STORE", __VA_ARGS__)
456#define FZ_LOG_DUMP_STORE(...) fz_log_dump_store(__VA_ARGS__)
457
458#else
459
460#define FZ_LOG_STORE(...) do {} while (0)
461#define FZ_LOG_DUMP_STORE(...) do {} while (0)
462
463#endif
464
465#endif
struct fz_store fz_store
Definition context.h:40
void fz_defer_reap_end(fz_context *ctx)
void fz_drop_key_storable_key(fz_context *, const fz_key_storable *)
void fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type)
int fz_store_filter_fn(fz_context *ctx, void *arg, void *key)
Definition store.h:400
void fz_filter_store(fz_context *ctx, fz_store_filter_fn *fn, void *arg, const fz_store_type *type)
void fz_new_store_context(fz_context *ctx, size_t max)
void * fz_store_item(fz_context *ctx, void *key, void *val, size_t itemsize, const fz_store_type *type)
void * fz_keep_storable(fz_context *, const fz_storable *)
void fz_drop_storable(fz_context *, const fz_storable *)
fz_store * fz_keep_store_context(fz_context *ctx)
int fz_store_droppable_fn(fz_context *, fz_storable *)
Definition store.h:69
void * fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, const fz_store_type *type)
void * fz_keep_key_storable(fz_context *, const fz_key_storable *)
int fz_store_scavenge_external(fz_context *ctx, size_t size, int *phase)
void fz_debug_store(fz_context *ctx, fz_output *out)
void * fz_keep_key_storable_key(fz_context *, const fz_key_storable *)
int fz_store_scavenge(fz_context *ctx, size_t size, int *phase)
void fz_defer_reap_start(fz_context *ctx)
int fz_shrink_store(fz_context *ctx, unsigned int percent)
void fz_drop_drawn_tiles_for_document(fz_context *ctx, fz_document *doc)
void fz_drop_store_context(fz_context *ctx)
void fz_store_drop_fn(fz_context *, fz_storable *)
Definition store.h:61
void fz_drop_key_storable(fz_context *, const fz_key_storable *)
void fz_empty_store(fz_context *ctx)
Definition context.h:886
Definition document.h:1080
Definition geometry.h:248
Definition store.h:88
short store_key_refs
Definition store.h:90
fz_storable storable
Definition store.h:89
Definition output.h:111
Definition store.h:76
int refs
Definition store.h:77
fz_store_drop_fn * drop
Definition store.h:78
fz_store_droppable_fn * droppable
Definition store.h:79
Definition store.h:219
fz_irect r
Definition store.h:232
unsigned int bgr
Definition store.h:254
unsigned int ri
Definition store.h:247
fz_store_drop_fn * drop
Definition store.h:220
unsigned char dst_md5[16]
Definition store.h:246
const void * ptr
Definition store.h:225
char has_group_alpha
Definition store.h:238
unsigned int src_extras
Definition store.h:251
char has_shape
Definition store.h:237
int i
Definition store.h:226
int id
Definition store.h:236
unsigned char src_md5[16]
Definition store.h:245
unsigned int proof
Definition store.h:250
unsigned int format
Definition store.h:249
float m[4]
Definition store.h:239
unsigned int copy_spots
Definition store.h:253
int doc_id
Definition store.h:241
unsigned int dst_extras
Definition store.h:252
unsigned int bp
Definition store.h:248
Definition store.h:266
int(* make_hash_key)(fz_context *ctx, fz_store_hash *hash, void *key)
Definition store.h:268
int(* needs_reap)(fz_context *ctx, void *key)
Definition store.h:273
int(* cmp_key)(fz_context *ctx, void *a, void *b)
Definition store.h:271
void(* format_key)(fz_context *ctx, char *buf, size_t size, void *key)
Definition store.h:272
void(* drop_key)(fz_context *ctx, void *key)
Definition store.h:270
const char * name
Definition store.h:267