diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-05-27 19:14:07 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-05-29 10:11:36 +0100 |
commit | 28a1ee7561ae92dd38023be94076e684eb7e9e59 (patch) | |
tree | 80ffbc1c407e066cbd8bea196921339662232c6e /source/fitz/image.c | |
parent | 388e34e47dcf6132f63877d133d6d7679d1b8537 (diff) | |
download | mupdf-28a1ee7561ae92dd38023be94076e684eb7e9e59.tar.xz |
Tweak plotter code slightly for speed.
Use do {} while(--w) rather than while(w--) {} as this safes a
test each time around the loop.
Diffstat (limited to 'source/fitz/image.c')
-rw-r--r-- | source/fitz/image.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/source/fitz/image.c b/source/fitz/image.c index c49580bf..e28ba649 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -99,10 +99,12 @@ fz_mask_color_key(fz_pixmap *pix, int n, const int *colorkey) int k, t; int h = pix->h; int stride = pix->stride - pix->w * pix->n; + if (pix->w == 0) + return; while (h--) { w = pix->w; - while (w--) + do { t = 1; for (k = 0; k < n; k++) @@ -113,6 +115,7 @@ fz_mask_color_key(fz_pixmap *pix, int n, const int *colorkey) p[k] = 0; p += pix->n; } + while (--w); p += stride; } } @@ -136,22 +139,26 @@ fz_unblend_masked_tile(fz_context *ctx, fz_pixmap *tile, fz_image *image) return; } - while (h--) + if (mask->w != 0) { - int w = mask->w; - while (w--) + while (h--) { - if (*s == 0) - for (k = 0; k < image->n; k++) - d[k] = image->colorkey[k]; - else - for (k = 0; k < image->n; k++) - d[k] = fz_clampi(image->colorkey[k] + (d[k] - image->colorkey[k]) * 255 / *s, 0, 255); - s++; - d += n; + int w = mask->w; + do + { + if (*s == 0) + for (k = 0; k < image->n; k++) + d[k] = image->colorkey[k]; + else + for (k = 0; k < image->n; k++) + d[k] = fz_clampi(image->colorkey[k] + (d[k] - image->colorkey[k]) * 255 / *s, 0, 255); + s++; + d += n; + } + while (--w); + s += sstride; + d += dstride; } - s += sstride; - d += dstride; } fz_drop_pixmap(ctx, mask); |