diff options
-rw-r--r-- | draw/porterduff.c | 84 | ||||
-rw-r--r-- | fitz/dev_draw.c | 6 | ||||
-rw-r--r-- | fitz/fitz_draw.h | 5 |
3 files changed, 9 insertions, 86 deletions
diff --git a/draw/porterduff.c b/draw/porterduff.c index 5c3339ec..9af8b55c 100644 --- a/draw/porterduff.c +++ b/draw/porterduff.c @@ -76,40 +76,14 @@ typedef unsigned char byte; * Blend pixmap regions */ -/* dst = src over dst */ -static void -duff_non(byte * restrict sp, int sw, int sn, byte * restrict dp, int dw, int w0, int h) -{ - int k; - - sw -= w0*sn; - dw -= w0*sn; - while (h--) - { - int w = w0; - while (w--) - { - int ssa = 255 - sp[sn-1]; - for (k = 0; k < sn; k++) - { - dp[k] = sp[k] + fz_mul255(dp[k], ssa); - } - sp += sn; - dp += sn; - } - sp += sw; - dp += dw; - } -} - /* dst = src in msk over dst */ static void -duff_nimon(byte * restrict sp, int sw, int sn, byte * restrict mp, int mw, int mn, byte * restrict dp, int dw, int w0, int h) +duff_ni1on(byte * restrict sp, int sw, int sn, byte * restrict mp, int mw, byte * restrict dp, int dw, int w0, int h) { int k; sw -= w0*sn; - mw -= w0*mn; + mw -= w0; dw -= w0*sn; while (h--) { @@ -117,13 +91,13 @@ duff_nimon(byte * restrict sp, int sw, int sn, byte * restrict mp, int mw, int m while (w--) { int ma = mp[0]; - int ssa = 255-fz_mul255(sp[sn-1], ma); + int ssa = 255 - fz_mul255(sp[sn-1], ma); for (k = 0; k < sn; k++) { dp[k] = fz_mul255(sp[k], ma) + fz_mul255(dp[k], ssa); } sp += sn; - mp += mn; + mp ++; dp += sn; } sp += sw; @@ -133,51 +107,6 @@ duff_nimon(byte * restrict sp, int sw, int sn, byte * restrict mp, int mw, int m } static void -duff_1o1(byte * restrict sp0, int sw, byte * restrict dp0, int dw, int w0, int h) -{ - /* duff_non(sp0, sw, 1, dp0, dw, w0, h); */ - while (h--) - { - byte *sp = sp0; - byte *dp = dp0; - int w = w0; - while (w--) - { - dp[0] = sp[0] + fz_mul255(dp[0], 255 - sp[0]); - sp ++; - dp ++; - } - sp0 += sw; - dp0 += dw; - } -} - -static void -duff_4o4(byte *sp, int sw, byte *dp, int dw, int w0, int h) -{ - /* duff_non(sp0, sw, 4, dp0, dw, w0, h); */ - - sw -= w0<<2; - dw -= w0<<2; - while (h--) - { - int w = w0; - while (w--) - { - byte ssa = 255 - sp[3]; - dp[0] = sp[0] + fz_mul255(dp[0], ssa); - dp[1] = sp[1] + fz_mul255(dp[1], ssa); - dp[2] = sp[2] + fz_mul255(dp[2], ssa); - dp[3] = sp[3] + fz_mul255(dp[3], ssa); - sp += 4; - dp += 4; - } - sp += sw; - dp += dw; - } -} - -static void duff_1i1o1(byte * restrict sp, int sw, byte * restrict mp, int mw, byte * restrict dp, int dw, int w0, int h) { /* duff_nimon(sp0, sw, 1, mp0, mw, 1, dp0, dw, w0, h); */ @@ -394,10 +323,7 @@ text_w4i1o4(byte * restrict rgba, byte * restrict src, int srcw, byte * restrict * ... and the function pointers */ -void (*fz_duff_non)(byte*,int,int,byte*,int,int,int) = duff_non; -void (*fz_duff_nimon)(byte*,int,int,byte*,int,int,byte*,int,int,int) = duff_nimon; -void (*fz_duff_1o1)(byte*,int,byte*,int,int,int) = duff_1o1; -void (*fz_duff_4o4)(byte*,int,byte*,int,int,int) = duff_4o4; +void (*fz_duff_ni1on)(byte*,int,int,byte*,int,byte*,int,int,int) = duff_ni1on; void (*fz_duff_1i1o1)(byte*,int,byte*,int,byte*,int,int,int) = duff_1i1o1; void (*fz_duff_2i1o2)(byte*,int,byte*,int,byte*,int,int,int) = duff_2i1o2; void (*fz_duff_4i1o4)(byte*,int,byte*,int,byte*,int,int,int) = duff_4i1o4; diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index 0906985f..29f092f3 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -63,9 +63,9 @@ blendmaskover(fz_pixmap *src, fz_pixmap *msk, fz_pixmap *dst) fz_duff_2i1o2(sp, src->w * 2, mp, msk->w, dp, dst->w * 2, w, h); else if (src->n == 4 && msk->n == 1 && dst->n == 4) fz_duff_4i1o4(sp, src->w * 4, mp, msk->w, dp, dst->w * 4, w, h); - else if (src->n == dst->n) - fz_duff_nimon(sp, src->w * src->n, src->n, - mp, msk->w * msk->n, msk->n, + else if (src->n == dst->n && msk->n == 1 ) + fz_duff_ni1on(sp, src->w * src->n, src->n, + mp, msk->w * msk->n, dp, dst->w * dst->n, w, h); else assert(!"blendmaskover src and msk and dst mismatch"); diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h index 00152b47..0f08249e 100644 --- a/fitz/fitz_draw.h +++ b/fitz/fitz_draw.h @@ -479,10 +479,7 @@ void fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix c extern void fz_accelerate(void); extern void fz_acceleratearch(void); -extern void (*fz_duff_non)(unsigned char*,int,int,unsigned char*,int,int,int); -extern void (*fz_duff_nimon)(unsigned char*,int,int,unsigned char*,int,int,unsigned char*,int,int,int); -extern void (*fz_duff_1o1)(unsigned char*,int,unsigned char*,int,int,int); -extern void (*fz_duff_4o4)(unsigned char*,int,unsigned char*,int,int,int); +extern void (*fz_duff_ni1on)(unsigned char*,int,int,unsigned char*,int,unsigned char*,int,int,int); extern void (*fz_duff_1i1o1)(unsigned char*,int,unsigned char*,int,unsigned char*,int,int,int); extern void (*fz_duff_2i1o2)(unsigned char*,int,unsigned char*,int,unsigned char*,int,int,int); extern void (*fz_duff_4i1o4)(unsigned char*,int,unsigned char*,int,unsigned char*,int,int,int); |