diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-01-07 00:19:10 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-01-07 00:19:10 +0100 |
commit | 662c6a3a0fe8bd09e90b877095f52a062eb92f22 (patch) | |
tree | f29952cb9cfc081cfbc34339ba581d13bcad5e2e | |
parent | 12f3f31f0b28ee8854858e54962c9e5763a37d5e (diff) | |
download | mupdf-662c6a3a0fe8bd09e90b877095f52a062eb92f22.tar.xz |
Fix typos in stroking code and pass the device matrix to the interpreter. Now tigers.
-rw-r--r-- | apps/pdfdraw.c | 4 | ||||
-rw-r--r-- | fitz/dev_draw.c | 49 | ||||
-rw-r--r-- | fitzdraw/pathstroke.c | 5 | ||||
-rw-r--r-- | fitzdraw/porterduff.c | 6 | ||||
-rw-r--r-- | mupdf/mupdf.h | 4 | ||||
-rw-r--r-- | mupdf/pdf_build.c | 4 | ||||
-rw-r--r-- | mupdf/pdf_interpret.c | 4 |
7 files changed, 55 insertions, 21 deletions
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 94e24f76..9cba8472 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -217,17 +217,19 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark * if (drawbands > 1) fprintf(stderr, "drawing band %d / %d\n", b + 1, drawbands); +#if 0 printf("\nRESOURCES:\n"); fz_debugobj(fz_resolveindirect(drawpage->resources)); printf("CONTENTS:\n"); showsafe(drawpage->contents->rp, drawpage->contents->wp - drawpage->contents->rp); printf("END.\n"); +#endif fz_device *dev = fz_newdrawdevice(pdf_devicergb, pix); drawpage->contents->rp = drawpage->contents->bp; fz_stream *file = fz_openrbuffer(drawpage->contents); - pdf_csi *csi = pdf_newcsi(dev, 0); + pdf_csi *csi = pdf_newcsi(dev, 0, ctm); error = pdf_runcsi(csi, xref, drawpage->resources, file); fz_dropstream(file); if (error) diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index cd3613e3..0719766d 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -19,14 +19,20 @@ void fz_drawfillpath(void *user, fz_path *path, fz_colorspace *colorspace, float float flatness = 0.3 / expansion; fz_irect bbox; fz_irect clip; - unsigned char argb[4]; + unsigned char argb[7]; + float rgb[3]; if (flatness < 0.1) flatness = 0.1; - argb[0] = 0xFF; - argb[1] = 0xFF; - argb[2] = 0x00; - argb[3] = 0x00; + + fz_convertcolor(colorspace, color, dev->model, rgb); + argb[0] = alpha * 255; + argb[1] = rgb[0] * alpha * 255; + argb[2] = rgb[1] * alpha * 255; + argb[3] = rgb[2] * alpha * 255; + argb[4] = rgb[0] * 255; + argb[5] = rgb[1] * 255; + argb[6] = rgb[2] * 255; clip.x0 = dev->dest->x; clip.y0 = dev->dest->y; @@ -53,16 +59,22 @@ void fz_drawstrokepath(void *user, fz_path *path, fz_colorspace *colorspace, flo float linewidth = path->linewidth; fz_irect bbox; fz_irect clip; - unsigned char argb[4]; + unsigned char argb[7]; + float rgb[3]; if (flatness < 0.1) flatness = 0.1; if (linewidth < 0.1) linewidth = 1.0 / expansion; - argb[0] = 0xFF; - argb[1] = 0x00; - argb[2] = 0xFF; - argb[3] = 0x00; + + fz_convertcolor(colorspace, color, dev->model, rgb); + argb[0] = alpha * 255; + argb[1] = rgb[0] * alpha * 255; + argb[2] = rgb[1] * alpha * 255; + argb[3] = rgb[2] * alpha * 255; + argb[4] = rgb[0] * 255; + argb[5] = rgb[1] * 255; + argb[6] = rgb[2] * 255; clip.x0 = dev->dest->x; clip.y0 = dev->dest->y; @@ -81,16 +93,31 @@ void fz_drawstrokepath(void *user, fz_path *path, fz_colorspace *colorspace, flo if (fz_isemptyrect(bbox)) return; - fz_scanconvert(dev->gel, dev->ael, FZ_NONZERO, bbox, dev->dest, argb, 1); + fz_scanconvert(dev->gel, dev->ael, 0, bbox, dev->dest, argb, 1); } void fz_drawclippath(void *user, fz_path *path) { fz_drawdevice *dev = user; + fz_printpath(path, 0); + printf("clippath\n"); } void fz_drawfilltext(void *user, fz_text *text, fz_colorspace *colorspace, float *color, float alpha) { + fz_drawdevice *dev = user; + unsigned char argb[7]; + float rgb[3]; + + fz_convertcolor(colorspace, color, dev->model, rgb); + argb[0] = alpha * 255; + argb[1] = rgb[0] * alpha * 255; + argb[2] = rgb[1] * alpha * 255; + argb[3] = rgb[2] * alpha * 255; + argb[4] = rgb[0] * 255; + argb[5] = rgb[1] * 255; + argb[6] = rgb[2] * 255; + printf("/%s setfont\n", text->font->name); fz_debugtext(text, 0); printf("show\n"); diff --git a/fitzdraw/pathstroke.c b/fitzdraw/pathstroke.c index 0373931a..73d3bba3 100644 --- a/fitzdraw/pathstroke.c +++ b/fitzdraw/pathstroke.c @@ -241,6 +241,7 @@ linedot(struct sctx *s, fz_point a) float ox = a.x - linewidth; float oy = a.y; int i; + for (i = 1; i < n; i++) { float theta = M_PI * 2 * i / n; @@ -252,6 +253,7 @@ linedot(struct sctx *s, fz_point a) ox = nx; oy = ny; } + line(s, ox, oy, a.x - linewidth, a.y); } @@ -288,7 +290,10 @@ strokelineto(struct sctx *s, fz_point cur) float dy = cur.y - s->seg[s->sn-1].y; if (dx * dx + dy * dy < FLT_EPSILON) + { s->dot = 1; + return; + } linestroke(s, s->seg[s->sn-1], cur); diff --git a/fitzdraw/porterduff.c b/fitzdraw/porterduff.c index 78ba198d..59e41ccc 100644 --- a/fitzdraw/porterduff.c +++ b/fitzdraw/porterduff.c @@ -259,9 +259,9 @@ static void path_1o1(byte * restrict src, byte cov, int len, byte * restrict dst static void path_w4i1o4(byte * restrict argb, byte * restrict src, byte cov, int len, byte * restrict dst) { byte alpha = argb[0]; - byte r = argb[4]; - byte g = argb[5]; - byte b = argb[6]; + byte r = argb[1]; + byte g = argb[2]; + byte b = argb[3]; while (len--) { byte ca; diff --git a/mupdf/mupdf.h b/mupdf/mupdf.h index 940b33cb..ad9a4ff2 100644 --- a/mupdf/mupdf.h +++ b/mupdf/mupdf.h @@ -701,7 +701,7 @@ struct pdf_csi_s }; /* build.c */ -void pdf_initgstate(pdf_gstate *gs); +void pdf_initgstate(pdf_gstate *gs, fz_matrix ctm); void pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *cs); void pdf_setcolor(pdf_csi *csi, int what, float *v); void pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v); @@ -713,7 +713,7 @@ void pdf_showimage(pdf_csi*, pdf_image *img); void pdf_showshade(pdf_csi*, fz_shade *shd); /* interpret.c */ -pdf_csi *pdf_newcsi(fz_device *dev, int maskonly); +pdf_csi *pdf_newcsi(fz_device *dev, int maskonly, fz_matrix ctm); fz_error pdf_runcsi(pdf_csi *, pdf_xref *xref, fz_obj *resources, fz_stream *contents); void pdf_dropcsi(pdf_csi *csi); diff --git a/mupdf/pdf_build.c b/mupdf/pdf_build.c index 46112ca1..43593f12 100644 --- a/mupdf/pdf_build.c +++ b/mupdf/pdf_build.c @@ -2,9 +2,9 @@ #include "mupdf.h" void -pdf_initgstate(pdf_gstate *gs) +pdf_initgstate(pdf_gstate *gs, fz_matrix ctm) { - gs->ctm = fz_identity(); + gs->ctm = ctm; gs->linewidth = 1.0; gs->linecap = 0; diff --git a/mupdf/pdf_interpret.c b/mupdf/pdf_interpret.c index e96d5905..2af65552 100644 --- a/mupdf/pdf_interpret.c +++ b/mupdf/pdf_interpret.c @@ -2,13 +2,13 @@ #include "mupdf.h" pdf_csi * -pdf_newcsi(fz_device *dev, int maskonly) +pdf_newcsi(fz_device *dev, int maskonly, fz_matrix ctm) { pdf_csi *csi; csi = fz_malloc(sizeof(pdf_csi)); - pdf_initgstate(&csi->gstate[0]); + pdf_initgstate(&csi->gstate[0], ctm); csi->gtop = 0; csi->top = 0; csi->xbalance = 0; |