diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-06-15 23:14:05 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-06-15 23:14:05 +0200 |
commit | 0604c0103d3a1a5a75ab7bd3060ff34bd8973592 (patch) | |
tree | d0a9b71b031de933959ea0651974b1698c9faff4 /fitz | |
parent | 5795eaee9455031dead3dff50d1ab2d06c5f9915 (diff) | |
download | mupdf-0604c0103d3a1a5a75ab7bd3060ff34bd8973592.tar.xz |
Use scissor bbox to clip shadings instead of using scratch buffers.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_draw.c | 64 | ||||
-rw-r--r-- | fitz/fitz_draw.h | 2 |
2 files changed, 13 insertions, 53 deletions
diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index b5b669bd..f8b3ed3b 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -25,42 +25,6 @@ struct fz_drawdevice_s }; static void -blendover(fz_pixmap *src, fz_pixmap *dst) -{ - unsigned char *sp, *dp; - fz_bbox sr, dr; - int x, y, w, h; - - sr.x0 = src->x; - sr.y0 = src->y; - sr.x1 = src->x + src->w; - sr.y1 = src->y + src->h; - - dr.x0 = dst->x; - dr.y0 = dst->y; - dr.x1 = dst->x + dst->w; - dr.y1 = dst->y + dst->h; - - dr = fz_intersectbbox(sr, dr); - x = dr.x0; - y = dr.y0; - w = dr.x1 - dr.x0; - h = dr.y1 - dr.y0; - - sp = src->samples + ((y - src->y) * src->w + (x - src->x)) * src->n; - dp = dst->samples + ((y - dst->y) * dst->w + (x - dst->x)) * dst->n; - - if (src->n == 1 && dst->n == 1) - fz_duff_1o1(sp, src->w, dp, dst->w, w, h); - else if (src->n == 4 && dst->n == 4) - fz_duff_4o4(sp, src->w * 4, dp, dst->w * 4, w, h); - else if (src->n == dst->n) - fz_duff_non(sp, src->w * src->n, src->n, dp, dst->w * dst->n, w, h); - else - assert(!"blendover src and dst mismatch"); -} - -static void blendmaskover(fz_pixmap *src, fz_pixmap *msk, fz_pixmap *dst) { unsigned char *sp, *dp, *mp; @@ -472,13 +436,13 @@ static void fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm) { fz_drawdevice *dev = user; + fz_pixmap *dest = dev->dest; fz_rect bounds; fz_bbox bbox; - fz_pixmap *temp; float rgb[3]; unsigned char argb[4]; unsigned char *s; - int n; + int x, y; bounds = fz_transformrect(fz_concat(shade->matrix, ctm), shade->bbox); bbox = fz_roundrect(bounds); @@ -493,8 +457,6 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm) return; } - temp = fz_newpixmapwithrect(dev->model, bbox); - if (shade->usebackground) { fz_convertcolor(shade->cs, shade->background, dev->model, rgb); @@ -502,22 +464,20 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm) argb[1] = rgb[0] * 255; argb[2] = rgb[1] * 255; argb[3] = rgb[2] * 255; - s = temp->samples; - n = temp->w * temp->h; - while (n--) + for (y = bbox.y0; y < bbox.y1; y++) { - *s++ = argb[0]; - *s++ = argb[1]; - *s++ = argb[2]; - *s++ = argb[3]; + s = dest->samples + ((bbox.x0 - dest->x) + (y - dest->y) * dest->w) * dest->n; + for (x = bbox.x0; x < bbox.x1; x++) + { + *s++ = argb[0]; + *s++ = argb[1]; + *s++ = argb[2]; + *s++ = argb[3]; + } } - blendover(temp, dev->dest); } - fz_rendershade(shade, ctm, temp); - blendover(temp, dev->dest); - - fz_droppixmap(temp); + fz_rendershade(shade, ctm, dev->dest, bbox); } static inline void diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h index a67a0c25..4ef84e1d 100644 --- a/fitz/fitz_draw.h +++ b/fitz/fitz_draw.h @@ -386,7 +386,7 @@ void fz_dropshade(fz_shade *shade); void fz_debugshade(fz_shade *shade); fz_rect fz_boundshade(fz_shade *shade, fz_matrix ctm); -void fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dst); +void fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dst, fz_bbox bbox); /* * Glyph cache |