diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-11-11 07:15:07 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-11-11 07:15:07 +0100 |
commit | 58de1fff510078e3d2d8cfce033c87299adf78f0 (patch) | |
tree | 80635049b0d1ccc8840717982afe983ea18c0b37 | |
parent | 2ec725624d637789845478a90f799e9eeb54f9ee (diff) | |
download | mupdf-58de1fff510078e3d2d8cfce033c87299adf78f0.tar.xz |
filter reference counting
-rw-r--r-- | TODO | 43 | ||||
-rw-r--r-- | base/error.c | 8 | ||||
-rw-r--r-- | base/memory.c | 4 | ||||
-rw-r--r-- | filter/buffer.c | 18 | ||||
-rw-r--r-- | filter/filec.c | 26 | ||||
-rw-r--r-- | filter/filer.c | 1 | ||||
-rw-r--r-- | filter/filter.c | 22 | ||||
-rw-r--r-- | filter/pipeline.c | 25 | ||||
-rw-r--r-- | include/fitz/base.h | 2 | ||||
-rw-r--r-- | include/fitz/filter.h | 5 | ||||
-rw-r--r-- | include/fitz/font.h | 1 | ||||
-rw-r--r-- | include/fitz/math.h | 14 | ||||
-rw-r--r-- | include/fitz/object.h | 2 | ||||
-rw-r--r-- | include/mupdf/syntax.h | 2 | ||||
-rw-r--r-- | mupdf/crypt.c | 2 | ||||
-rw-r--r-- | mupdf/fontfile.c | 11 | ||||
-rw-r--r-- | mupdf/repair.c | 3 | ||||
-rw-r--r-- | mupdf/save.c | 20 | ||||
-rw-r--r-- | mupdf/stream.c | 2 | ||||
-rw-r--r-- | mupdf/xref.c | 4 | ||||
-rw-r--r-- | object/array.c | 2 | ||||
-rw-r--r-- | object/dict.c | 2 | ||||
-rw-r--r-- | object/simple.c | 22 | ||||
-rw-r--r-- | render/glyphcache.c | 2 | ||||
-rw-r--r-- | test/pdfclean.c | 3 | ||||
-rw-r--r-- | test/x11pdf.c | 18 |
26 files changed, 172 insertions, 92 deletions
@@ -0,0 +1,43 @@ +colorspace conversions + - cal* + - iccbased + - how to normalize Lab components to 0..1 + - fast color cubes + - how to cache colorspace cubes (what key?) + +image rendering + - tiles + - dct case + - better filter than box + +shadings + - ... jeong ... + +rendering + - aabb-bounded temp buffers + - save non-transformed bbox in nodes + - explicit mask field in fz_renderer .. general cleanup + - merge gka optims + - optimize! optimize! optimize! (special case 1 and 4 channel cases) + +parser + - text clip mode + - split content streams (TJ objects) + - resource dict generate fake ids + - try to clean up colorspace/material handling in interpreter + - tounicode + +clean up + - reference count everything + - standard cleanup mechanism + - naming conventions (fz_new/renew) + + - design by contract + - split into private and public + - comments and documentation + +cache + global cache for cmaps and fontfiles (emb+sys) + render cache (link-nodes and scaled images) + profile font cache (esp with t3 fonts) + diff --git a/base/error.c b/base/error.c index df795192..489dcc40 100644 --- a/base/error.c +++ b/base/error.c @@ -20,9 +20,10 @@ fz_throwMS(char *fmt, ...) eo = fz_malloc(sizeof(fz_error)); if (!eo) return fz_outofmem; + eo->nrefs = 1; strlcpy(eo->func, "unknown", sizeof eo->func); strlcpy(eo->file, "unknown", sizeof eo->file); - eo->line = -1; + eo->line = 0; va_start(ap, fmt); vsnprintf(eo->msg, sizeof eo->msg, fmt, ap); @@ -41,6 +42,7 @@ fz_throw0(const char *func, const char *file, int line, char *fmt, ...) eo = fz_malloc(sizeof(fz_error)); if (!eo) return fz_outofmem; + eo->nrefs = 1; strlcpy(eo->func, func, sizeof eo->func); strlcpy(eo->file, file, sizeof eo->file); eo->line = line; @@ -59,7 +61,9 @@ fz_throw0(const char *func, const char *file, int line, char *fmt, ...) void fz_droperror(fz_error *eo) { - if (!eo->frozen) + if (eo->nrefs > 0) + eo->nrefs--; + if (eo->nrefs == 0) fz_free(eo); } diff --git a/base/memory.c b/base/memory.c index b0858383..2c2f8e0d 100644 --- a/base/memory.c +++ b/base/memory.c @@ -39,11 +39,11 @@ static fz_memorycontext defmem = { stdmalloc, stdrealloc, stdfree }; static fz_memorycontext *curmem = &defmem; fz_error fz_koutofmem = { + -1, {"out of memory"}, {"<malloc>"}, {"memory.c"}, - 0, - 1 + 0 }; fz_memorycontext * diff --git a/filter/buffer.c b/filter/buffer.c index 1b7a0793..79339456 100644 --- a/filter/buffer.c +++ b/filter/buffer.c @@ -8,6 +8,7 @@ fz_newbuffer(fz_buffer **bp, int size) b = *bp = fz_malloc(sizeof(fz_buffer)); if (!b) return fz_outofmem; + b->nrefs = 1; b->ownsdata = 1; b->bp = fz_malloc(size); if (!b->bp) { fz_free(b); return fz_outofmem; } @@ -28,6 +29,7 @@ fz_newbufferwithdata(fz_buffer **bp, unsigned char *data, int size) b = *bp = fz_malloc(sizeof(fz_buffer)); if (!b) return fz_outofmem; + b->nrefs = 1; b->ownsdata = 0; b->bp = data; @@ -39,12 +41,22 @@ fz_newbufferwithdata(fz_buffer **bp, unsigned char *data, int size) return nil; } +fz_buffer * +fz_keepbuffer(fz_buffer *buf) +{ + buf->nrefs ++; + return buf; +} + void fz_dropbuffer(fz_buffer *buf) { - if (buf->ownsdata) - fz_free(buf->bp); - fz_free(buf); + if (--buf->nrefs == 0) + { + if (buf->ownsdata) + fz_free(buf->bp); + fz_free(buf); + } } fz_error * diff --git a/filter/filec.c b/filter/filec.c index 4c132b33..5ea3c75a 100644 --- a/filter/filec.c +++ b/filter/filec.c @@ -67,8 +67,8 @@ fz_openfile(fz_file **filep, char *path, int mode) cleanup: *filep = nil; close(fd); - fz_free(file->out); - fz_free(file->in); + fz_dropbuffer(file->out); + fz_dropbuffer(file->in); fz_free(file); return error; } @@ -93,7 +93,7 @@ fz_openbuffer(fz_file **filep, fz_buffer *buf, int mode) if (mode == FZ_READ) { - file->out = buf; + file->out = fz_keepbuffer(buf); error = fz_newbuffer(&file->in, FZ_BUFSIZE); if (error) goto cleanup; @@ -104,7 +104,7 @@ fz_openbuffer(fz_file **filep, fz_buffer *buf, int mode) error = fz_newbuffer(&file->out, FZ_BUFSIZE); if (error) goto cleanup; - file->in = buf; + file->in = fz_keepbuffer(buf); } return nil; @@ -130,19 +130,11 @@ fz_closefile(fz_file *file) file->error = nil; } - if (file->fd == -1) /* open to buffer not file */ - { - if (file->mode == FZ_READ) - fz_dropbuffer(file->in); - else - fz_dropbuffer(file->out); - } - else - { - fz_dropbuffer(file->in); - fz_dropbuffer(file->out); + if (file->fd != -1) /* open to real file */ close(file->fd); - } + + fz_dropbuffer(file->in); + fz_dropbuffer(file->out); if (file->filter) fz_dropfilter(file->filter); @@ -178,7 +170,7 @@ fz_pushfilter(fz_file *file, fz_filter *filter) file->in->eof = 0; } - file->filter = filter; + file->filter = fz_keepfilter(filter); } else diff --git a/filter/filer.c b/filter/filer.c index 29e04558..24f9a214 100644 --- a/filter/filer.c +++ b/filter/filer.c @@ -233,6 +233,7 @@ fz_readfile(fz_buffer **bufp, fz_file *file) return fz_outofmem; } + real->nrefs = 1; real->ownsdata = 1; real->bp = buf; real->rp = buf; diff --git a/filter/filter.c b/filter/filter.c index 25bbd441..4bd8c4ff 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -1,8 +1,8 @@ #include <fitz.h> -fz_error fz_kioneedin = { "<ioneedin>", "<process>", "filter.c", 0, 1 }; -fz_error fz_kioneedout = { "<ioneedout>", "<process>", "filter.c", 0, 1 }; -fz_error fz_kiodone = { "<iodone>", "<process>", "filter.c", 0, 1 }; +fz_error fz_kioneedin = { -1, "<ioneedin>", "<process>", "filter.c", 0 }; +fz_error fz_kioneedout = { -1, "<ioneedout>", "<process>", "filter.c", 0 }; +fz_error fz_kiodone = { -1, "<iodone>", "<process>", "filter.c", 0 }; fz_error * fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) @@ -31,11 +31,21 @@ fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) return reason; } +fz_filter * +fz_keepfilter(fz_filter *f) +{ + f->nrefs ++; + return f; +} + void fz_dropfilter(fz_filter *f) { - if (f->drop) - f->drop(f); - fz_free(f); + if (--f->nrefs == 0) + { + if (f->drop) + f->drop(f); + fz_free(f); + } } diff --git a/filter/pipeline.c b/filter/pipeline.c index 4ac0da58..7b7f4252 100644 --- a/filter/pipeline.c +++ b/filter/pipeline.c @@ -19,10 +19,10 @@ fz_error * fz_chainpipeline(fz_filter **fp, fz_filter *head, fz_filter *tail, fz_buffer *buf) { FZ_NEWFILTER(fz_pipeline, p, pipeline); - p->head = head; - p->tail = tail; + p->head = fz_keepfilter(head); + p->tail = fz_keepfilter(tail); p->tailneedsin = 1; - p->buffer = buf; + p->buffer = fz_keepbuffer(buf); return nil; } @@ -30,24 +30,25 @@ void fz_unchainpipeline(fz_filter *filter, fz_filter **oldfp, fz_buffer **oldbp) { fz_pipeline *p = (fz_pipeline*)filter; - *oldfp = p->head; - *oldbp = p->buffer; - fz_dropfilter(p->tail); - fz_free(p); + + *oldfp = fz_keepfilter(p->head); + *oldbp = fz_keepbuffer(p->buffer); + + fz_dropfilter(filter); } fz_error * fz_newpipeline(fz_filter **fp, fz_filter *head, fz_filter *tail) { - fz_error *err; + fz_error *error; FZ_NEWFILTER(fz_pipeline, p, pipeline); - p->head = head; - p->tail = tail; + p->head = fz_keepfilter(head); + p->tail = fz_keepfilter(tail); p->tailneedsin = 1; - err = fz_newbuffer(&p->buffer, FZ_BUFSIZE); - if (err) { fz_free(p); return err; } + error = fz_newbuffer(&p->buffer, FZ_BUFSIZE); + if (error) { fz_free(p); return error; } return nil; } diff --git a/include/fitz/base.h b/include/fitz/base.h index 9ead6c88..e08b2f09 100644 --- a/include/fitz/base.h +++ b/include/fitz/base.h @@ -25,11 +25,11 @@ typedef struct fz_error_s fz_error; struct fz_error_s { + int nrefs; char msg[184]; char file[32]; char func[32]; int line; - int frozen; }; #define fz_outofmem (&fz_koutofmem) diff --git a/include/fitz/filter.h b/include/fitz/filter.h index 225cb172..7f45bd34 100644 --- a/include/fitz/filter.h +++ b/include/fitz/filter.h @@ -17,6 +17,7 @@ extern fz_error fz_kiodone; TYPE *VAR; \ *fp = fz_malloc(sizeof(TYPE)); \ if (!*fp) return fz_outofmem; \ + (*fp)->nrefs = 1; \ (*fp)->process = fz_process ## NAME ; \ (*fp)->drop = fz_drop ## NAME ; \ (*fp)->consumed = 0; \ @@ -26,6 +27,7 @@ extern fz_error fz_kiodone; struct fz_filter_s { + int nrefs; fz_error* (*process)(fz_filter *filter, fz_buffer *in, fz_buffer *out); void (*drop)(fz_filter *filter); int consumed; @@ -35,6 +37,7 @@ struct fz_filter_s struct fz_buffer_s { + int nrefs; int ownsdata; unsigned char *bp; unsigned char *rp; @@ -44,6 +47,7 @@ struct fz_buffer_s }; fz_error *fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out); +fz_filter *fz_keepfilter(fz_filter *f); void fz_dropfilter(fz_filter *f); fz_error *fz_newnullfilter(fz_filter **fp, int len); @@ -57,6 +61,7 @@ fz_error *fz_newbuffer(fz_buffer **bufp, int size); fz_error *fz_newbufferwithdata(fz_buffer **bufp, unsigned char *data, int size); fz_error *fz_rewindbuffer(fz_buffer *buf); fz_error *fz_growbuffer(fz_buffer *buf); +fz_buffer *fz_keepbuffer(fz_buffer *buf); void fz_dropbuffer(fz_buffer *buf); fz_error *fz_newa85d(fz_filter **filterp, fz_obj *param); diff --git a/include/fitz/font.h b/include/fitz/font.h index 9fd9218b..a3caec7f 100644 --- a/include/fitz/font.h +++ b/include/fitz/font.h @@ -61,5 +61,6 @@ fz_vmtx fz_getvmtx(fz_font *font, int cid); fz_error *fz_newglyphcache(fz_glyphcache **arenap, int slots, int size); fz_error *fz_renderglyph(fz_glyphcache*, fz_glyph*, fz_font*, int, fz_matrix); +void fz_debugglyphcache(fz_glyphcache *); void fz_dropglyphcache(fz_glyphcache *); diff --git a/include/fitz/math.h b/include/fitz/math.h index bfc1f8e6..30577691 100644 --- a/include/fitz/math.h +++ b/include/fitz/math.h @@ -7,16 +7,18 @@ static inline unsigned char fz_mul255(unsigned char a, unsigned char b) /* floor / ceil towards/from +/- inf */ static inline float fz_floor(float x) { - if (x > 0) - return floor(x); - return ceil(x); + return floor(x); +// if (x > 0) +// return floor(x); +// return ceil(x); } static inline float fz_ceil(float x) { - if (x > 0) - return ceil(x); - return floor(x); + return ceil(x); +// if (x > 0) +// return ceil(x); +// return floor(x); } /* divide and floor towards -inf */ diff --git a/include/fitz/object.h b/include/fitz/object.h index e275074b..d24b8a7a 100644 --- a/include/fitz/object.h +++ b/include/fitz/object.h @@ -24,8 +24,8 @@ struct fz_keyval_s struct fz_obj_s { + unsigned short nrefs; unsigned short kind; /* fz_objkind takes 4 bytes :( */ - unsigned short refcount; union { int b; diff --git a/include/mupdf/syntax.h b/include/mupdf/syntax.h index 0df89d65..ce9d9c80 100644 --- a/include/mupdf/syntax.h +++ b/include/mupdf/syntax.h @@ -50,7 +50,7 @@ struct pdf_crypt_s fz_error *pdf_newdecrypt(pdf_crypt **cp, fz_obj *enc, fz_obj *id); fz_error *pdf_newencrypt(pdf_crypt **cp, char *userpw, char *ownerpw, int p, int n, fz_obj *id); fz_error *pdf_setpassword(pdf_crypt *crypt, char *pw); -fz_error *pdf_cryptstm(fz_filter **fp, pdf_crypt *crypt, int oid, int gid); +fz_error *pdf_cryptstream(fz_filter **fp, pdf_crypt *crypt, int oid, int gid); void pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int oid, int gid); void pdf_dropcrypt(pdf_crypt *crypt); diff --git a/mupdf/crypt.c b/mupdf/crypt.c index b6b79261..302f4588 100644 --- a/mupdf/crypt.c +++ b/mupdf/crypt.c @@ -360,7 +360,7 @@ pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int oid, int gid) } fz_error * -pdf_cryptstm(fz_filter **fp, pdf_crypt *crypt, int oid, int gid) +pdf_cryptstream(fz_filter **fp, pdf_crypt *crypt, int oid, int gid) { unsigned char key[16]; createobjkey(crypt, oid, gid, key); diff --git a/mupdf/fontfile.c b/mupdf/fontfile.c index e5e154da..a17bbfdf 100644 --- a/mupdf/fontfile.c +++ b/mupdf/fontfile.c @@ -44,7 +44,7 @@ static char *basenames[15] = static struct { char *collection; char *serif; char *gothic; } cidfonts[5] = { { "Adobe-CNS1", "MOESung-Regular", "MOEKai-Regular" }, - { "Adobe-GB1", "GB1-Serif", "GB1-Gothic" }, + { "Adobe-GB1", "gkai00mp", "gbsn00lp" }, { "Adobe-Japan1", "WadaMin-Regular", "WadaMaruGo-Regular" }, { "Adobe-Japan2", "WadaMin-RegularH", "WadaMaruGo-RegularH" }, { "Adobe-Korea1", "Munhwa-Regular", "MunhwaGothic-Regular" }, @@ -187,7 +187,15 @@ pdf_loadsystemfont(pdf_font *font, char *fontname, char *collection) if (collection) { + char buf[256]; + char *env; printf(" find cid font %s (%d)\n", collection, isserif); + + snprintf(buf, sizeof buf, "%s_%s", strstr(collection, "-") + 1, isserif ? "S" : "G"); + env = getenv(buf); + if (env) + return loadcidfont(font, env); + for (i = 0; i < 5; i++) { if (!strcmp(collection, cidfonts[i].collection)) @@ -198,6 +206,7 @@ printf(" find cid font %s (%d)\n", collection, isserif); return loadcidfont(font, cidfonts[i].gothic); } } + fz_warn("unknown cid collection: %s", collection); } diff --git a/mupdf/repair.c b/mupdf/repair.c index 91d46a39..b50e08f2 100644 --- a/mupdf/repair.c +++ b/mupdf/repair.c @@ -225,6 +225,9 @@ pdf_repairpdf(pdf_xref **xrefp, char *filename) xref->table[0].mark = 0; xref->table[0].ofs = 0; xref->table[0].gen = 65535; + xref->table[0].stmbuf = nil; + xref->table[0].stmofs = 0; + xref->table[0].obj = nil; for (i = 1; i < xref->len; i++) { diff --git a/mupdf/save.c b/mupdf/save.c index 8238dc8f..1fcc31da 100644 --- a/mupdf/save.c +++ b/mupdf/save.c @@ -4,7 +4,7 @@ #define TIGHT 0 static fz_error * -writestm(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) +writestream(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) { fz_error *error; unsigned char buf[4096]; @@ -15,7 +15,7 @@ writestm(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) if (encrypt) { - error = pdf_cryptstm(&ef, encrypt, oid, gen); + error = pdf_cryptstream(&ef, encrypt, oid, gen); if (error) return error; @@ -60,7 +60,7 @@ cleanup: } static fz_error * -writeobj(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) +writeobject(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) { pdf_xrefentry *x = xref->table + oid; fz_error *error; @@ -81,7 +81,7 @@ writeobj(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) if (x->stmbuf || x->stmofs) { - error = writestm(out, xref, encrypt, oid, gen); + error = writestream(out, xref, encrypt, oid, gen); if (error) return error; } @@ -95,8 +95,6 @@ writeobj(fz_file *out, pdf_xref *xref, pdf_crypt *encrypt, int oid, int gen) return nil; } -#if 0 - static int countmodified(pdf_xref *xref, int oid) { int i; @@ -127,7 +125,7 @@ pdf_updatepdf(pdf_xref *xref, char *path) if (xref->table[oid].type == 'a') { xref->table[oid].ofs = fz_tell(out); - error = writestoredobj(out, xref, xref->crypt, oid, xref->table[oid].gen); + error = writeobject(out, xref, xref->crypt, oid, xref->table[oid].gen); if (error) goto cleanup; } @@ -171,11 +169,11 @@ pdf_updatepdf(pdf_xref *xref, char *path) fz_print(out, "trailer\n<<\n /Size %d\n /Prev %d", xref->len, xref->startxref); obj = fz_dictgets(xref->trailer, "Root"); - fz_print(out,"\n /Root %d %d R", fz_toobjid(obj), fz_togenid(obj)); + fz_print(out,"\n /Root %d %d R", fz_tonum(obj), fz_togen(obj)); obj = fz_dictgets(xref->trailer, "Info"); if (obj) - fz_print(out,"\n /Info %d %d R", fz_toobjid(obj), fz_togenid(obj)); + fz_print(out,"\n /Info %d %d R", fz_tonum(obj), fz_togen(obj)); obj = fz_dictgets(xref->trailer, "Encrypt"); if (obj) { @@ -205,8 +203,6 @@ cleanup: return error; } -#endif - fz_error * pdf_savepdf(pdf_xref *xref, char *path, pdf_crypt *encrypt) { @@ -252,7 +248,7 @@ pdf_savepdf(pdf_xref *xref, char *path, pdf_crypt *encrypt) if (x->type == 'n' || x->type == 'o' || x->type == 'a') { ofsbuf[oid] = fz_tell(out); - error = writeobj(out, xref, encrypt, oid, x->type == 'o' ? 0 : x->gen); + error = writeobject(out, xref, encrypt, oid, x->type == 'o' ? 0 : x->gen); if (error) goto cleanup; } diff --git a/mupdf/stream.c b/mupdf/stream.c index 9b108a2b..13b79642 100644 --- a/mupdf/stream.c +++ b/mupdf/stream.c @@ -111,7 +111,7 @@ makerawfilter(fz_filter **filterp, pdf_xref *xref, fz_obj *stmobj, int oid, int if (xref->crypt) { - error = pdf_cryptstm(&cf, xref->crypt, oid, gen); + error = pdf_cryptstream(&cf, xref->crypt, oid, gen); error = fz_newpipeline(&pipe, pipe, cf); } diff --git a/mupdf/xref.c b/mupdf/xref.c index 98885f05..40f1f65a 100644 --- a/mupdf/xref.c +++ b/mupdf/xref.c @@ -114,7 +114,7 @@ pdf_debugpdf(pdf_xref *xref) xref->table[i].ofs, xref->table[i].gen, xref->table[i].type, - xref->table[i].obj ? xref->table[i].obj->refcount : 0, + xref->table[i].obj ? xref->table[i].obj->nrefs : 0, xref->table[i].stmofs); } } @@ -281,7 +281,7 @@ pdf_updatestream(pdf_xref *xref, int oid, int gen, fz_buffer *stm) if (x->stmbuf) fz_dropbuffer(x->stmbuf); - x->stmbuf = stm; + x->stmbuf = fz_keepbuffer(stm); return nil; } diff --git a/object/array.c b/object/array.c index c57f3952..78e50963 100644 --- a/object/array.c +++ b/object/array.c @@ -11,8 +11,8 @@ fz_newarray(fz_obj **op, int initialcap) obj = *op = fz_malloc(sizeof (fz_obj)); if (!obj) return fz_outofmem; + obj->nrefs = 1; obj->kind = FZ_ARRAY; - obj->refcount = 1; obj->u.a.len = 0; obj->u.a.cap = initialcap > 0 ? initialcap : 6; diff --git a/object/dict.c b/object/dict.c index fda48dc3..70e5005b 100644 --- a/object/dict.c +++ b/object/dict.c @@ -11,8 +11,8 @@ fz_newdict(fz_obj **op, int initialcap) obj = *op = fz_malloc(sizeof (fz_obj)); if (!obj) return fz_outofmem; + obj->nrefs = 1; obj->kind = FZ_DICT; - obj->refcount = 1; obj->u.d.len = 0; obj->u.d.cap = initialcap > 0 ? initialcap : 10; diff --git a/object/simple.c b/object/simple.c index 9f645c89..b06c77d7 100644 --- a/object/simple.c +++ b/object/simple.c @@ -3,12 +3,12 @@ extern void fz_droparray(fz_obj *array); extern void fz_dropdict(fz_obj *dict); -#define NEWOBJ(KIND,SIZE) \ - fz_obj *o; \ - o = *op = fz_malloc(SIZE); \ - if (!o) return fz_outofmem; \ - o->kind = KIND; \ - o->refcount = 1 +#define NEWOBJ(KIND,SIZE) \ + fz_obj *o; \ + o = *op = fz_malloc(SIZE); \ + if (!o) return fz_outofmem; \ + o->nrefs = 1; \ + o->kind = KIND; \ fz_error * fz_newnull(fz_obj **op) @@ -71,22 +71,22 @@ fz_error * fz_newpointer(fz_obj **op, void *p) { NEWOBJ(FZ_POINTER, sizeof (fz_obj)); - o->u.p = p; - return nil; + o->u.p = p; + return nil; } fz_obj * fz_keepobj(fz_obj *o) { - o->refcount ++; + o->nrefs ++; return o; } fz_obj * fz_dropobj(fz_obj *o) { - o->refcount --; - if (o->refcount == 0) { + if (--o->nrefs == 0) + { if (o->kind == FZ_ARRAY) fz_droparray(o); else if (o->kind == FZ_DICT) diff --git a/render/glyphcache.c b/render/glyphcache.c index ec77e857..41ef0f08 100644 --- a/render/glyphcache.c +++ b/render/glyphcache.c @@ -329,7 +329,7 @@ fz_renderglyph(fz_glyphcache *arena, fz_glyph *glyph, fz_font *font, int cid, fz } ctm.e = fz_floor(ctm.e) + key.e / HSUBPIX; - ctm.f = fz_floor(ctm.f) + key.f / HSUBPIX; + ctm.f = fz_floor(ctm.f) + key.f / VSUBPIX; error = font->render(glyph, font, cid, ctm); if (error) diff --git a/test/pdfclean.c b/test/pdfclean.c index 7dd15427..b8102d2c 100644 --- a/test/pdfclean.c +++ b/test/pdfclean.c @@ -162,6 +162,9 @@ int main(int argc, char **argv) if (error) fz_abort(error); + if (encrypt) + pdf_dropcrypt(encrypt); + pdf_closepdf(xref); return 0; diff --git a/test/x11pdf.c b/test/x11pdf.c index 0d52ff41..d6cbb28a 100644 --- a/test/x11pdf.c +++ b/test/x11pdf.c @@ -157,14 +157,12 @@ static void showpage(void) XDrawString(xdpy, xwin, xgc, 10, 30, s, strlen(s)); XFlush(xdpy); - ctm = fz_concat(fz_translate(0, -page->mediabox.max.y), - fz_scale(zoom, -zoom)); + ctm = fz_identity(); + ctm = fz_concat(ctm, fz_translate(0, -page->mediabox.max.y)); + ctm = fz_concat(ctm, fz_scale(zoom, -zoom)); + ctm = fz_concat(ctm, fz_rotate(rotate)); - bbox = page->mediabox; - bbox.min.x = bbox.min.x * zoom; - bbox.min.y = bbox.min.y * zoom; - bbox.max.x = bbox.max.x * zoom; - bbox.max.y = bbox.max.y * zoom; + bbox = fz_transformaabb(ctm, page->mediabox); error = fz_rendertree(&image, rast, page->tree, ctm, bbox); if (error) @@ -222,9 +220,9 @@ static void handlekey(int c) switch (c) { - case '8': - fz_debugglyphcache(rast->cache); - break; + case 'd': fz_debugglyphcache(rast->cache); break; + case 'a': rotate -= 5; break; + case 's': rotate += 5; break; case 'b': pageno--; |