summaryrefslogtreecommitdiff
path: root/source/fitz/draw-blend.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-23 18:33:55 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-24 12:48:43 +0100
commit28827a69cff9f94df72daf29a68d3ab8b26259d1 (patch)
tree556ce54892b5b934b89de22fd8e73a0da3c129fe /source/fitz/draw-blend.c
parent3d5c48dbc90fb91d481a146a17170cd180e0db70 (diff)
downloadmupdf-28827a69cff9f94df72daf29a68d3ab8b26259d1.tar.xz
Sprinkle some consts and restricts in plotters.
Try and help C avoid pointer aliasing issues. Some of this may not help at all. None of it should hurt though.
Diffstat (limited to 'source/fitz/draw-blend.c')
-rw-r--r--source/fitz/draw-blend.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/source/fitz/draw-blend.c b/source/fitz/draw-blend.c
index 31914ae1..33f2c0c6 100644
--- a/source/fitz/draw-blend.c
+++ b/source/fitz/draw-blend.c
@@ -269,7 +269,7 @@ fz_blend_pixel(unsigned char dp[3], unsigned char bp[3], unsigned char sp[3], in
/* Blending loops */
static inline void
-fz_blend_separable(byte * restrict bp, int bal, byte * restrict sp, int sal, int n1, int w, int blendmode)
+fz_blend_separable(byte * restrict bp, int bal, const byte * restrict sp, int sal, int n1, int w, int blendmode)
{
int k;
while (w--)
@@ -317,7 +317,7 @@ fz_blend_separable(byte * restrict bp, int bal, byte * restrict sp, int sal, int
}
static void
-fz_blend_nonseparable(byte * restrict bp, int bal, byte * restrict sp, int sal, int w, int blendmode)
+fz_blend_nonseparable(byte * restrict bp, int bal, const byte * restrict sp, int sal, int w, int blendmode)
{
while (w--)
{
@@ -368,7 +368,7 @@ fz_blend_nonseparable(byte * restrict bp, int bal, byte * restrict sp, int sal,
}
static inline void
-fz_blend_separable_nonisolated(byte * restrict bp, int bal, byte * restrict sp, int sal, int n1, int w, int blendmode, byte * restrict hp, int alpha)
+fz_blend_separable_nonisolated(byte * restrict bp, int bal, const byte * restrict sp, int sal, int n1, int w, int blendmode, const byte * restrict hp, int alpha)
{
int k;
@@ -499,7 +499,7 @@ fz_blend_separable_nonisolated(byte * restrict bp, int bal, byte * restrict sp,
}
static inline void
-fz_blend_nonseparable_nonisolated(byte * restrict bp, int bal, byte * restrict sp, int sal, int w, int blendmode, byte * restrict hp, int alpha)
+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--)
{
@@ -579,9 +579,10 @@ fz_blend_nonseparable_nonisolated(byte * restrict bp, int bal, byte * restrict s
}
void
-fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int isolated, fz_pixmap *shape)
+fz_blend_pixmap(fz_pixmap * restrict dst, fz_pixmap * restrict src, int alpha, int blendmode, int isolated, const fz_pixmap * restrict shape)
{
- unsigned char *sp, *dp;
+ const unsigned char *sp;
+ unsigned char *dp;
fz_irect bbox;
fz_irect bbox2;
int x, y, w, h, n;
@@ -590,19 +591,20 @@ fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int is
/* TODO: fix this hack! */
if (isolated && alpha < 255)
{
+ unsigned char *sp2;
int nn;
h = src->h;
- sp = src->samples;
+ sp2 = src->samples;
nn = src->w * src->n;
while (h--)
{
n = nn;
while (n--)
{
- *sp = fz_mul255(*sp, alpha);
- sp++;
+ *sp2 = fz_mul255(*sp2, alpha);
+ sp2++;
}
- sp += src->stride - nn;
+ sp2 += src->stride - nn;
}
}
@@ -626,7 +628,7 @@ fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int is
if (!isolated)
{
- unsigned char *hp = shape->samples + (unsigned int)((y - shape->y) * shape->stride + (x - shape->x));
+ const unsigned char *hp = shape->samples + (unsigned int)((y - shape->y) * shape->stride + (x - shape->x));
while (h--)
{