summaryrefslogtreecommitdiff
path: root/source/fitz/draw-blend.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-27 19:14:07 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-29 10:11:36 +0100
commit28a1ee7561ae92dd38023be94076e684eb7e9e59 (patch)
tree80ffbc1c407e066cbd8bea196921339662232c6e /source/fitz/draw-blend.c
parent388e34e47dcf6132f63877d133d6d7679d1b8537 (diff)
downloadmupdf-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/draw-blend.c')
-rw-r--r--source/fitz/draw-blend.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/fitz/draw-blend.c b/source/fitz/draw-blend.c
index 33f2c0c6..942481c1 100644
--- a/source/fitz/draw-blend.c
+++ b/source/fitz/draw-blend.c
@@ -272,7 +272,7 @@ static inline void
fz_blend_separable(byte * restrict bp, int bal, const byte * restrict sp, int sal, int n1, int w, int blendmode)
{
int k;
- while (w--)
+ do
{
int sa = (sal ? sp[n1] : 255);
int ba = (bal ? bp[n1] : 255);
@@ -314,12 +314,13 @@ fz_blend_separable(byte * restrict bp, int bal, const byte * restrict sp, int sa
sp += n1 + sal;
bp += n1 + bal;
}
+ while (--w);
}
static void
fz_blend_nonseparable(byte * restrict bp, int bal, const byte * restrict sp, int sal, int w, int blendmode)
{
- while (w--)
+ do
{
unsigned char rr, rg, rb;
@@ -365,6 +366,7 @@ fz_blend_nonseparable(byte * restrict bp, int bal, const byte * restrict sp, int
sp += 3 + sal;
bp += 3 + bal;
}
+ while (--w);
}
static inline void
@@ -378,7 +380,7 @@ fz_blend_separable_nonisolated(byte * restrict bp, int bal, const byte * restric
* cancel one another out, and it's just a simple copy. */
/* FIXME: Maybe we can avoid using the shape plane entirely
* and just copy? */
- while (w--)
+ do
{
int ha = fz_mul255(*hp++, alpha); /* ha = shape_alpha */
/* If ha == 0 then leave everything unchanged */
@@ -395,9 +397,10 @@ fz_blend_separable_nonisolated(byte * restrict bp, int bal, const byte * restric
sp += n1 + sal;
bp += n1 + bal;
}
+ while (--w);
return;
}
- while (w--)
+ do
{
int ha = *hp++;
int haa = fz_mul255(ha, alpha); /* ha = shape_alpha */
@@ -496,12 +499,13 @@ fz_blend_separable_nonisolated(byte * restrict bp, int bal, const byte * restric
sp += n1 + sal;
bp += n1 + bal;
}
+ while (--w);
}
static inline void
fz_blend_nonseparable_nonisolated(byte * restrict bp, int bal, const byte * restrict sp, int sal, int w, int blendmode, const byte * restrict hp, int alpha)
{
- while (w--)
+ do
{
int ha = *hp++;
int haa = fz_mul255(ha, alpha);
@@ -576,6 +580,7 @@ fz_blend_nonseparable_nonisolated(byte * restrict bp, int bal, const byte * rest
sp += 3 + sal;
bp += 3 + bal;
}
+ while (--w);
}
void
@@ -617,6 +622,9 @@ fz_blend_pixmap(fz_pixmap * restrict dst, fz_pixmap * restrict src, int alpha, i
w = bbox.x1 - bbox.x0;
h = bbox.y1 - bbox.y0;
+ if (w == 0 || h == 0)
+ return;
+
n = src->n;
sp = src->samples + (unsigned int)((y - src->y) * src->stride + (x - src->x) * src->n);
sa = src->alpha;