summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw/meshdraw.c44
-rw-r--r--fitz/dev_draw.c64
-rw-r--r--fitz/fitz_draw.h2
3 files changed, 37 insertions, 73 deletions
diff --git a/draw/meshdraw.c b/draw/meshdraw.c
index 002f58ad..8e876397 100644
--- a/draw/meshdraw.c
+++ b/draw/meshdraw.c
@@ -217,14 +217,14 @@ stepedge(int *ael, int *del, int n)
}
static void
-fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n)
+fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox)
{
float poly[MAXV][MAXN];
float temp[MAXV][MAXN];
- float cx0 = pix->x;
- float cy0 = pix->y;
- float cx1 = pix->x + pix->w;
- float cy1 = pix->y + pix->h;
+ float cx0 = bbox.x0;
+ float cy0 = bbox.y0;
+ float cx1 = bbox.x1;
+ float cy1 = bbox.y1;
int gel[MAXV][MAXN];
int ael[2][MAXN];
@@ -311,15 +311,17 @@ fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n)
*/
void
-fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest)
+fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
{
unsigned char clut[256][FZ_MAXCOLORS];
unsigned char *s, *d;
+ unsigned char sa, ssa;
fz_pixmap *temp;
float color[FZ_MAXCOLORS];
float tri[3][MAXN];
fz_point p;
int i, j, k, n;
+ int x, y;
assert(dest->n == 4);
@@ -328,7 +330,8 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest)
if (shade->usefunction)
{
n = 3;
- temp = fz_newpixmap(pdf_devicegray, dest->x, dest->y, dest->w, dest->h);
+ temp = fz_newpixmapwithrect(pdf_devicegray, bbox);
+ fz_clearpixmap(temp, 0);
}
else
{
@@ -336,8 +339,6 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest)
temp = dest;
}
- fz_clearpixmap(temp, 0);
-
for (i = 0; i < shade->meshlen; i++)
{
for (k = 0; k < 3; k++)
@@ -357,7 +358,7 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest)
tri[k][j + 2] *= 255;
}
}
- fz_drawtriangle(temp, tri[0], tri[1], tri[2], 2 + temp->colorspace->n);
+ fz_drawtriangle(temp, tri[0], tri[1], tri[2], 2 + temp->colorspace->n, bbox);
}
if (shade->usefunction)
@@ -369,17 +370,20 @@ fz_rendershade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest)
clut[i][k] = color[k] * 255;
}
- n = temp->w * temp->h;
- s = temp->samples;
- d = dest->samples;
-
- while (n--)
+ for (y = bbox.y0; y < bbox.y1; y++)
{
- d[0] = s[0];
- for (k = 0; k < dest->colorspace->n; k++)
- d[k + 1] = fz_mul255(s[0], clut[s[1]][k]);
- s += 2;
- d += 1 + dest->colorspace->n;
+ s = temp->samples + ((bbox.x0 - temp->x) + (y - temp->y) * temp->w) * temp->n;
+ d = dest->samples + ((bbox.x0 - dest->x) + (y - dest->y) * dest->w) * dest->n;
+ for (x = bbox.x0; x < bbox.x1; x++)
+ {
+ sa = s[0];
+ ssa = 255 - sa;
+ d[0] = s[0] + fz_mul255(d[0], ssa);
+ for (k = 0; k < dest->colorspace->n; k++)
+ d[k+1] = fz_mul255(clut[s[1]][k], sa) + fz_mul255(d[k+1], ssa);
+ s += 2;
+ d += 1 + dest->colorspace->n;
+ }
}
fz_droppixmap(temp);
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