diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-06-30 02:29:48 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-06-30 02:29:48 +0200 |
commit | 1a789da086a7816384495f2737b89bd3b7700f10 (patch) | |
tree | 72b2eaa8b603109ec6bb2c8ae2bdbca7e384a895 /draw | |
parent | 9b36c63c9c25c7f6c7c99ff30385a29bc51703c5 (diff) | |
download | mupdf-1a789da086a7816384495f2737b89bd3b7700f10.tar.xz |
Refactor and clean up shading code a bit.
Diffstat (limited to 'draw')
-rw-r--r-- | draw/meshdraw.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/draw/meshdraw.c b/draw/meshdraw.c index 72a723e0..dc76e9fa 100644 --- a/draw/meshdraw.c +++ b/draw/meshdraw.c @@ -320,42 +320,45 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) float color[FZ_MAXCOLORS]; float tri[3][MAXN]; fz_point p; - int i, j, k, n; + float *mesh; + int ntris; + int i, j, k; int x, y; assert(dest->n == 4); ctm = fz_concat(shade->matrix, ctm); + mesh = shade->mesh; if (shade->usefunction) { - n = 3; temp = fz_newpixmapwithrect(pdf_devicegray, bbox); fz_clearpixmap(temp, 0); + ntris = shade->meshlen / 9; } else { - n = 2 + shade->cs->n; temp = dest; + ntris = shade->meshlen / ((2 + shade->cs->n) * 3); } - for (i = 0; i < shade->meshlen; i++) + while (ntris--) { for (k = 0; k < 3; k++) { - p.x = shade->mesh[(i * 3 + k) * n + 0]; - p.y = shade->mesh[(i * 3 + k) * n + 1]; + p.x = *mesh++; + p.y = *mesh++; p = fz_transformpoint(ctm, p); tri[k][0] = p.x; tri[k][1] = p.y; if (shade->usefunction) - tri[k][2] = shade->mesh[(i * 3 + k) * n + 2] * 255; + tri[k][2] = *mesh++ * 255; else { - fz_convertcolor(shade->cs, shade->mesh + (i * 3 + k) * n + 2, - temp->colorspace, tri[k] + 2); + fz_convertcolor(shade->cs, mesh, temp->colorspace, tri[k] + 2); for (j = 0; j < temp->colorspace->n; j++) tri[k][j + 2] *= 255; + mesh += shade->cs->n; } } fz_drawtriangle(temp, tri[0], tri[1], tri[2], 2 + temp->colorspace->n, bbox); |