diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-21 22:42:11 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-21 22:42:11 +0000 |
commit | d5d8d07709f6ad7d76ee1c466faf4d28549299a9 (patch) | |
tree | 4a5a49a4cf4edb527ac757068dfd3c6ec7d504e8 /draw/porterduff.c | |
parent | c7f031f2039aa6b8c681e377849208ebea4b6f01 (diff) | |
download | mupdf-d5d8d07709f6ad7d76ee1c466faf4d28549299a9.tar.xz |
Replace path blending with general blending functions. Rewrite image rendering loops so they don't depend on the scan converter.
Diffstat (limited to 'draw/porterduff.c')
-rw-r--r-- | draw/porterduff.c | 68 |
1 files changed, 5 insertions, 63 deletions
diff --git a/draw/porterduff.c b/draw/porterduff.c index 3596616d..e5070a5d 100644 --- a/draw/porterduff.c +++ b/draw/porterduff.c @@ -72,64 +72,6 @@ and stick to using the premultiplied form. typedef unsigned char byte; -/* - * Path drawing (the source colors are not premultiplied) - */ - -static void -path_1o1(byte * restrict src, byte cov, int len, byte * restrict dst) -{ - while (len--) - { - int c; - cov += *src; *src = 0; src++; - c = FZ_EXPAND(cov); - dst[0] = FZ_BLEND(255, dst[0], c); - dst++; - } -} - -static void -path_w2i1o2(byte *ga, byte * restrict src, byte cov, int len, byte * restrict dst) -{ - byte g = ga[0]; - int a = FZ_EXPAND(ga[1]); - - while (len--) - { - int ca; - cov += *src; *src = 0; src++; - ca = FZ_COMBINE(FZ_EXPAND(cov), a); - dst[0] = FZ_BLEND(g, dst[0], ca); - dst[1] = FZ_BLEND(255, dst[1], ca); - dst += 2; - } -} - -static void -path_w4i1o4(byte *rgba, byte * restrict src, byte cov, int len, byte * restrict dst) -{ - byte r = rgba[0]; - byte g = rgba[1]; - byte b = rgba[2]; - int a = FZ_EXPAND(rgba[3]); - while (len--) - { - int ca; - cov += *src; *src = 0; src++; - ca = FZ_COMBINE(FZ_EXPAND(cov), a); - dst[0] = FZ_BLEND(r, dst[0], ca); - dst[1] = FZ_BLEND(g, dst[1], ca); - dst[2] = FZ_BLEND(b, dst[2], ca); - dst[3] = FZ_BLEND(255, dst[3], ca); - dst += 4; - } -} - -void (*fz_path_1o1)(byte*restrict,byte,int,byte*restrict) = path_1o1; -void (*fz_path_w2i1o2)(byte*,byte*restrict,byte,int,byte*restrict) = path_w2i1o2; -void (*fz_path_w4i1o4)(byte*,byte*restrict,byte,int,byte*restrict) = path_w4i1o4; - /* Blend source alpha over destination alpha */ void @@ -288,6 +230,9 @@ fz_blendpixmapswithmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) fz_bbox bbox; int x, y, w, h, n; + assert(dst->n == src->n); + assert(msk->n == 1); + bbox = fz_boundpixmap(dst); bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); bbox = fz_intersectbbox(bbox, fz_boundpixmap(msk)); @@ -302,9 +247,6 @@ fz_blendpixmapswithmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) mp = msk->samples + ((y - msk->y) * msk->w + (x - msk->x)) * msk->n; dp = dst->samples + ((y - dst->y) * dst->w + (x - dst->x)) * dst->n; - assert(dst->n == src->n); - assert(msk->n == 1); - while (h--) { fz_blendwithmask(dp, sp, mp, n, w); @@ -321,6 +263,8 @@ fz_blendpixmapswithalpha(fz_pixmap *dst, fz_pixmap *src, float alpha) fz_bbox bbox; int x, y, w, h, n, a; + assert(dst->n == src->n); + bbox = fz_boundpixmap(dst); bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); @@ -334,8 +278,6 @@ fz_blendpixmapswithalpha(fz_pixmap *dst, fz_pixmap *src, float alpha) 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; - assert(dst->n == src->n); - while (h--) { if (a == 255) |