diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-05-27 17:13:56 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-05-29 10:11:30 +0100 |
commit | 6ac9843782043fd221db156de525fc825ecdeb0c (patch) | |
tree | 0de733d065f4a5a5f0df0c80278c07a09247ca02 /source/fitz | |
parent | 37dbda6399654f4aaf6a5062e70d85b578d2d584 (diff) | |
download | mupdf-6ac9843782043fd221db156de525fc825ecdeb0c.tar.xz |
Split draw-paint.c plotters out into separate functions.
Again, mainly so profiling works nicely.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/draw-device.c | 33 | ||||
-rw-r--r-- | source/fitz/draw-edge.c | 48 | ||||
-rw-r--r-- | source/fitz/draw-imp.h | 10 | ||||
-rw-r--r-- | source/fitz/draw-paint.c | 647 |
4 files changed, 600 insertions, 138 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 88e117c7..202e24dd 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -572,14 +572,33 @@ draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_glyph *glyph, unsigned char *mp = msk->samples + skip_y * msk->stride + skip_x; int da = dst->alpha; - while (h--) + if (dst->colorspace) { - if (dst->colorspace) - fz_paint_span_with_color(dp, mp, dst->n, w, colorbv, da); - else - fz_paint_span(dp, da, mp, 1, 0, w, 255); - dp += dst->stride; - mp += msk->stride; + fz_span_color_painter_t *fn; + + fn = fz_get_span_color_painter(dst->n, da, colorbv); + if (fn == NULL) + return; + while (h--) + { + (*fn)(dp, mp, dst->n, w, colorbv, da); + dp += dst->stride; + mp += msk->stride; + } + } + else + { + fz_span_painter_t *fn; + + fn = fz_get_span_painter(da, 1, 0, 255); + if (fn == NULL) + return; + while (h--) + { + (*fn)(dp, da, mp, 1, 0, w, 255); + dp += dst->stride; + mp += msk->stride; + } } } } diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c index abf02a8c..859d1ef1 100644 --- a/source/fitz/draw-edge.c +++ b/source/fitz/draw-edge.c @@ -833,18 +833,18 @@ undelta_aa(fz_context *ctx, unsigned char * restrict out, int * restrict in, int } static inline void -blit_aa(fz_pixmap *dst, int x, int y, unsigned char *mp, int w, unsigned char *color) +blit_aa(fz_pixmap *dst, int x, int y, unsigned char *mp, int w, unsigned char *color, void *fn) { unsigned char *dp; dp = dst->samples + (unsigned int)((y - dst->y) * dst->stride + (x - dst->x) * dst->n); if (color) - fz_paint_span_with_color(dp, mp, dst->n, w, color, dst->alpha); + (*(fz_span_color_painter_t *)fn)(dp, mp, dst->n, w, color, dst->alpha); else - fz_paint_span(dp, dst->alpha, mp, 1, 0, w, 255); + (*(fz_span_painter_t *)fn)(dp, dst->alpha, mp, 1, 0, w, 255); } static void -fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *clip, fz_pixmap *dst, unsigned char *color) +fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *clip, fz_pixmap *dst, unsigned char *color, void *painter) { unsigned char *alphas; int *deltas; @@ -943,7 +943,7 @@ fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *cli if (yc != yd) { undelta_aa(ctx, alphas, deltas, skipx + clipn); - blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color); + blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color, painter); memset(deltas, 0, (skipx + clipn) * sizeof(int)); } yd = yc; @@ -966,7 +966,7 @@ fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *cli else non_zero_winding_aa(ctx, gel, deltas, xofs, rh); undelta_aa(ctx, alphas, deltas, skipx + clipn); - blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color); + blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color, painter); memset(deltas, 0, (skipx + clipn) * sizeof(int)); yd++; if (yd >= clip->y1) @@ -987,7 +987,7 @@ fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *cli { /* Do any successive whole scanlines - no need * to recalculate deltas here. */ - blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color); + blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color, painter); yd++; if (yd >= clip->y1) goto clip_ended; @@ -1016,7 +1016,7 @@ advance: if (yd < clip->y1) { undelta_aa(ctx, alphas, deltas, skipx + clipn); - blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color); + blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color, painter); } clip_ended: fz_free(ctx, deltas); @@ -1028,7 +1028,7 @@ clip_ended: */ static inline void -blit_sharp(int x0, int x1, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color) +blit_sharp(int x0, int x1, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color, fz_solid_color_painter_t *fn) { unsigned char *dp; int da = dst->alpha; @@ -1038,14 +1038,14 @@ blit_sharp(int x0, int x1, int y, const fz_irect *clip, fz_pixmap *dst, unsigned { dp = dst->samples + (unsigned int)((y - dst->y) * dst->stride + (x0 - dst->x) * dst->n); if (color) - fz_paint_solid_color(dp, dst->n, x1 - x0, color, da); + (*fn)(dp, dst->n, x1 - x0, color, da); else memset(dp, 255, x1-x0); } } static inline void -non_zero_winding_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color) +non_zero_winding_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color, fz_solid_color_painter_t *fn) { int winding = 0; int x = 0; @@ -1055,13 +1055,13 @@ non_zero_winding_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip if (!winding && (winding + gel->active[i]->ydir)) x = gel->active[i]->x; if (winding && !(winding + gel->active[i]->ydir)) - blit_sharp(x, gel->active[i]->x, y, clip, dst, color); + blit_sharp(x, gel->active[i]->x, y, clip, dst, color, fn); winding += gel->active[i]->ydir; } } static inline void -even_odd_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color) +even_odd_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pixmap *dst, unsigned char *color, fz_solid_color_painter_t *fn) { int even = 0; int x = 0; @@ -1071,7 +1071,7 @@ even_odd_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pix if (!even) x = gel->active[i]->x; else - blit_sharp(x, gel->active[i]->x, y, clip, dst, color); + blit_sharp(x, gel->active[i]->x, y, clip, dst, color, fn); even = !even; } } @@ -1079,7 +1079,7 @@ even_odd_sharp(fz_context *ctx, fz_gel *gel, int y, const fz_irect *clip, fz_pix static void fz_scan_convert_sharp(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *clip, - fz_pixmap *dst, unsigned char *color) + fz_pixmap *dst, unsigned char *color, fz_solid_color_painter_t *fn) { int e = 0; int y = gel->edges[0].y; @@ -1119,9 +1119,9 @@ fz_scan_convert_sharp(fz_context *ctx, while (h--) { if (eofill) - even_odd_sharp(ctx, gel, y, clip, dst, color); + even_odd_sharp(ctx, gel, y, clip, dst, color, fn); else - non_zero_winding_sharp(ctx, gel, y, clip, dst, color); + non_zero_winding_sharp(ctx, gel, y, clip, dst, color, fn); y++; } } @@ -1141,7 +1141,17 @@ fz_scan_convert(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *clip, return; if (fz_aa_bits > 0) - fz_scan_convert_aa(ctx, gel, eofill, &local_clip, dst, color); + { + void *fn; + if (color) + fn = (void *)fz_get_span_color_painter(dst->n, dst->alpha, color); + else + fn = (void *)fz_get_span_painter(dst->alpha, 1, 0, 255); + fz_scan_convert_aa(ctx, gel, eofill, &local_clip, dst, color, fn); + } else - fz_scan_convert_sharp(ctx, gel, eofill, &local_clip, dst, color); + { + fz_solid_color_painter_t *fn = fz_get_solid_color_painter(dst->n, color, dst->alpha); + fz_scan_convert_sharp(ctx, gel, eofill, &local_clip, dst, color, (fz_solid_color_painter_t *)fn); + } } diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h index 7b035d08..bb94be4d 100644 --- a/source/fitz/draw-imp.h +++ b/source/fitz/draw-imp.h @@ -29,10 +29,14 @@ fz_irect *fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect * Plotting functions. */ -void fz_paint_solid_color(unsigned char * restrict dp, int n, int w, const unsigned char * restrict color, int da); +typedef void (fz_solid_color_painter_t)(unsigned char * restrict dp, int n, int w, const unsigned char * restrict color, int da); -void fz_paint_span(unsigned char * restrict dp, int da, const unsigned char * restrict sp, int sa, int n, int w, int alpha); -void fz_paint_span_with_color(unsigned char * restrict dp, const unsigned char * restrict mp, int n, int w, const unsigned char * restrict color, int da); +typedef void (fz_span_painter_t)(unsigned char * restrict dp, int da, const unsigned char * restrict sp, int sa, int n, int w, int alpha); +typedef void (fz_span_color_painter_t)(unsigned char * restrict dp, const unsigned char * restrict mp, int n, int w, const unsigned char * restrict color, int da); + +fz_solid_color_painter_t *fz_get_solid_color_painter(int n, const unsigned char * restrict color, int da); +fz_span_painter_t *fz_get_span_painter(int da, int sa, int n, int alpha); +fz_span_color_painter_t *fz_get_span_color_painter(int n, int da, const unsigned char * restrict color); void fz_paint_image(fz_pixmap *dst, const fz_irect * restrict scissor, fz_pixmap * restrict shape, const fz_pixmap * restrict img, const fz_matrix * restrict ctm, int alpha, int lerp_allowed, int gridfit_as_tiled); void fz_paint_image_with_color(fz_pixmap * restrict dst, const fz_irect * restrict scissor, fz_pixmap *restrict shape, const fz_pixmap * restrict img, const fz_matrix * restrict ctm, const unsigned char * restrict colorbv, int lerp_allowed, int gridfit_as_tiled); diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c index 1652b218..5828842f 100644 --- a/source/fitz/draw-paint.c +++ b/source/fitz/draw-paint.c @@ -76,9 +76,10 @@ typedef unsigned char byte; /* These are used by the non-aa scan converter */ static inline void -fz_paint_solid_color_2_da(byte * restrict dp, int w, const byte * restrict color) +fz_paint_solid_color_2_da(byte * restrict dp, int n, int w, const byte * restrict color, int da) { int sa = FZ_EXPAND(color[1]); + TRACK_FN(); if (sa == 0) return; if (sa == 256) @@ -108,10 +109,11 @@ static inline int isbigendian(void) } static inline void -fz_paint_solid_color_4_da(byte * restrict dp, int w, const byte * restrict color) +fz_paint_solid_color_4_da(byte * restrict dp, int n, int w, const byte * restrict color, int da) { unsigned int rgba = *(int *)color; int sa = FZ_EXPAND(color[3]); + TRACK_FN(); if (sa == 0) return; if (isbigendian()) @@ -147,9 +149,10 @@ fz_paint_solid_color_4_da(byte * restrict dp, int w, const byte * restrict color } static inline void -fz_paint_solid_color_5_da(byte * restrict dp, int w, const byte * restrict color) +fz_paint_solid_color_5_da(byte * restrict dp, int n, int w, const byte * restrict color, int da) { int sa = FZ_EXPAND(color[4]); + TRACK_FN(); if (sa == 0) return; if (sa == 256) @@ -225,11 +228,12 @@ fz_paint_solid_color_5_da(byte * restrict dp, int w, const byte * restrict color } static inline void -fz_paint_solid_color_N(byte * restrict dp, int n, int w, const byte * restrict color, int da) +fz_paint_solid_color_N_general(byte * restrict dp, int n, int w, const byte * restrict color, int da) { int k; int n1 = n - da; int sa = FZ_EXPAND(color[n1]); + TRACK_FN(); if (sa == 0) return; if (sa == 256) @@ -256,38 +260,70 @@ fz_paint_solid_color_N(byte * restrict dp, int n, int w, const byte * restrict c } } -void -fz_paint_solid_color(byte * restrict dp, int n, int w, const byte * restrict color, int da) +static void fz_paint_solid_color_N_da(byte * restrict dp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_solid_color_N_general(dp, 1, w, color, 1); +} + +static void fz_paint_solid_color_1(byte * restrict dp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_solid_color_N_general(dp, 1, w, color, 0); +} + +static void fz_paint_solid_color_3(byte * restrict dp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_solid_color_N_general(dp, 3, w, color, 0); +} + +static void fz_paint_solid_color_4(byte * restrict dp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_solid_color_N_general(dp, 4, w, color, 0); +} + +static void fz_paint_solid_color_N(byte * restrict dp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_solid_color_N_general(dp, n, w, color, 0); +} + +fz_solid_color_painter_t * +fz_get_solid_color_painter(int n, const byte * restrict color, int da) { if (da) { switch (n) { - case 2: TRACK_LABEL("p1cd2"); fz_paint_solid_color_2_da(dp, w, color); break; - case 4: TRACK_LABEL("p1cd4"); fz_paint_solid_color_4_da(dp, w, color); break; - case 5: TRACK_LABEL("p1cd5"); fz_paint_solid_color_5_da(dp, w, color); break; - default: TRACK_LABEL("p1cdn"); fz_paint_solid_color_N(dp, n, w, color, 1); break; + case 2: return fz_paint_solid_color_2_da; + case 4: return fz_paint_solid_color_4_da; + case 5: return fz_paint_solid_color_5_da; + default: return fz_paint_solid_color_N_da; } } else { switch (n) { - case 1: TRACK_LABEL("p1c1"); fz_paint_solid_color_N(dp, 1, w, color, 0); break; - case 3: TRACK_LABEL("p1c3"); fz_paint_solid_color_N(dp, 3, w, color, 0); break; - case 4: TRACK_LABEL("p1c4"); fz_paint_solid_color_N(dp, 4, w, color, 0); break; - default: TRACK_LABEL("p1cn"); fz_paint_solid_color_N(dp, n, w, color, 0); break; + case 1: return fz_paint_solid_color_1; + case 3: return fz_paint_solid_color_3; + case 4: return fz_paint_solid_color_4; + default: return fz_paint_solid_color_N; } } + return NULL; } /* Blend a non-premultiplied color in mask over destination */ -static inline void -fz_paint_span_with_color_2_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color) +static void +fz_paint_span_with_color_2_da(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) { int sa = FZ_EXPAND(color[1]); int g = color[0]; + TRACK_FN(); if (sa == 256) { while (w--) @@ -330,12 +366,13 @@ fz_paint_span_with_color_2_da(byte * restrict dp, const byte * restrict mp, int } } -static inline void -fz_paint_span_with_color_4_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color) +static void +fz_paint_span_with_color_4_da(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) { unsigned int rgba = *((const unsigned int *)color); unsigned int mask, rb, ga; int sa = FZ_EXPAND(color[3]); + TRACK_FN(); if (sa == 0) return; if (isbigendian()) @@ -394,14 +431,15 @@ fz_paint_span_with_color_4_da(byte * restrict dp, const byte * restrict mp, int } } -static inline void -fz_paint_span_with_color_5_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color) +static void +fz_paint_span_with_color_5_da(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) { int sa = FZ_EXPAND(color[4]); int c = color[0]; int m = color[1]; int y = color[2]; int k = color[3]; + TRACK_FN(); if (sa == 256) { while (w--) @@ -454,7 +492,7 @@ fz_paint_span_with_color_5_da(byte * restrict dp, const byte * restrict mp, int } static inline void -fz_paint_span_with_color_N(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +fz_paint_span_with_color_N_general(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) { int k; int n1 = n - da; @@ -502,36 +540,72 @@ fz_paint_span_with_color_N(byte * restrict dp, const byte * restrict mp, int n, } } -void -fz_paint_span_with_color(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +static void +fz_paint_span_with_color_N_da(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_span_with_color_N_general(dp, mp, n, w, color, 1); +} + +static void +fz_paint_span_with_color_1(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_span_with_color_N_general(dp, mp, 1, w, color, 0); +} + +static void +fz_paint_span_with_color_3(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_span_with_color_N_general(dp, mp, 3, w, color, 0); +} + +static void +fz_paint_span_with_color_4(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_span_with_color_N_general(dp, mp, 4, w, color, 0); +} + +static void +fz_paint_span_with_color_N(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da) +{ + TRACK_FN(); + fz_paint_span_with_color_N_general(dp, mp, n, w, color, 0); +} + +fz_span_color_painter_t * +fz_get_span_color_painter(int n, int da, const byte * restrict color) { if (da) { switch (n) { - case 2: TRACK_LABEL("pscd2"); fz_paint_span_with_color_2_da(dp, mp, w, color); break; - case 4: TRACK_LABEL("pscd4"); fz_paint_span_with_color_4_da(dp, mp, w, color); break; - case 5: TRACK_LABEL("pscd5"); fz_paint_span_with_color_5_da(dp, mp, w, color); break; - default: TRACK_LABEL("pscdn"); fz_paint_span_with_color_N(dp, mp, n, w, color, 1); break; + case 2: return fz_paint_span_with_color_2_da; + case 4: return fz_paint_span_with_color_4_da; + case 5: return fz_paint_span_with_color_5_da; + default: return fz_paint_span_with_color_N_da; } } else { switch (n) { - case 1: TRACK_LABEL("pscd1"); fz_paint_span_with_color_N(dp, mp, 1, w, color, 0); break; - case 3: TRACK_LABEL("pscd3"); fz_paint_span_with_color_N(dp, mp, 3, w, color, 0); break; - case 4: TRACK_LABEL("pscd4"); fz_paint_span_with_color_N(dp, mp, 4, w, color, 0); break; - default: TRACK_LABEL("pscdn"); fz_paint_span_with_color_N(dp, mp, n, w, color, 0); break; + case 1: return fz_paint_span_with_color_1; + case 3: return fz_paint_span_with_color_3; + case 4: return fz_paint_span_with_color_4; + default: return fz_paint_span_with_color_N; } } + return NULL; } /* Blend source in mask over destination */ /* FIXME: There is potential for SWAR optimisation here */ static inline void -fz_paint_span_with_mask_1(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) +fz_paint_span_with_mask_1_general(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) { while (w--) { @@ -598,7 +672,7 @@ fz_paint_span_with_mask_1(byte * restrict dp, int da, const byte * restrict sp, /* FIXME: There is potential for SWAR optimisation here */ static inline void -fz_paint_span_with_mask_3(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) +fz_paint_span_with_mask_3_general(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) { while (w--) { @@ -690,7 +764,7 @@ fz_paint_span_with_mask_3(byte * restrict dp, int da, const byte * restrict sp, /* FIXME: There is potential for SWAR optimisation here */ static inline void -fz_paint_span_with_mask_4(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) +fz_paint_span_with_mask_4_general(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w) { while (w--) { @@ -779,7 +853,7 @@ fz_paint_span_with_mask_4(byte * restrict dp, int da, const byte * restrict sp, } static inline void -fz_paint_span_with_mask_N(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +fz_paint_span_with_mask_N_general(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) { while (w--) { @@ -861,7 +935,121 @@ fz_paint_span_with_mask_N(byte * restrict dp, int da, const byte * restrict sp, } static void -fz_paint_span_with_mask(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +fz_paint_span_with_mask_1_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_1_general(dp, 1, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_3_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_3_general(dp, 1, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_4_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_4_general(dp, 1, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_N_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_N_general(dp, 1, sp, 1, mp, n, w); +} + +static void +fz_paint_span_with_mask_1_da(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_1_general(dp, 1, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_3_da(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_3_general(dp, 1, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_4_da(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_4_general(dp, 1, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_N_da(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_N_general(dp, 1, sp, 0, mp, n, w); +} + +static void +fz_paint_span_with_mask_1_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_1_general(dp, 0, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_3_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_3_general(dp, 0, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_4_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_4_general(dp, 0, sp, 1, mp, w); +} + +static void +fz_paint_span_with_mask_N_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_N_general(dp, 0, sp, 1, mp, n, w); +} + +static void +fz_paint_span_with_mask_1(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_1_general(dp, 0, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_3(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_3_general(dp, 0, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_4(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_4_general(dp, 0, sp, 0, mp, w); +} + +static void +fz_paint_span_with_mask_N(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w) +{ + TRACK_FN(); + fz_paint_span_with_mask_N_general(dp, 0, sp, 0, mp, n, w); +} + +typedef void (fz_span_mask_painter_t)(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w); + +static fz_span_mask_painter_t * +fz_get_span_mask_painter(int da, int sa, int n) { if (da) { @@ -869,20 +1057,20 @@ fz_paint_span_with_mask(byte * restrict dp, int da, const byte * restrict sp, in { switch (n) { - case 1: TRACK_LABEL("pmds1"); fz_paint_span_with_mask_1(dp, 1, sp, 1, mp, w); break; - case 3: TRACK_LABEL("pmds3"); fz_paint_span_with_mask_3(dp, 1, sp, 1, mp, w); break; - case 4: TRACK_LABEL("pmds4"); fz_paint_span_with_mask_4(dp, 1, sp, 1, mp, w); break; - default: TRACK_LABEL("pmdsn"); fz_paint_span_with_mask_N(dp, 1, sp, 1, mp, n, w); break; + case 1: return fz_paint_span_with_mask_1_da_sa; + case 3: return fz_paint_span_with_mask_3_da_sa; + case 4: return fz_paint_span_with_mask_4_da_sa; + default: return fz_paint_span_with_mask_N_da_sa; } } else { switch (n) { - case 1: TRACK_LABEL("pmd1"); fz_paint_span_with_mask_1(dp, 1, sp, 0, mp, w); break; - case 3: TRACK_LABEL("pmd3"); fz_paint_span_with_mask_3(dp, 1, sp, 0, mp, w); break; - case 4: TRACK_LABEL("pmd4"); fz_paint_span_with_mask_4(dp, 1, sp, 0, mp, w); break; - default: TRACK_LABEL("pmdn"); fz_paint_span_with_mask_N(dp, 1, sp, 0, mp, n, w); break; + case 1: return fz_paint_span_with_mask_1_da; + case 3: return fz_paint_span_with_mask_3_da; + case 4: return fz_paint_span_with_mask_4_da; + default: return fz_paint_span_with_mask_N_da; } } } @@ -892,29 +1080,30 @@ fz_paint_span_with_mask(byte * restrict dp, int da, const byte * restrict sp, in { switch (n) { - case 1: TRACK_LABEL("pms1"); fz_paint_span_with_mask_1(dp, 0, sp, 1, mp, w); break; - case 3: TRACK_LABEL("pms3"); fz_paint_span_with_mask_3(dp, 0, sp, 1, mp, w); break; - case 4: TRACK_LABEL("pms4"); fz_paint_span_with_mask_4(dp, 0, sp, 1, mp, w); break; - default: TRACK_LABEL("pmsn"); fz_paint_span_with_mask_N(dp, 0, sp, 1, mp, n, w); break; + case 1: return fz_paint_span_with_mask_1_sa; + case 3: return fz_paint_span_with_mask_3_sa; + case 4: return fz_paint_span_with_mask_4_sa; + default: return fz_paint_span_with_mask_N_sa; } } else { switch (n) { - case 1: TRACK_LABEL("pm1"); fz_paint_span_with_mask_1(dp, 0, sp, 0, mp, w); break; - case 3: TRACK_LABEL("pm3"); fz_paint_span_with_mask_3(dp, 0, sp, 0, mp, w); break; - case 4: TRACK_LABEL("pm4"); fz_paint_span_with_mask_4(dp, 0, sp, 0, mp, w); break; - default: TRACK_LABEL("pmn"); fz_paint_span_with_mask_N(dp, 0, sp, 0, mp, n, w); break; + case 1: return fz_paint_span_with_mask_1; + case 3: return fz_paint_span_with_mask_3; + case 4: return fz_paint_span_with_mask_4; + default: return fz_paint_span_with_mask_N; } } } + return NULL; } /* Blend source in constant alpha over destination */ static inline void -fz_paint_span_1_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) +fz_paint_span_1_with_alpha_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) { if (sa) alpha = FZ_EXPAND(alpha); @@ -934,7 +1123,7 @@ fz_paint_span_1_with_alpha(byte * restrict dp, int da, const byte * restrict sp, } static inline void -fz_paint_span_3_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) +fz_paint_span_3_with_alpha_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) { if (sa) alpha = FZ_EXPAND(alpha); @@ -958,7 +1147,7 @@ fz_paint_span_3_with_alpha(byte * restrict dp, int da, const byte * restrict sp, } static inline void -fz_paint_span_4_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) +fz_paint_span_4_with_alpha_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha) { if (sa) alpha = FZ_EXPAND(alpha); @@ -984,7 +1173,7 @@ fz_paint_span_4_with_alpha(byte * restrict dp, int da, const byte * restrict sp, } static inline void -fz_paint_span_N_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w, int alpha) +fz_paint_span_N_with_alpha_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w, int alpha) { if (sa) alpha = FZ_EXPAND(alpha); @@ -1010,18 +1199,7 @@ fz_paint_span_N_with_alpha(byte * restrict dp, int da, const byte * restrict sp, /* Blend source over destination */ static inline void -fz_paint_span_1_dasa(byte * restrict dp, const byte * restrict sp, int w) -{ - while (w--) - { - int t = FZ_EXPAND(255 - sp[0]); - *dp = *sp++ + FZ_COMBINE(*dp, t); - dp ++; - } -} - -static inline void -fz_paint_span_1(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) +fz_paint_span_1_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) { while (w--) { @@ -1058,7 +1236,7 @@ fz_paint_span_1(byte * restrict dp, int da, const byte * restrict sp, int sa, in } static inline void -fz_paint_span_3(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) +fz_paint_span_3_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) { while (w--) { @@ -1105,7 +1283,7 @@ fz_paint_span_3(byte * restrict dp, int da, const byte * restrict sp, int sa, in } static inline void -fz_paint_span_4(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) +fz_paint_span_4_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int w) { while (w--) { @@ -1150,7 +1328,7 @@ fz_paint_span_4(byte * restrict dp, int da, const byte * restrict sp, int sa, in } static inline void -fz_paint_span_N(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w) +fz_paint_span_N_general(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w) { while (w--) { @@ -1194,8 +1372,243 @@ fz_paint_span_N(byte * restrict dp, int da, const byte * restrict sp, int sa, in } } -void -fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +static void +fz_paint_span_0_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + while (w--) + { + int t = FZ_EXPAND(255 - sp[0]); + *dp = *sp++ + FZ_COMBINE(*dp, t); + dp ++; + } +} + +static void +fz_paint_span_1_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_general(dp, 1, sp, 1, w); +} + +static void +fz_paint_span_3_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_general(dp, 1, sp, 1, w); +} + +static void +fz_paint_span_4_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_general(dp, 1, sp, 1, w); +} + +static void +fz_paint_span_N_da_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_general(dp, 1, sp, 1, n, w); +} + +static void +fz_paint_span_1_da_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_with_alpha_general(dp, 1, sp, 1, w, alpha); +} + +static void +fz_paint_span_3_da_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_with_alpha_general(dp, 1, sp, 1, w, alpha); +} + +static void +fz_paint_span_4_da_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_with_alpha_general(dp, 1, sp, 1, w, alpha); +} + +static void +fz_paint_span_N_da_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_with_alpha_general(dp, 1, sp, 1, n, w, alpha); +} + +static void +fz_paint_span_1_da(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_general(dp, 1, sp, 0, w); +} + +static void +fz_paint_span_3_da(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_general(dp, 1, sp, 0, w); +} + +static void +fz_paint_span_4_da(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_general(dp, 1, sp, 0, w); +} + +static void +fz_paint_span_N_da(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_general(dp, 1, sp, 0, n, w); +} + +static void +fz_paint_span_1_da_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_with_alpha_general(dp, 1, sp, 0, w, alpha); +} + +static void +fz_paint_span_3_da_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_with_alpha_general(dp, 1, sp, 0, w, alpha); +} + +static void +fz_paint_span_4_da_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_with_alpha_general(dp, 1, sp, 0, w, alpha); +} + +static void +fz_paint_span_N_da_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_with_alpha_general(dp, 1, sp, 0, n, w, alpha); +} + +static void +fz_paint_span_1_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_general(dp, 0, sp, 1, w); +} + +static void +fz_paint_span_3_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_general(dp, 0, sp, 1, w); +} + +static void +fz_paint_span_4_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_general(dp, 0, sp, 1, w); +} + +static void +fz_paint_span_N_sa(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_general(dp, 0, sp, 1, n, w); +} + +static void +fz_paint_span_1_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_with_alpha_general(dp, 0, sp, 1, w, alpha); +} + +static void +fz_paint_span_3_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_with_alpha_general(dp, 0, sp, 1, w, alpha); +} + +static void +fz_paint_span_4_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_with_alpha_general(dp, 0, sp, 1, w, alpha); +} + +static void +fz_paint_span_N_sa_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_with_alpha_general(dp, 0, sp, 1, n, w, alpha); +} + +static void +fz_paint_span_1(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_general(dp, 0, sp, 0, w); +} + +static void +fz_paint_span_3(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_general(dp, 0, sp, 0, w); +} + +static void +fz_paint_span_4(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_general(dp, 0, sp, 0, w); +} + +static void +fz_paint_span_N(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_general(dp, 0, sp, 0, n, w); +} + +static void +fz_paint_span_1_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_1_with_alpha_general(dp, 0, sp, 0, w, alpha); +} + +static void +fz_paint_span_3_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_3_with_alpha_general(dp, 0, sp, 0, w, alpha); +} + +static void +fz_paint_span_4_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_4_with_alpha_general(dp, 0, sp, 0, w, alpha); +} + +static void +fz_paint_span_N_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha) +{ + TRACK_FN(); + fz_paint_span_N_with_alpha_general(dp, 0, sp, 0, n, w, alpha); +} + +fz_span_painter_t * +fz_get_span_painter(int da, int sa, int n, int alpha) { if (da) { @@ -1205,21 +1618,21 @@ fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int { switch (n) { - case 0: TRACK_LABEL("psds0"); fz_paint_span_1_dasa(dp, sp, w); break; - case 1: TRACK_LABEL("psds1"); fz_paint_span_1(dp, 1, sp, 1, w); break; - case 3: TRACK_LABEL("psds3"); fz_paint_span_3(dp, 1, sp, 1, w); break; - case 4: TRACK_LABEL("psds4"); fz_paint_span_4(dp, 1, sp, 1, w); break; - default: TRACK_LABEL("psdsn"); fz_paint_span_N(dp, 1, sp, 1, n, w); break; + case 0: return fz_paint_span_0_da_sa; + case 1: return fz_paint_span_1_da_sa; + case 3: return fz_paint_span_3_da_sa; + case 4: return fz_paint_span_4_da_sa; + default: return fz_paint_span_N_da_sa; } } else if (alpha > 0) { switch (n) { - case 1: TRACK_LABEL("psdsa2"); fz_paint_span_1_with_alpha(dp, 1, sp, 1, w, alpha); break; - case 3: TRACK_LABEL("psdsa3"); fz_paint_span_3_with_alpha(dp, 1, sp, 1, w, alpha); break; - case 4: TRACK_LABEL("psdsa4"); fz_paint_span_4_with_alpha(dp, 1, sp, 1, w, alpha); break; - default: TRACK_LABEL("psdsan"); fz_paint_span_N_with_alpha(dp, 1, sp, 1, n, w, alpha); break; + case 1: return fz_paint_span_1_da_sa_alpha; + case 3: return fz_paint_span_3_da_sa_alpha; + case 4: return fz_paint_span_4_da_sa_alpha; + default: return fz_paint_span_N_da_sa_alpha; } } } @@ -1229,20 +1642,20 @@ fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int { switch (n) { - case 1: TRACK_LABEL("psd1"); fz_paint_span_1(dp, 1, sp, 0, w); break; - case 3: TRACK_LABEL("psd3"); fz_paint_span_3(dp, 1, sp, 0, w); break; - case 4: TRACK_LABEL("psd4"); fz_paint_span_4(dp, 1, sp, 0, w); break; - default: TRACK_LABEL("psdn"); fz_paint_span_N(dp, 1, sp, 0, n, w); break; + case 1: return fz_paint_span_1_da; + case 3: return fz_paint_span_3_da; + case 4: return fz_paint_span_4_da; + default: return fz_paint_span_N_da; } } else if (alpha > 0) { switch (n) { - case 1: TRACK_LABEL("psda1"); fz_paint_span_1_with_alpha(dp, 1, sp, 0, w, alpha); break; - case 3: TRACK_LABEL("psda3"); fz_paint_span_3_with_alpha(dp, 1, sp, 0, w, alpha); break; - case 4: TRACK_LABEL("psda4"); fz_paint_span_4_with_alpha(dp, 1, sp, 0, w, alpha); break; - default: TRACK_LABEL("psdan"); fz_paint_span_N_with_alpha(dp, 1, sp, 0, n, w, alpha); break; + case 1: return fz_paint_span_1_da_alpha; + case 3: return fz_paint_span_3_da_alpha; + case 4: return fz_paint_span_4_da_alpha; + default: return fz_paint_span_N_da_alpha; } } } @@ -1255,20 +1668,20 @@ fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int { switch (n) { - case 1: TRACK_LABEL("pss1"); fz_paint_span_1(dp, 0, sp, 1, w); break; - case 3: TRACK_LABEL("pss3"); fz_paint_span_3(dp, 0, sp, 1, w); break; - case 4: TRACK_LABEL("pss4"); fz_paint_span_4(dp, 0, sp, 1, w); break; - default: TRACK_LABEL("pssn"); fz_paint_span_N(dp, 0, sp, 1, n, w); break; + case 1: return fz_paint_span_1_sa; + case 3: return fz_paint_span_3_sa; + case 4: return fz_paint_span_4_sa; + default: return fz_paint_span_N_sa; } } else if (alpha > 0) { switch (n) { - case 1: TRACK_LABEL("pssa1"); fz_paint_span_1_with_alpha(dp, 0, sp, 1, w, alpha); break; - case 3: TRACK_LABEL("pssa3"); fz_paint_span_3_with_alpha(dp, 0, sp, 1, w, alpha); break; - case 4: TRACK_LABEL("pssa4"); fz_paint_span_4_with_alpha(dp, 0, sp, 1, w, alpha); break; - default: TRACK_LABEL("pssan"); fz_paint_span_N_with_alpha(dp, 0, sp, 1, n, w, alpha); break; + case 1: return fz_paint_span_1_sa_alpha; + case 3: return fz_paint_span_3_sa_alpha; + case 4: return fz_paint_span_4_sa_alpha; + default: return fz_paint_span_N_sa_alpha; } } } @@ -1278,24 +1691,25 @@ fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int { switch (n) { - case 1: TRACK_LABEL("ps1"); fz_paint_span_1(dp, 0, sp, 0, w); break; - case 3: TRACK_LABEL("ps3"); fz_paint_span_3(dp, 0, sp, 0, w); break; - case 4: TRACK_LABEL("ps4"); fz_paint_span_4(dp, 0, sp, 0, w); break; - default: TRACK_LABEL("psn"); fz_paint_span_N(dp, 0, sp, 0, n, w); break; + case 1: return fz_paint_span_1; + case 3: return fz_paint_span_3; + case 4: return fz_paint_span_4; + default: return fz_paint_span_N; } } else if (alpha > 0) { switch (n) { - case 1: TRACK_LABEL("psa1"); fz_paint_span_1_with_alpha(dp, 0, sp, 0, w, alpha); break; - case 3: TRACK_LABEL("psa3"); fz_paint_span_3_with_alpha(dp, 0, sp, 0, w, alpha); break; - case 4: TRACK_LABEL("psa4"); fz_paint_span_4_with_alpha(dp, 0, sp, 0, w, alpha); break; - default: TRACK_LABEL("psan"); fz_paint_span_N_with_alpha(dp, 0 ,sp, 0, n, w, alpha); break; + case 1: return fz_paint_span_1_alpha; + case 3: return fz_paint_span_3_alpha; + case 4: return fz_paint_span_4_alpha; + default: return fz_paint_span_N_alpha; } } } } + return NULL; } /* @@ -1309,6 +1723,7 @@ fz_paint_pixmap_with_bbox(fz_pixmap * restrict dst, const fz_pixmap * restrict s unsigned char *dp; int x, y, w, h, n, da, sa; fz_irect bbox2; + fz_span_painter_t *fn; assert(dst->n - dst->alpha == src->n - src->alpha); @@ -1331,9 +1746,13 @@ fz_paint_pixmap_with_bbox(fz_pixmap * restrict dst, const fz_pixmap * restrict s da = dst->alpha; n -= sa; + fn = fz_get_span_painter(da, sa, n, alpha); + if (fn == NULL) + return; + while (h--) { - fz_paint_span(dp, da, sp, sa, n, w, alpha); + (*fn)(dp, da, sp, sa, n, w, alpha); sp += src->stride; dp += dst->stride; } @@ -1347,6 +1766,7 @@ fz_paint_pixmap(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int al fz_irect bbox; fz_irect bbox2; int x, y, w, h, n, da, sa; + fz_span_painter_t *fn; assert(dst->n - dst->alpha == src->n - src->alpha); @@ -1368,9 +1788,13 @@ fz_paint_pixmap(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int al da = dst->alpha; n -= sa; + fn = fz_get_span_painter(da, sa, n, alpha); + if (fn == NULL) + return; + while (h--) { - fz_paint_span(dp, da, sp, sa, n, w, alpha); + (*fn)(dp, da, sp, sa, n, w, alpha); sp += src->stride; dp += dst->stride; } @@ -1383,6 +1807,7 @@ fz_paint_pixmap_with_mask(fz_pixmap * restrict dst, const fz_pixmap * restrict s unsigned char *dp; fz_irect bbox, bbox2; int x, y, w, h, n, sa, da; + fz_span_mask_painter_t *fn; assert(dst->n == src->n); assert(msk->n == 1); @@ -1408,9 +1833,13 @@ fz_paint_pixmap_with_mask(fz_pixmap * restrict dst, const fz_pixmap * restrict s da = dst->alpha; n -= sa; + fn = fz_get_span_mask_painter(da, sa, n); + if (fn == NULL) + return; + while (h--) { - fz_paint_span_with_mask(dp, da, sp, sa, mp, n, w); + (*fn)(dp, da, sp, sa, mp, n, w); sp += src->stride; dp += dst->stride; mp += msk->stride; |