summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-04-15 22:40:41 +0200
committerTor Andersson <tor@ghostscript.com>2010-04-15 22:40:41 +0200
commit80f493b34eb72dfad76d06a97545e64afff84f78 (patch)
treee048b299da91aba52b878eab6242780f9f896bfc /apps
parentbd7e94651b00d884ffb0a5349182d99a87396a6d (diff)
downloadmupdf-80f493b34eb72dfad76d06a97545e64afff84f78.tar.xz
Make the glyph cache an input to fz_newdrawdevice so that it can be shared between pages.
Diffstat (limited to 'apps')
-rw-r--r--apps/pdfapp.c7
-rw-r--r--apps/pdfapp.h1
-rw-r--r--apps/pdfdraw.c10
3 files changed, 16 insertions, 2 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 499502ca..e4aaa07b 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -56,6 +56,7 @@ void pdfapp_init(pdfapp_t *app)
app->scrw = 640;
app->scrh = 480;
app->zoom = 1.0;
+ app->cache = fz_newglyphcache(512, 512 * 512);
}
void pdfapp_open(pdfapp_t *app, char *filename)
@@ -133,6 +134,10 @@ void pdfapp_open(pdfapp_t *app, char *filename)
void pdfapp_close(pdfapp_t *app)
{
+ if (app->cache)
+ fz_freeglyphcache(app->cache);
+ app->cache = nil;
+
if (app->page)
pdf_droppage(app->page);
app->page = nil;
@@ -241,7 +246,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage)
fz_droppixmap(app->image);
app->image = fz_newpixmapwithrect(pdf_devicergb, bbox);
fz_clearpixmap(app->image, 0xFF);
- idev = fz_newdrawdevice(app->image);
+ idev = fz_newdrawdevice(app->cache, app->image);
fz_executedisplaylist(list, idev, ctm);
fz_freedevice(idev);
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index d243dea1..1c80ee4a 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -27,6 +27,7 @@ struct pdfapp_s
pdf_xref *xref;
pdf_outline *outline;
int pagecount;
+ fz_glyphcache *cache;
/* current view params */
float zoom;
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c
index 14ec4afd..8f840bd0 100644
--- a/apps/pdfdraw.c
+++ b/apps/pdfdraw.c
@@ -50,6 +50,7 @@ struct benchmark
int maxpage;
};
+static fz_glyphcache *drawcache = nil;
static int drawmode = DRAWPNM;
static char *drawpattern = nil;
static pdf_page *drawpage = nil;
@@ -67,6 +68,11 @@ static void local_cleanup(void)
pdf_dropstore(xref->store);
xref->store = nil;
}
+ if (drawcache)
+ {
+ fz_freeglyphcache(drawcache);
+ drawcache = nil;
+ }
}
static void drawusage(void)
@@ -216,7 +222,7 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark *
if (drawbands > 1)
fprintf(stdout, "drawing band %d / %d\n", b + 1, drawbands);
- dev = fz_newdrawdevice(pix);
+ dev = fz_newdrawdevice(drawcache, pix);
drawpage->contents->rp = drawpage->contents->bp;
error = pdf_runcontentstream(dev, ctm, xref, drawpage->resources, drawpage->contents);
if (error)
@@ -454,6 +460,8 @@ int main(int argc, char **argv)
if (fz_optind == argc)
drawusage();
+ drawcache = fz_newglyphcache(512, 512*512);
+
setcleanup(local_cleanup);
state = NO_FILE_OPENED;