summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/filec.c27
-rw-r--r--include/mupdf/content.h2
-rw-r--r--mupdf/build.c17
-rw-r--r--mupdf/interpret.c12
-rw-r--r--test/x11pdf.c31
-rw-r--r--test/ximage.c9
6 files changed, 67 insertions, 31 deletions
diff --git a/filter/filec.c b/filter/filec.c
index 4388b48a..05813185 100644
--- a/filter/filec.c
+++ b/filter/filec.c
@@ -282,6 +282,25 @@ fz_seek(fz_file *f, int ofs, int whence)
whence = 0;
}
+ if (f->fd == -1)
+ {
+ if (whence == 0)
+ {
+ if (f->mode == FZ_READ)
+ f->out->rp = CLAMP(f->out->bp + ofs, f->out->bp, f->in->ep);
+ else
+ f->in->wp = CLAMP(f->in->bp + ofs, f->in->bp, f->in->ep);
+ }
+ else
+ {
+ if (f->mode == FZ_READ)
+ f->out->rp = CLAMP(f->out->ep + ofs, f->out->bp, f->in->ep);
+ else
+ f->in->wp = CLAMP(f->in->ep + ofs, f->in->bp, f->in->ep);
+ }
+ return fz_tell(f);
+ }
+
t = lseek(f->fd, ofs, whence);
if (t == -1)
{
@@ -307,6 +326,14 @@ fz_tell(fz_file *f)
return f->filter->count - (f->out->wp - f->out->rp);
}
+ if (f->fd == -1)
+ {
+ if (f->mode == FZ_READ)
+ return f->out->rp - f->out->bp;
+ else
+ return f->in->wp - f->in->bp;
+ }
+
t = lseek(f->fd, 0, 1);
if (t == -1)
{
diff --git a/include/mupdf/content.h b/include/mupdf/content.h
index 65bd386e..adc5757a 100644
--- a/include/mupdf/content.h
+++ b/include/mupdf/content.h
@@ -72,7 +72,7 @@ struct pdf_csi_s
/* path object state */
fz_pathnode *path;
- fz_pathnode *clip;
+ int clip;
/* text object state */
fz_node *textclip;
diff --git a/mupdf/build.c b/mupdf/build.c
index cd949a15..93d1a26d 100644
--- a/mupdf/build.c
+++ b/mupdf/build.c
@@ -580,16 +580,21 @@ pdf_showpath(pdf_csi *csi,
if (error) return error;
}
- if (!dofill && !dostroke)
+ if (csi->clip)
{
- fz_free(csi->path);
+ fz_pathnode *clip;
+ error = fz_clonepathnode(&clip, csi->path);
+ if (error) return error;
+ error = fz_endpath(clip, FZ_FILL, nil, nil);
+ if (error) return error;
+ error = pdf_addclipmask(gstate, (fz_node*)clip);
+ if (error) return error;
+ csi->clip = 0;
}
- if (csi->clip)
+ if (!dofill && !dostroke)
{
- error = pdf_addclipmask(gstate, (fz_node*)csi->clip);
- if (error) return error;
- csi->clip = nil;
+ fz_dropnode((fz_node*)csi->path);
}
csi->path = nil;
diff --git a/mupdf/interpret.c b/mupdf/interpret.c
index 753a4aaf..d4b2b2be 100644
--- a/mupdf/interpret.c
+++ b/mupdf/interpret.c
@@ -42,7 +42,7 @@ pdf_newcsi(pdf_csi **csip, int maskonly)
csi->gstate[0].stroke.kind = PDF_MNONE;
}
- csi->clip = nil;
+ csi->clip = 0;
csi->textclip = nil;
csi->textmode = 0;
@@ -427,10 +427,7 @@ runkeyword(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, char *buf)
{
if (csi->top != 0)
goto syntaxerror;
- error = fz_clonepathnode(&csi->clip, csi->path);
- if (error) return error;
- error = fz_endpath(csi->clip, FZ_EOFILL, nil, nil);
- if (error) return error;
+ csi->clip = 1;
}
else if (!strcmp(buf, "cs"))
@@ -990,10 +987,7 @@ fz_debugobj(rdb);
case 'W':
if (csi->top != 0)
goto syntaxerror;
- error = fz_clonepathnode(&csi->clip, csi->path);
- if (error) return error;
- error = fz_endpath(csi->clip, FZ_FILL, nil, nil);
- if (error) return error;
+ csi->clip = 1;
break;
case 'g':
diff --git a/test/x11pdf.c b/test/x11pdf.c
index 5dbfb506..6e38071f 100644
--- a/test/x11pdf.c
+++ b/test/x11pdf.c
@@ -48,7 +48,10 @@ static fz_pixmap *image;
void usage()
{
- fprintf(stderr, "usage: x11pdf [-u password] file.pdf\n");
+ fprintf(stderr, "usage: x11pdf [-b] [-pzr page/zoom/rotate] [-u password] file.pdf\n");
+ fprintf(stderr,
+"\n"
+ );
exit(1);
}
@@ -200,7 +203,13 @@ static void pdfopen(char *filename, char *password)
error = pdf_openpdf(&xref, filename);
if (error)
- fz_abort(error);
+ {
+ fz_warn(error->msg);
+ printf("trying to repair...\n");
+ error = pdf_repairpdf(&xref, filename);
+ if (error)
+ fz_abort(error);
+ }
error = pdf_decryptpdf(xref);
if (error)
@@ -486,12 +495,14 @@ int main(int argc, char **argv)
char *filename;
int c;
+ int benchmark = 0;
char *password = "";
- while ((c = getopt(argc, argv, "z:r:p:u:")) != -1)
+ while ((c = getopt(argc, argv, "bz:r:p:u:")) != -1)
{
switch (c)
{
+ case 'b': ++benchmark; break;
case 'u': password = optarg; break;
case 'p': pageno = atoi(optarg); break;
case 'z': zoom = atof(optarg); break;
@@ -512,13 +523,16 @@ int main(int argc, char **argv)
pdfopen(filename, password);
showpage();
-#ifdef RUNFAST
- while (pageno < count)
+ if (benchmark)
{
- pageno ++;
- showpage();
+ while (pageno < count)
+ {
+ pageno ++;
+ showpage();
+ }
+ return 0;
}
-#else
+
while (1)
{
int len;
@@ -548,7 +562,6 @@ int main(int argc, char **argv)
break;
}
}
-#endif
pdf_closepdf(xref);
diff --git a/test/ximage.c b/test/ximage.c
index 1e56fa2e..9f7ec064 100644
--- a/test/ximage.c
+++ b/test/ximage.c
@@ -125,9 +125,6 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w,
shmctl(xsi->shmid, IPC_RMID, 0);
- printf("make xshm w=%d h=%d id=%d data=%p\n",
- w, h, xsi->shmid, xsi->shmaddr);
-
return img;
fallback:
@@ -211,7 +208,7 @@ select_mode(void)
gs = ffs(gm) - 1;
bs = ffs(bm) - 1;
- printf("mode %d/%d %08lx %08lx %08lx (%ld,%ld,%ld) %s%s\n",
+ printf("ximage: mode %d/%d %08lx %08lx %08lx (%ld,%ld,%ld) %s%s\n",
info.visual.depth,
info.bitsperpixel,
rm, gm, bm, rs, gs, bs,
@@ -246,7 +243,7 @@ select_mode(void)
info.mode = byteorder == MSBFirst ? RGBA8888 : ABGR8888;
}
- printf("convert ARGB8888 to %s\n", modename[info.mode]);
+ printf("ximage: ARGB8888 to %s\n", modename[info.mode]);
/* select conversion function */
info.convert_func = ximage_convert_funcs[info.mode];
@@ -340,7 +337,7 @@ ximage_init(Display *display, int screen, Visual *visual)
if (!ok)
return 0;
- printf("Using %sPutImage\n", info.useshm ? "XShm" : "X");
+ printf("ximage: %sPutImage\n", info.useshm ? "XShm" : "X");
return 1;
}