summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/rsrc.h5
-rw-r--r--mupdf/build.c7
-rw-r--r--mupdf/font.c22
-rw-r--r--mupdf/interpret.c5
-rw-r--r--mupdf/pattern.c3
-rw-r--r--mupdf/resources.c85
-rw-r--r--mupdf/type3.c8
-rw-r--r--render/glyphcache.c6
8 files changed, 43 insertions, 98 deletions
diff --git a/include/mupdf/rsrc.h b/include/mupdf/rsrc.h
index 371661a0..39222351 100644
--- a/include/mupdf/rsrc.h
+++ b/include/mupdf/rsrc.h
@@ -4,14 +4,13 @@
struct pdf_rsrc_s
{
- int oid;
- int gen;
+ fz_obj *key;
void *val;
pdf_rsrc *next;
};
fz_error *pdf_loadresources(fz_obj **rdb, pdf_xref *xref, fz_obj *orig);
-void *pdf_findresource(pdf_rsrc *list, fz_obj *ref);
+void *pdf_findresource(pdf_rsrc *list, fz_obj *key);
/*
* Functions
diff --git a/mupdf/build.c b/mupdf/build.c
index 06c09f84..72c1cfda 100644
--- a/mupdf/build.c
+++ b/mupdf/build.c
@@ -293,18 +293,11 @@ addpatternshape(pdf_gstate *gs, fz_node *shape,
bbox.max.x += pat->bbox.max.x;
bbox.max.y += pat->bbox.max.y;
-printf("stamping pattern [%g %g] over [%g %g %g %g]\n",
- pat->xstep, pat->ystep,
- bbox.min.x, bbox.min.y,
- bbox.max.x, bbox.max.y);
-
x0 = fz_floor(bbox.min.x / pat->xstep);
y0 = fz_floor(bbox.min.y / pat->ystep);
x1 = fz_ceil(bbox.max.x / pat->xstep);
y1 = fz_ceil(bbox.max.y / pat->ystep);
-printf(" %d,%d to %d,%d\n", x0, y0, x1, y1);
-
for (y = y0; y <= y1; y++)
{
for (x = x0; x <= x1; x++)
diff --git a/mupdf/font.c b/mupdf/font.c
index b27403d6..11218cfd 100644
--- a/mupdf/font.c
+++ b/mupdf/font.c
@@ -46,7 +46,6 @@ enum { UNKNOWN, TYPE1, CFF, TRUETYPE, CID };
static int ftkind(FT_Face face)
{
const char *kind = face->driver->clazz->root.module_name;
-printf(" type %s\n", kind);
if (!strcmp(kind, "type1"))
return TYPE1;
if (!strcmp(kind, "cff"))
@@ -294,8 +293,6 @@ loadsimplefont(pdf_font **fontp, pdf_xref *xref, fz_obj *dict)
* Load font file
*/
-printf("loading simple font %s -> %s\n", basefont, fontname);
-
font = *fontp = pdf_newfont(fontname);
if (!font)
return fz_outofmem;
@@ -420,7 +417,6 @@ printf("loading simple font %s -> %s\n", basefont, fontname);
/* Unicode cmap */
if (face->charmap->platform_id == 3)
{
-printf(" winansi cmap\n");
for (i = 0; i < 256; i++)
if (estrings[i])
{
@@ -437,7 +433,6 @@ printf(" winansi cmap\n");
/* MacRoman cmap */
else if (face->charmap->platform_id == 1)
{
-printf(" macroman cmap\n");
for (i = 0; i < 256; i++)
if (estrings[i])
{
@@ -454,7 +449,6 @@ printf(" macroman cmap\n");
/* Symbolic cmap */
else
{
-printf(" symbolic cmap\n");
for (i = 0; i < 256; i++)
etable[i] = FT_Get_Char_Index(face, i);
}
@@ -465,7 +459,6 @@ printf(" symbolic cmap\n");
else
{
-printf(" builtin encoding\n");
for (i = 0; i < 256; i++)
etable[i] = FT_Get_Char_Index(face, i);
}
@@ -500,8 +493,6 @@ printf(" builtin encoding\n");
first = fz_toint(fz_dictgets(dict, "FirstChar"));
last = fz_toint(fz_dictgets(dict, "LastChar"));
-printf(" widths vector %d to %d\n", first, last);
-
if (first < 0 || last > 255 || first > last)
first = last = 0;
@@ -517,7 +508,6 @@ printf(" widths vector %d to %d\n", first, last);
}
else
{
-printf(" builtin widths\n");
FT_Set_Char_Size(face, 1000, 1000, 72, 72);
for (i = 0; i < 256; i++)
{
@@ -531,8 +521,6 @@ printf(" builtin widths\n");
if (error)
goto cleanup;
-printf("\n");
-
return nil;
cleanup:
@@ -567,8 +555,6 @@ loadcidfont(pdf_font **fontp, pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz
basefont = fz_toname(fz_dictgets(dict, "BaseFont"));
-printf("loading cid font %s\n", basefont);
-
{
fz_obj *cidinfo;
fz_obj *obj;
@@ -598,8 +584,6 @@ printf("loading cid font %s\n", basefont);
fz_dropobj(cidinfo);
}
-printf(" collection %s\n", collection);
-
/*
* Load font file
*/
@@ -632,7 +616,6 @@ printf(" collection %s\n", collection);
if (fz_isname(encoding))
{
-printf(" external CMap %s\n", fz_toname(encoding));
if (!strcmp(fz_toname(encoding), "Identity-H"))
error = pdf_makeidentitycmap(&font->encoding, 0, 2);
else if (!strcmp(fz_toname(encoding), "Identity-V"))
@@ -642,7 +625,6 @@ printf(" external CMap %s\n", fz_toname(encoding));
}
else if (fz_isindirect(encoding))
{
-printf(" embedded CMap\n");
error = pdf_loadembeddedcmap(&font->encoding, xref, encoding);
}
else
@@ -678,8 +660,6 @@ printf(" embedded CMap\n");
goto cleanup;
}
-printf(" cidtogidmap %d\n", len / 2);
-
for (i = 0; i < len; i++)
map[i] = (buf->rp[i * 2] << 8) + buf->rp[i * 2 + 1];
@@ -815,8 +795,6 @@ printf(" cidtogidmap %d\n", len / 2);
goto cleanup;
}
-printf("\n");
-
return nil;
cleanup:
diff --git a/mupdf/interpret.c b/mupdf/interpret.c
index 578dc72c..494404fc 100644
--- a/mupdf/interpret.c
+++ b/mupdf/interpret.c
@@ -433,10 +433,7 @@ Lsetcolorspace:
obj = fz_dictget(dict, obj);
if (!obj)
return fz_throw("syntaxerror: missing colorspace resource");
- if (fz_isindirect(obj))
- cs = pdf_findresource(xref->rcolorspace, obj);
- else
- return fz_throw("syntaxerror: inline colorspace in dict");
+ cs = pdf_findresource(xref->rcolorspace, obj);
if (!cs)
return fz_throw("syntaxerror: missing colorspace resource");
}
diff --git a/mupdf/pattern.c b/mupdf/pattern.c
index fae71c45..cc8e9929 100644
--- a/mupdf/pattern.c
+++ b/mupdf/pattern.c
@@ -94,9 +94,6 @@ printf(" ystep %g\n", pat->ystep);
if (error)
goto cleanup2;
- if (csi->tree)
- fz_debugtree(csi->tree);
-
pat->tree = csi->tree;
csi->tree = nil;
diff --git a/mupdf/resources.c b/mupdf/resources.c
index 1db57a1b..953f2d24 100644
--- a/mupdf/resources.c
+++ b/mupdf/resources.c
@@ -2,11 +2,11 @@
#include <mupdf.h>
void *
-pdf_findresource(pdf_rsrc *rsrc, fz_obj *ref)
+pdf_findresource(pdf_rsrc *rsrc, fz_obj *key)
{
while (rsrc)
{
- if (rsrc->oid == fz_tonum(ref) && rsrc->gen == fz_togen(ref))
+ if (rsrc->key == key) /* TODO: compare equality not identity */
return rsrc->val;
rsrc = rsrc->next;
}
@@ -31,9 +31,9 @@ indirect references so we end up with a stylized structure:
>>
/ColorSpace <<
/Cs0 5 0 R
- /Cs1 [ /ICCBased 5 0 R ] % /Cs1 -1 0 R ???
- /Cs2 [ /CalRGB << ... >> ] % /Cs2 -2 0 R ???
- /CsX [ /Pattern /DeviceRGB ] % eep!
+ /Cs1 [ /ICCBased 5 0 R ]
+ /Cs2 [ /CalRGB << ... >> ]
+ /CsX [ /Pattern /DeviceRGB ]
>>
/Pattern <<
/Pat0 20 0 R
@@ -48,11 +48,7 @@ indirect references so we end up with a stylized structure:
>>
Then all references to actual resources will get
-parsed and inserted into the pdf_xref resource
-lists, indexed by their object number.
-
-TODO: inline colorspaces -> fake objects || refcount ?
-TODO: inline images -> fake objects || refcount?
+parsed and inserted into the pdf_xref resource lists.
*/
@@ -62,7 +58,10 @@ preloadcolorspace(pdf_xref *xref, fz_obj *ref)
fz_error *error;
fz_colorspace *colorspace;
pdf_rsrc *rsrc;
- fz_obj *obj;
+ fz_obj *obj = ref;
+
+ if (!fz_isindirect(ref))
+ fz_warn("inline colorspace resource");
if (pdf_findresource(xref->rcolorspace, ref))
return nil;
@@ -70,10 +69,8 @@ preloadcolorspace(pdf_xref *xref, fz_obj *ref)
rsrc = fz_malloc(sizeof(pdf_rsrc));
if (!rsrc)
return fz_outofmem;
- rsrc->oid = fz_tonum(ref);
- rsrc->gen = fz_togen(ref);
- error = pdf_loadindirect(&obj, xref, ref);
+ error = pdf_resolve(&obj, xref);
if (error)
return error;
error = pdf_loadcolorspace(&colorspace, xref, obj);
@@ -83,6 +80,7 @@ preloadcolorspace(pdf_xref *xref, fz_obj *ref)
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->val = colorspace;
rsrc->next = xref->rcolorspace;
xref->rcolorspace = rsrc;
@@ -94,8 +92,11 @@ preloadpattern(pdf_xref *xref, fz_obj *ref)
{
fz_error *error;
pdf_rsrc *rsrc;
- fz_obj *obj;
fz_obj *type;
+ fz_obj *obj = ref;
+
+ if (!fz_isindirect(ref))
+ fz_warn("inline pattern resource");
if (pdf_findresource(xref->rpattern, ref))
return nil;
@@ -105,10 +106,8 @@ preloadpattern(pdf_xref *xref, fz_obj *ref)
rsrc = fz_malloc(sizeof(pdf_rsrc));
if (!rsrc)
return fz_outofmem;
- rsrc->oid = fz_tonum(ref);
- rsrc->gen = fz_togen(ref);
- error = pdf_loadindirect(&obj, xref, ref);
+ error = pdf_resolve(&obj, xref);
if (error)
return error;
@@ -122,6 +121,7 @@ preloadpattern(pdf_xref *xref, fz_obj *ref)
fz_free(rsrc);
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->next = xref->rpattern;
xref->rpattern = rsrc;
return nil;
@@ -135,6 +135,7 @@ preloadpattern(pdf_xref *xref, fz_obj *ref)
fz_free(rsrc);
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->next = xref->rshade;
xref->rshade = rsrc;
return nil;
@@ -153,7 +154,10 @@ preloadshading(pdf_xref *xref, fz_obj *ref)
{
fz_error *error;
pdf_rsrc *rsrc;
- fz_obj *obj;
+ fz_obj *obj = ref;
+
+ if (!fz_isindirect(ref))
+ fz_warn("inline shading resource");
if (pdf_findresource(xref->rshade, ref))
return nil;
@@ -161,10 +165,8 @@ preloadshading(pdf_xref *xref, fz_obj *ref)
rsrc = fz_malloc(sizeof(pdf_rsrc));
if (!rsrc)
return fz_outofmem;
- rsrc->oid = fz_tonum(ref);
- rsrc->gen = fz_togen(ref);
- error = pdf_loadindirect(&obj, xref, ref);
+ error = pdf_resolve(&obj, xref);
if (error)
return error;
@@ -175,6 +177,7 @@ preloadshading(pdf_xref *xref, fz_obj *ref)
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->next = xref->rshade;
xref->rshade = rsrc;
return nil;
@@ -185,9 +188,12 @@ preloadxobject(pdf_xref *xref, fz_obj *ref)
{
fz_error *error;
pdf_rsrc *rsrc;
- fz_obj *obj;
+ fz_obj *obj = ref;
fz_obj *subtype;
+ if (!fz_isindirect(ref))
+ fz_warn("inline xobject resource");
+
if (pdf_findresource(xref->rxobject, ref))
return nil;
if (pdf_findresource(xref->rimage, ref))
@@ -196,10 +202,8 @@ preloadxobject(pdf_xref *xref, fz_obj *ref)
rsrc = fz_malloc(sizeof(pdf_rsrc));
if (!rsrc)
return fz_outofmem;
- rsrc->oid = fz_tonum(ref);
- rsrc->gen = fz_togen(ref);
- error = pdf_loadindirect(&obj, xref, ref);
+ error = pdf_resolve(&obj, xref);
if (error)
return error;
@@ -213,6 +217,7 @@ preloadxobject(pdf_xref *xref, fz_obj *ref)
fz_free(rsrc);
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->next = xref->rxobject;
xref->rxobject = rsrc;
return nil;
@@ -226,6 +231,7 @@ preloadxobject(pdf_xref *xref, fz_obj *ref)
fz_free(rsrc);
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->next = xref->rimage;
xref->rimage = rsrc;
return nil;
@@ -245,10 +251,10 @@ preloadfont(pdf_xref *xref, fz_obj *ref)
fz_error *error;
pdf_font *font;
pdf_rsrc *rsrc;
- fz_obj *obj;
+ fz_obj *obj = ref;
-if (!fz_isindirect(ref))
- fz_warn("inline font resource");
+ if (!fz_isindirect(ref))
+ fz_warn("inline font resource");
if (pdf_findresource(xref->rfont, ref))
return nil;
@@ -256,10 +262,8 @@ if (!fz_isindirect(ref))
rsrc = fz_malloc(sizeof(pdf_rsrc));
if (!rsrc)
return fz_outofmem;
- rsrc->oid = fz_tonum(ref);
- rsrc->gen = fz_togen(ref);
- error = pdf_loadindirect(&obj, xref, ref);
+ error = pdf_resolve(&obj, xref);
if (error)
return error;
error = pdf_loadfont(&font, xref, obj);
@@ -269,6 +273,7 @@ if (!fz_isindirect(ref))
return error;
}
+ rsrc->key = fz_keepobj(ref);
rsrc->val = font;
rsrc->next = xref->rfont;
xref->rfont = rsrc;
@@ -398,13 +403,9 @@ pdf_loadresources(fz_obj **rdbp, pdf_xref *xref, fz_obj *orig)
for (i = 0; i < fz_dictlen(dict); i++)
{
obj = fz_dictgetval(dict, i);
- if (fz_isindirect(obj))
- {
error = preloadcolorspace(xref, obj);
if (error)
return error;
- }
-else fz_warn("inline colorspace resource");
}
}
@@ -418,13 +419,9 @@ else fz_warn("inline colorspace resource");
for (i = 0; i < fz_dictlen(dict); i++)
{
obj = fz_dictgetval(dict, i);
- if (fz_isindirect(obj))
- {
error = preloadpattern(xref, obj);
if (error)
return error;
- }
-else fz_warn("inline pattern resource");
}
}
@@ -434,13 +431,9 @@ else fz_warn("inline pattern resource");
for (i = 0; i < fz_dictlen(dict); i++)
{
obj = fz_dictgetval(dict, i);
- if (fz_isindirect(obj))
- {
error = preloadshading(xref, obj);
if (error)
return error;
- }
-else fz_warn("inline shading resource");
}
}
@@ -454,13 +447,9 @@ else fz_warn("inline shading resource");
for (i = 0; i < fz_dictlen(dict); i++)
{
obj = fz_dictgetval(dict, i);
- if (fz_isindirect(obj))
- {
error = preloadxobject(xref, obj);
if (error)
return error;
- }
-else fz_warn("inline xobject resource");
}
}
diff --git a/mupdf/type3.c b/mupdf/type3.c
index 59c82db2..8406e763 100644
--- a/mupdf/type3.c
+++ b/mupdf/type3.c
@@ -107,8 +107,6 @@ pdf_loadtype3font(pdf_font **fontp, pdf_xref *xref, fz_obj *dict)
else
sprintf(buf, "Unnamed-T3");
-printf("loading type3 font %s\n", buf);
-
font = pdf_newfont(buf);
if (!font)
return fz_outofmem;
@@ -124,11 +122,6 @@ printf("loading type3 font %s\n", buf);
font->matrix.e = fz_toreal(fz_arrayget(obj, 4));
font->matrix.f = fz_toreal(fz_arrayget(obj, 5));
-printf(" matrix [%g %g %g %g %g %g]\n",
- font->matrix.a, font->matrix.b,
- font->matrix.c, font->matrix.d,
- font->matrix.e, font->matrix.f);
-
obj = fz_dictgets(dict, "FontBBox");
bbox.min.x = fz_toreal(fz_arrayget(obj, 0));
bbox.min.y = fz_toreal(fz_arrayget(obj, 1));
@@ -140,7 +133,6 @@ printf(" matrix [%g %g %g %g %g %g]\n",
bbox.max.x = fz_ceil(bbox.max.x * 1000);
bbox.max.y = fz_ceil(bbox.max.x * 1000);
fz_setfontbbox((fz_font*)font, bbox.min.x, bbox.min.y, bbox.max.x, bbox.max.y);
-printf(" bbox [%g %g %g %g]\n", bbox.min.x,bbox.min.y,bbox.max.x,bbox.max.y);
/*
* Encoding
diff --git a/render/glyphcache.c b/render/glyphcache.c
index 517a67ef..57b2ce84 100644
--- a/render/glyphcache.c
+++ b/render/glyphcache.c
@@ -215,15 +215,14 @@ hashremove(fz_glyphcache *arena, fz_key *key)
void
fz_debugglyphcache(fz_glyphcache *arena)
{
- int i;
-
printf("cache load %d / %d (%d / %d bytes)\n",
arena->load, arena->slots, arena->used, arena->size);
printf("no-colliders: %d colliders: %d\n", hokay, hcoll);
printf("avg dist: %d / %d: %g\n", hdist, hcoll, (double)hdist / hcoll);
printf("out-of-space evicts: %d\n", coos);
printf("out-of-hash evicts: %d\n", covf);
-
+/*
+ int i;
for (i = 0; i < arena->slots; i++)
{
if (!arena->hash[i].val)
@@ -246,6 +245,7 @@ fz_debugglyphcache(fz_glyphcache *arena)
for (i = 0; i < arena->load; i++)
printf("lru %04d: glyph %d (%d)\n", i,
arena->lru[i].ent - arena->hash, arena->lru[i].uses);
+*/
}
static void