diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-01-07 19:21:13 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-01-07 19:21:13 +0100 |
commit | a167d7f21c4862d502e0db609998d19ca9ea7d3b (patch) | |
tree | 850c728ec7df1db7df5ed49a9e51dcd3a00b06ff | |
parent | c9b33125b5093df3df622c26fbb20a6dd8656ad0 (diff) | |
download | mupdf-a167d7f21c4862d502e0db609998d19ca9ea7d3b.tar.xz |
Reenable x11pdf viewer.
-rw-r--r-- | apps/pdfapp.c | 25 | ||||
-rw-r--r-- | apps/pdfapp.h | 1 | ||||
-rw-r--r-- | apps/pdfdraw.c | 3 | ||||
-rw-r--r-- | fitz/dev_draw.c | 13 | ||||
-rw-r--r-- | fitz/fitz_base.h | 2 | ||||
-rw-r--r-- | fitz/fitz_draw.h | 1 | ||||
-rw-r--r-- | fitzdraw/meshdraw.c | 2 | ||||
-rw-r--r-- | fitzdraw/pixmap.c | 4 |
8 files changed, 25 insertions, 26 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 137825ec..c6bc64d1 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -52,14 +52,7 @@ char *pdfapp_usage(pdfapp_t *app) void pdfapp_init(pdfapp_t *app) { - fz_error error; - memset(app, 0, sizeof(pdfapp_t)); - - error = fz_newrenderer(&app->rast, pdf_devicergb, 0, 1024 * 512); - if (error) - pdfapp_error(app, error); - app->scrw = 640; app->scrh = 480; app->zoom = 1.0; @@ -171,7 +164,7 @@ void pdfapp_close(pdfapp_t *app) app->page = nil; if (app->image) - fz_droppixmap(app->image); + fz_freepixmap(app->image); app->image = nil; if (app->outline) @@ -224,8 +217,9 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage) { char buf[256]; fz_error error; + fz_device *dev; fz_matrix ctm; - fz_rect bbox; + fz_irect bbox; fz_obj *obj; if (loadpage) @@ -253,14 +247,17 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage) wincursor(app, WAIT); if (app->image) - fz_droppixmap(app->image); + fz_freepixmap(app->image); app->image = nil; ctm = pdfapp_viewctm(app); - bbox = fz_transformaabb(ctm, app->page->mediabox); - - error = fz_rendertree(&app->image, app->rast, app->page->tree, - ctm, fz_roundrect(bbox), 1); + bbox = fz_roundrect(fz_transformaabb(ctm, app->page->mediabox)); + app->image = fz_newpixmapwithrect(bbox, 4); + fz_clearpixmap(app->image, 0xFF); + app->page->contents->rp = app->page->contents->bp; + dev = fz_newdrawdevice(pdf_devicergb, app->image); + error = pdf_runcontentstream(dev, ctm, 0, app->xref, app->page->resources, app->page->contents); + fz_freedrawdevice(dev); if (error) pdfapp_error(app, error); diff --git a/apps/pdfapp.h b/apps/pdfapp.h index 3b7852be..3504a605 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -26,7 +26,6 @@ struct pdfapp_s char *doctitle; pdf_xref *xref; pdf_outline *outline; - fz_renderer *rast; int pagecount; /* current view params */ diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 00dc8848..d47db425 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -207,6 +207,7 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark * } pix = fz_newpixmap(bbox.x0, bbox.y0, w, bh, 4); + fz_clearpixmap(pix, 0xFF); memset(pix->samples, 0xff, pix->h * pix->w * pix->n); @@ -229,7 +230,7 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark * error = pdf_runcontentstream(dev, ctm, 0, xref, drawpage->resources, drawpage->contents); if (error) die(error); - fz_free(dev); + fz_freedrawdevice(dev); if (drawpattern) { diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index 563289e7..ea2f48ef 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -535,12 +535,13 @@ fz_device *fz_newdrawdevice(fz_colorspace *colorspace, fz_pixmap *dest) } void -fz_freedrawdevice(void *user) +fz_freedrawdevice(fz_device *dev) { - fz_drawdevice *dev = user; - fz_dropcolorspace(dev->model); - fz_freeglyphcache(dev->cache); - fz_freegel(dev->gel); - fz_freeael(dev->ael); + fz_drawdevice *ddev = dev->user; + fz_dropcolorspace(ddev->model); + fz_freeglyphcache(ddev->cache); + fz_freegel(ddev->gel); + fz_freeael(ddev->ael); + fz_free(ddev); fz_free(dev); } diff --git a/fitz/fitz_base.h b/fitz/fitz_base.h index 10ec702e..67665204 100644 --- a/fitz/fitz_base.h +++ b/fitz/fitz_base.h @@ -312,7 +312,7 @@ fz_pixmap * fz_newpixmap(int x, int y, int w, int h, int n); fz_pixmap * fz_newpixmapcopy(fz_pixmap *old); void fz_debugpixmap(fz_pixmap *map, char *prefix); -void fz_clearpixmap(fz_pixmap *map); +void fz_clearpixmap(fz_pixmap *map, unsigned char value); void fz_freepixmap(fz_pixmap *map); fz_pixmap * fz_scalepixmap(fz_pixmap *src, int xdenom, int ydenom); diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h index 9fb093b1..f106f792 100644 --- a/fitz/fitz_draw.h +++ b/fitz/fitz_draw.h @@ -13,6 +13,7 @@ typedef struct fz_glyph_s fz_glyph; typedef struct fz_glyphcache_s fz_glyphcache; fz_device *fz_newdrawdevice(fz_colorspace *colorspace, fz_pixmap *dest); +void fz_freedrawdevice(fz_device *dev); fz_glyphcache * fz_newglyphcache(int slots, int size); void fz_renderftglyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm); diff --git a/fitzdraw/meshdraw.c b/fitzdraw/meshdraw.c index b770a1b4..a204f889 100644 --- a/fitzdraw/meshdraw.c +++ b/fitzdraw/meshdraw.c @@ -341,7 +341,7 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_colorspace *destcs, fz_pixmap temp = dest; } - fz_clearpixmap(temp); + fz_clearpixmap(temp, 0); for (i = 0; i < shade->meshlen; i++) { diff --git a/fitzdraw/pixmap.c b/fitzdraw/pixmap.c index a219f0bd..87c136f2 100644 --- a/fitzdraw/pixmap.c +++ b/fitzdraw/pixmap.c @@ -39,9 +39,9 @@ fz_freepixmap(fz_pixmap *pix) } void -fz_clearpixmap(fz_pixmap *pix) +fz_clearpixmap(fz_pixmap *pix, unsigned char value) { - memset(pix->samples, 0, pix->w * pix->h * pix->n * sizeof(fz_sample)); + memset(pix->samples, value, pix->w * pix->h * pix->n * sizeof(fz_sample)); } void |