summaryrefslogtreecommitdiff
path: root/source
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
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')
-rw-r--r--source/fitz/draw-affine.c106
-rw-r--r--source/fitz/draw-blend.c24
-rw-r--r--source/fitz/draw-imp.h20
-rw-r--r--source/fitz/draw-paint.c81
-rw-r--r--source/fitz/pixmap.c4
5 files changed, 120 insertions, 115 deletions
diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c
index e4db9ec8..71a0cecd 100644
--- a/source/fitz/draw-affine.c
+++ b/source/fitz/draw-affine.c
@@ -13,7 +13,7 @@ static inline int bilerp(int a, int b, int c, int d, int u, int v)
return lerp(lerp(a, b, u), lerp(c, d, u), v);
}
-static inline byte *sample_nearest(byte *s, int w, int h, int str, int n, int u, int v)
+static inline const byte *sample_nearest(const byte *s, int w, int h, int str, int n, int u, int v)
{
if (u < 0) u = 0;
if (v < 0) v = 0;
@@ -25,7 +25,7 @@ static inline byte *sample_nearest(byte *s, int w, int h, int str, int n, int u,
/* Blend premultiplied source image in constant alpha over destination */
static inline void
-fz_paint_affine_alpha_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, int alpha, byte *hp)
+fz_paint_affine_alpha_N_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, int alpha, byte * restrict hp)
{
int k;
@@ -37,10 +37,10 @@ fz_paint_affine_alpha_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss,
int vi = v >> 16;
int uf = u & 0xffff;
int vf = v & 0xffff;
- byte *a = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi);
- byte *b = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi);
- byte *c = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi+1);
- byte *d = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi+1);
+ const byte *a = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi);
+ const byte *b = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi);
+ const byte *c = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi+1);
+ const byte *d = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi+1);
int xa = sa ? bilerp(a[n1], b[n1], c[n1], d[n1], uf, vf) : 255;
int t;
xa = fz_mul255(xa, alpha);
@@ -65,7 +65,7 @@ fz_paint_affine_alpha_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss,
/* Special case code for gray -> rgb */
static inline void
-fz_paint_affine_alpha_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int alpha, byte *hp)
+fz_paint_affine_alpha_g2rgb_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int alpha, byte * restrict hp)
{
while (w--)
{
@@ -75,10 +75,10 @@ fz_paint_affine_alpha_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
int uf = u & 0xffff;
int vf = v & 0xffff;
- byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
- byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
- byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
- byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
+ const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
+ const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
+ const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
+ const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
int y = (sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255);
int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
int t;
@@ -102,7 +102,7 @@ fz_paint_affine_alpha_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int
}
static inline void
-fz_paint_affine_alpha_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, int alpha, byte *hp)
+fz_paint_affine_alpha_N_near(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, int alpha, byte * restrict hp)
{
int k;
@@ -117,7 +117,7 @@ fz_paint_affine_alpha_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss,
int vi = v >> 16;
if (vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss);
+ const byte *sample = sp + (vi * ss);
int a = (sa ? fz_mul255(sample[n1], alpha) : 255);
int t = 255 - a;
for (k = 0; k < n1; k++)
@@ -144,7 +144,7 @@ fz_paint_affine_alpha_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss,
int ui = u >> 16;
if (ui >= 0 && ui < sw)
{
- byte *sample = sp + (ui * (n1+sa));
+ const byte *sample = sp + (ui * (n1+sa));
int a = (sa ? fz_mul255(sample[n1], alpha) : 255);
int t = 255 - a;
for (k = 0; k < n1; k++)
@@ -168,7 +168,7 @@ fz_paint_affine_alpha_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss,
int vi = v >> 16;
if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss) + (ui * (n1+sa));
+ const byte *sample = sp + (vi * ss) + (ui * (n1+sa));
int a = (sa ? fz_mul255(sample[n1], alpha) : 255);
int t = 255 - a;
for (k = 0; k < n1; k++)
@@ -188,7 +188,7 @@ fz_paint_affine_alpha_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss,
}
static inline void
-fz_paint_affine_alpha_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int alpha, byte *hp)
+fz_paint_affine_alpha_g2rgb_near(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int alpha, byte * restrict hp)
{
if (fa == 0)
{
@@ -201,7 +201,7 @@ fz_paint_affine_alpha_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
if (vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss);
+ const byte *sample = sp + (vi * ss);
int x = fz_mul255(sample[0], alpha);
int a = (sa ? fz_mul255(sample[1], alpha) : 255);
int t = 255 - a;
@@ -230,7 +230,7 @@ fz_paint_affine_alpha_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int ui = u >> 16;
if (ui >= 0 && ui < sw)
{
- byte *sample = sp + (ui * (1+sa));
+ const byte *sample = sp + (ui * (1+sa));
int x = fz_mul255(sample[0], alpha);
int a = (sa ? fz_mul255(sample[1], alpha) : 255);
int t = 255 - a;
@@ -256,7 +256,7 @@ fz_paint_affine_alpha_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss) + (ui * (1+sa));
+ const byte *sample = sp + (vi * ss) + (ui * (1+sa));
int x = fz_mul255(sample[0], alpha);
int a = (sa ? fz_mul255(sample[1], alpha): 255);
int t = 255 - a;
@@ -280,7 +280,7 @@ fz_paint_affine_alpha_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
/* Blend premultiplied source image over destination */
static inline void
-fz_paint_affine_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, byte *hp)
+fz_paint_affine_N_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, byte * restrict hp)
{
int k;
@@ -292,10 +292,10 @@ fz_paint_affine_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
int vi = v >> 16;
int uf = u & 0xffff;
int vf = v & 0xffff;
- byte *a = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi);
- byte *b = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi);
- byte *c = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi+1);
- byte *d = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi+1);
+ const byte *a = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi);
+ const byte *b = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi);
+ const byte *c = sample_nearest(sp, sw, sh, ss, n1+sa, ui, vi+1);
+ const byte *d = sample_nearest(sp, sw, sh, ss, n1+sa, ui+1, vi+1);
int y = sa ? bilerp(a[n1], b[n1], c[n1], d[n1], uf, vf) : 255;
int t = 255 - y;
for (k = 0; k < n1; k++)
@@ -317,7 +317,7 @@ fz_paint_affine_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
}
static inline void
-fz_paint_affine_solid_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, byte *hp)
+fz_paint_affine_solid_g2rgb_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, byte * restrict hp)
{
while (w--)
{
@@ -327,10 +327,10 @@ fz_paint_affine_solid_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
int uf = u & 0xffff;
int vf = v & 0xffff;
- byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
- byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
- byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
- byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
+ const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
+ const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
+ const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
+ const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
int y = (sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255);
int t = 255 - y;
int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
@@ -351,7 +351,7 @@ fz_paint_affine_solid_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int
}
static inline void
-fz_paint_affine_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, byte *hp)
+fz_paint_affine_N_near(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n1, byte * restrict hp)
{
int k;
@@ -366,7 +366,7 @@ fz_paint_affine_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
int vi = v >> 16;
if (vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss);
+ const byte *sample = sp + (vi * ss);
int a = (sa ? sample[n1] : 255);
/* If a is 0, then sample[k] = 0 for all k, as premultiplied */
if (a != 0)
@@ -416,7 +416,7 @@ fz_paint_affine_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
int ui = u >> 16;
if (ui >= 0 && ui < sw)
{
- byte *sample = sp + (ui * (n1+sa));
+ const byte *sample = sp + (ui * (n1+sa));
int a = sa ? sample[n1] : 255;
/* If a is 0, then sample[k] = 0 for all k, as premultiplied */
if (a != 0)
@@ -463,7 +463,7 @@ fz_paint_affine_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
int vi = v >> 16;
if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss) + (ui * (n1+sa));
+ const byte *sample = sp + (vi * ss) + (ui * (n1+sa));
int a = sa ? sample[n1] : 255;
/* If a is 0, then sample[k] = 0 for all k, as premultiplied */
if (a != 0)
@@ -506,7 +506,7 @@ fz_paint_affine_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int s
}
static inline void
-fz_paint_affine_solid_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, byte *hp)
+fz_paint_affine_solid_g2rgb_near(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, byte * restrict hp)
{
if (fa == 0)
{
@@ -519,7 +519,7 @@ fz_paint_affine_solid_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
if (vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss);
+ const byte *sample = sp + (vi * ss);
int a = (sa ? sample[1] : 255);
if (a != 0)
{
@@ -564,7 +564,7 @@ fz_paint_affine_solid_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int ui = u >> 16;
if (ui >= 0 && ui < sw)
{
- byte *sample = sp + (ui * (1+sa));
+ const byte *sample = sp + (ui * (1+sa));
int a = (sa ? sample[1] : 255);
if (a != 0)
{
@@ -606,7 +606,7 @@ fz_paint_affine_solid_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
int vi = v >> 16;
if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
{
- byte *sample = sp + (vi * ss) + (ui * (1+sa));
+ const byte *sample = sp + (vi * ss) + (ui * (1+sa));
int a = sa ? sample[1] : 255;
if (a != 0)
{
@@ -646,7 +646,7 @@ fz_paint_affine_solid_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int
/* Blend non-premultiplied color in source image mask over destination */
static inline void
-fz_paint_affine_color_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int u, int v, int fa, int fb, int w, int n1, byte *color, byte *hp)
+fz_paint_affine_color_N_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int u, int v, int fa, int fb, int w, int n1, const byte * restrict color, byte * restrict hp)
{
int sa = color[n1];
int k;
@@ -659,10 +659,10 @@ fz_paint_affine_color_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss,
int vi = v >> 16;
int uf = u & 0xffff;
int vf = v & 0xffff;
- byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
- byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
- byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
- byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
+ const byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
+ const byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
+ const byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
+ const byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf);
int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
for (k = 0; k < n1; k++)
@@ -681,7 +681,7 @@ fz_paint_affine_color_N_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss,
}
static inline void
-fz_paint_affine_color_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int u, int v, int fa, int fb, int w, int n1, byte *color, byte *hp)
+fz_paint_affine_color_N_near(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int u, int v, int fa, int fb, int w, int n1, const byte * restrict color, byte * restrict hp)
{
int sa = color[n1];
int k;
@@ -710,7 +710,7 @@ fz_paint_affine_color_N_near(byte *dp, int da, byte *sp, int sw, int sh, int ss,
}
static void
-fz_paint_affine_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color/*unused*/, byte *hp)
+fz_paint_affine_lerp(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, const byte * restrict color/*unused*/, byte * restrict hp)
{
if (da)
{
@@ -813,7 +813,7 @@ fz_paint_affine_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa,
}
static void
-fz_paint_affine_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color/*unused*/, byte *hp)
+fz_paint_affine_g2rgb_lerp(byte *dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, const byte * restrict color/*unused*/, byte * restrict hp)
{
if (da)
{
@@ -868,7 +868,7 @@ fz_paint_affine_g2rgb_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, i
}
static void
-fz_paint_affine_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color/*unused */, byte *hp)
+fz_paint_affine_near(byte *dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, const byte * restrict color/*unused */, byte * restrict hp)
{
if (da)
{
@@ -975,7 +975,7 @@ fz_paint_affine_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa,
}
static void
-fz_paint_affine_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color/*unused*/, byte *hp)
+fz_paint_affine_g2rgb_near(byte *dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, const byte * restrict color/*unused*/, byte * restrict hp)
{
if (da)
{
@@ -1030,7 +1030,7 @@ fz_paint_affine_g2rgb_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, i
}
static void
-fz_paint_affine_color_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha/*unused*/, byte *color, byte *hp)
+fz_paint_affine_color_lerp(byte *dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha/*unused*/, const byte * restrict color, byte * restrict hp)
{
if (da)
{
@@ -1055,7 +1055,7 @@ fz_paint_affine_color_lerp(byte *dp, int da, byte *sp, int sw, int sh, int ss, i
}
static void
-fz_paint_affine_color_near(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha/*unused*/, byte *color, byte *hp)
+fz_paint_affine_color_near(byte *dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha/*unused*/, const byte * restrict color, byte * restrict hp)
{
if (da)
{
@@ -1271,7 +1271,7 @@ fz_gridfit_matrix(int as_tiled, fz_matrix *m)
/* Draw an image with an affine transform on destination */
static void
-fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color, int alpha, int lerp_allowed, int as_tiled)
+fz_paint_image_imp(fz_pixmap * restrict dst, const fz_irect *scissor, const fz_pixmap * restrict shape, const fz_pixmap * restrict img, const fz_matrix * restrict ctm, const byte * restrict color, int alpha, int lerp_allowed, int as_tiled)
{
byte *dp, *sp, *hp;
int u, v, fa, fb, fc, fd;
@@ -1279,7 +1279,7 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz
int sw, sh, ss, sa, n, hs, da;
fz_irect bbox;
int dolerp;
- void (*paintfn)(byte *dp, int da, byte *sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color, byte *hp);
+ void (*paintfn)(byte * restrict dp, int da, const byte * restrict sp, int sw, int sh, int ss, int sa, int u, int v, int fa, int fb, int w, int n, int alpha, const byte * restrict color, byte * restrict hp);
fz_matrix local_ctm = *ctm;
fz_rect rect;
int is_rectilinear;
@@ -1416,14 +1416,14 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz
}
void
-fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, byte *color, int lerp_allowed, int as_tiled)
+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 byte * restrict color, int lerp_allowed, int as_tiled)
{
assert(img->n == 1);
fz_paint_image_imp(dst, scissor, shape, img, ctm, color, 255, lerp_allowed, as_tiled);
}
void
-fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha, int lerp_allowed, int as_tiled)
+fz_paint_image(fz_pixmap * restrict 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 as_tiled)
{
assert(dst->n - dst->alpha == img->n - img->alpha|| (dst->n == 3 + dst->alpha && img->n == 1 + img->alpha));
fz_paint_image_imp(dst, scissor, shape, img, ctm, NULL, alpha, lerp_allowed, as_tiled);
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--)
{
diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h
index 0eef8156..7b035d08 100644
--- a/source/fitz/draw-imp.h
+++ b/source/fitz/draw-imp.h
@@ -29,21 +29,21 @@ 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, unsigned char *color, int da);
+void fz_paint_solid_color(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, unsigned char * restrict sp, int sa, int n, int w, int alpha);
-void fz_paint_span_with_color(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *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);
-void fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, int alpha, int lerp_allowed, int gridfit_as_tiled);
-void fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *img, const fz_matrix *ctm, unsigned char *colorbv, int lerp_allowed, int gridfit_as_tiled);
+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);
-void fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha);
-void fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk);
-void fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_irect bbox);
+void fz_paint_pixmap(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int alpha);
+void fz_paint_pixmap_with_mask(fz_pixmap * restrict dst, const fz_pixmap * restrict src, const fz_pixmap * restrict msk);
+void fz_paint_pixmap_with_bbox(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int alpha, fz_irect bbox);
-void fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int isolated, fz_pixmap *shape);
+void fz_blend_pixmap(fz_pixmap * restrict dst, fz_pixmap * restrict src, int alpha, int blendmode, int isolated, const fz_pixmap * restrict shape);
void fz_blend_pixel(unsigned char dp[3], unsigned char bp[3], unsigned char sp[3], int blendmode);
-void fz_paint_glyph(unsigned char *colorbv, fz_pixmap *dst, unsigned char *dp, fz_glyph *glyph, int w, int h, int skip_x, int skip_y);
+void fz_paint_glyph(const unsigned char * restrict colorbv, fz_pixmap * restrict dst, unsigned char * restrict dp, const fz_glyph * restrict glyph, int w, int h, int skip_x, int skip_y);
#endif
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c
index 17f50724..568151cc 100644
--- a/source/fitz/draw-paint.c
+++ b/source/fitz/draw-paint.c
@@ -76,7 +76,7 @@ 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, byte *color)
+fz_paint_solid_color_2_da(byte * restrict dp, int w, const byte * restrict color)
{
int sa = FZ_EXPAND(color[1]);
if (sa == 0)
@@ -108,7 +108,7 @@ static inline int isbigendian(void)
}
static inline void
-fz_paint_solid_color_4_da(byte * restrict dp, int w, byte *color)
+fz_paint_solid_color_4_da(byte * restrict dp, int w, const byte * restrict color)
{
unsigned int rgba = *(int *)color;
int sa = FZ_EXPAND(color[3]);
@@ -147,7 +147,7 @@ fz_paint_solid_color_4_da(byte * restrict dp, int w, byte *color)
}
static inline void
-fz_paint_solid_color_5_da(byte * restrict dp, int w, byte *color)
+fz_paint_solid_color_5_da(byte * restrict dp, int w, const byte * restrict color)
{
int sa = FZ_EXPAND(color[4]);
if (sa == 0)
@@ -225,7 +225,7 @@ fz_paint_solid_color_5_da(byte * restrict dp, int w, byte *color)
}
static inline void
-fz_paint_solid_color_N(byte * restrict dp, int n, int w, byte *color, int da)
+fz_paint_solid_color_N(byte * restrict dp, int n, int w, const byte * restrict color, int da)
{
int k;
int n1 = n - da;
@@ -257,7 +257,7 @@ fz_paint_solid_color_N(byte * restrict dp, int n, int w, byte *color, int da)
}
void
-fz_paint_solid_color(byte * restrict dp, int n, int w, byte *color, int da)
+fz_paint_solid_color(byte * restrict dp, int n, int w, const byte * restrict color, int da)
{
if (da)
{
@@ -284,7 +284,7 @@ fz_paint_solid_color(byte * restrict dp, int n, int w, byte *color, int da)
/* Blend a non-premultiplied color in mask over destination */
static inline void
-fz_paint_span_with_color_2_da(byte * restrict dp, byte * restrict mp, int w, byte *color)
+fz_paint_span_with_color_2_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color)
{
int sa = FZ_EXPAND(color[1]);
int g = color[0];
@@ -331,9 +331,9 @@ fz_paint_span_with_color_2_da(byte * restrict dp, byte * restrict mp, int w, byt
}
static inline void
-fz_paint_span_with_color_4_da(byte * restrict dp, byte * restrict mp, int w, byte *color)
+fz_paint_span_with_color_4_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color)
{
- unsigned int rgba = *((unsigned int *)color);
+ unsigned int rgba = *((const unsigned int *)color);
unsigned int mask, rb, ga;
int sa = FZ_EXPAND(color[3]);
if (sa == 0)
@@ -395,7 +395,7 @@ fz_paint_span_with_color_4_da(byte * restrict dp, byte * restrict mp, int w, byt
}
static inline void
-fz_paint_span_with_color_5_da(byte * restrict dp, byte * restrict mp, int w, byte *color)
+fz_paint_span_with_color_5_da(byte * restrict dp, const byte * restrict mp, int w, const byte * restrict color)
{
int sa = FZ_EXPAND(color[4]);
int c = color[0];
@@ -454,7 +454,7 @@ fz_paint_span_with_color_5_da(byte * restrict dp, byte * restrict mp, int w, byt
}
static inline void
-fz_paint_span_with_color_N(byte * restrict dp, byte * restrict mp, int n, int w, byte *color, int da)
+fz_paint_span_with_color_N(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da)
{
int k;
int n1 = n - da;
@@ -503,7 +503,7 @@ fz_paint_span_with_color_N(byte * restrict dp, byte * restrict mp, int n, int w,
}
void
-fz_paint_span_with_color(byte * restrict dp, byte * restrict mp, int n, int w, byte *color, int da)
+fz_paint_span_with_color(byte * restrict dp, const byte * restrict mp, int n, int w, const byte * restrict color, int da)
{
if (da)
{
@@ -531,7 +531,7 @@ fz_paint_span_with_color(byte * restrict dp, byte * restrict mp, int n, int w, b
/* FIXME: There is potential for SWAR optimisation here */
static inline void
-fz_paint_span_with_mask_1(byte * restrict dp, int da, byte * restrict sp, int sa, byte * restrict mp, int w)
+fz_paint_span_with_mask_1(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w)
{
while (w--)
{
@@ -598,7 +598,7 @@ fz_paint_span_with_mask_1(byte * restrict dp, int da, byte * restrict sp, int sa
/* FIXME: There is potential for SWAR optimisation here */
static inline void
-fz_paint_span_with_mask_3(byte * restrict dp, int da, byte * restrict sp, int sa, byte * restrict mp, int w)
+fz_paint_span_with_mask_3(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w)
{
while (w--)
{
@@ -690,7 +690,7 @@ fz_paint_span_with_mask_3(byte * restrict dp, int da, byte * restrict sp, int sa
/* FIXME: There is potential for SWAR optimisation here */
static inline void
-fz_paint_span_with_mask_4(byte * restrict dp, int da, byte * restrict sp, int sa, byte * restrict mp, int w)
+fz_paint_span_with_mask_4(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int w)
{
while (w--)
{
@@ -779,7 +779,7 @@ fz_paint_span_with_mask_4(byte * restrict dp, int da, byte * restrict sp, int sa
}
static inline void
-fz_paint_span_with_mask_N(byte * restrict dp, int da, byte * restrict sp, int sa, byte * restrict mp, int n, int w)
+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)
{
while (w--)
{
@@ -861,7 +861,7 @@ fz_paint_span_with_mask_N(byte * restrict dp, int da, byte * restrict sp, int sa
}
static void
-fz_paint_span_with_mask(byte * restrict dp, int da, byte * restrict sp, int sa, byte * restrict mp, int n, int w)
+fz_paint_span_with_mask(byte * restrict dp, int da, const byte * restrict sp, int sa, const byte * restrict mp, int n, int w)
{
if (da)
{
@@ -914,7 +914,7 @@ fz_paint_span_with_mask(byte * restrict dp, int da, byte * restrict sp, int sa,
/* Blend source in constant alpha over destination */
static inline void
-fz_paint_span_1_with_alpha(byte * restrict dp, int da, byte * restrict sp, int sa, int w, int alpha)
+fz_paint_span_1_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha)
{
if (sa)
alpha = FZ_EXPAND(alpha);
@@ -934,7 +934,7 @@ fz_paint_span_1_with_alpha(byte * restrict dp, int da, byte * restrict sp, int s
}
static inline void
-fz_paint_span_3_with_alpha(byte * restrict dp, int da, byte * restrict sp, int sa, int w, int alpha)
+fz_paint_span_3_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha)
{
if (sa)
alpha = FZ_EXPAND(alpha);
@@ -958,7 +958,7 @@ fz_paint_span_3_with_alpha(byte * restrict dp, int da, byte * restrict sp, int s
}
static inline void
-fz_paint_span_4_with_alpha(byte * restrict dp, int da, byte * restrict sp, int sa, int w, int alpha)
+fz_paint_span_4_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int w, int alpha)
{
if (sa)
alpha = FZ_EXPAND(alpha);
@@ -984,7 +984,7 @@ fz_paint_span_4_with_alpha(byte * restrict dp, int da, byte * restrict sp, int s
}
static inline void
-fz_paint_span_N_with_alpha(byte * restrict dp, int da, byte * restrict sp, int sa, int n1, int w, int alpha)
+fz_paint_span_N_with_alpha(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w, int alpha)
{
if (sa)
alpha = FZ_EXPAND(alpha);
@@ -1010,7 +1010,7 @@ fz_paint_span_N_with_alpha(byte * restrict dp, int da, byte * restrict sp, int s
/* Blend source over destination */
static inline void
-fz_paint_span_1_dasa(byte * restrict dp, byte * restrict sp, int w)
+fz_paint_span_1_dasa(byte * restrict dp, const byte * restrict sp, int w)
{
while (w--)
{
@@ -1021,7 +1021,7 @@ fz_paint_span_1_dasa(byte * restrict dp, byte * restrict sp, int w)
}
static inline void
-fz_paint_span_1(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
+fz_paint_span_1(byte * restrict dp, int da, const byte * restrict sp, int sa, int w)
{
while (w--)
{
@@ -1058,7 +1058,7 @@ fz_paint_span_1(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
}
static inline void
-fz_paint_span_3(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
+fz_paint_span_3(byte * restrict dp, int da, const byte * restrict sp, int sa, int w)
{
while (w--)
{
@@ -1073,7 +1073,7 @@ fz_paint_span_3(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
if (t == 0)
{
if (da && sa)
- *(int *)dp = *(int *)sp;
+ *(int *)dp = *(const int *)sp;
else
{
dp[0] = sp[0];
@@ -1105,7 +1105,7 @@ fz_paint_span_3(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
}
static inline void
-fz_paint_span_4(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
+fz_paint_span_4(byte * restrict dp, int da, const byte * restrict sp, int sa, int w)
{
while (w--)
{
@@ -1150,7 +1150,7 @@ fz_paint_span_4(byte * restrict dp, int da, byte * restrict sp, int sa, int w)
}
static inline void
-fz_paint_span_N(byte * restrict dp, int da, byte * restrict sp, int sa, int n1, int w)
+fz_paint_span_N(byte * restrict dp, int da, const byte * restrict sp, int sa, int n1, int w)
{
while (w--)
{
@@ -1195,7 +1195,7 @@ fz_paint_span_N(byte * restrict dp, int da, byte * restrict sp, int sa, int n1,
}
void
-fz_paint_span(byte * restrict dp, int da, byte * restrict sp, int sa, int n, int w, int alpha)
+fz_paint_span(byte * restrict dp, int da, const byte * restrict sp, int sa, int n, int w, int alpha)
{
if (da)
{
@@ -1303,9 +1303,10 @@ fz_paint_span(byte * restrict dp, int da, byte * restrict sp, int sa, int n, int
*/
void
-fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_irect bbox)
+fz_paint_pixmap_with_bbox(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int alpha, fz_irect bbox)
{
- unsigned char *sp, *dp;
+ const unsigned char *sp;
+ unsigned char *dp;
int x, y, w, h, n, da, sa;
fz_irect bbox2;
@@ -1339,9 +1340,10 @@ fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_irect bb
}
void
-fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha)
+fz_paint_pixmap(fz_pixmap * restrict dst, const fz_pixmap * restrict src, int alpha)
{
- unsigned char *sp, *dp;
+ const unsigned char *sp;
+ unsigned char *dp;
fz_irect bbox;
fz_irect bbox2;
int x, y, w, h, n, da, sa;
@@ -1375,9 +1377,10 @@ fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha)
}
void
-fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk)
+fz_paint_pixmap_with_mask(fz_pixmap * restrict dst, const fz_pixmap * restrict src, const fz_pixmap * restrict msk)
{
- unsigned char *sp, *dp, *mp;
+ const unsigned char *sp, *mp;
+ unsigned char *dp;
fz_irect bbox, bbox2;
int x, y, w, h, n, sa, da;
@@ -1415,14 +1418,14 @@ fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk)
}
static inline void
-fz_paint_glyph_mask(int span, unsigned char *dp, int da, fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
+fz_paint_glyph_mask(int span, unsigned char *dp, int da, const fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
{
while (h--)
{
int skip_xx, ww, len, extend;
- unsigned char *runp;
+ const unsigned char *runp;
unsigned char *ddp = dp;
- int offset = ((int *)(glyph->data))[skip_y++];
+ int offset = ((const int *)(glyph->data))[skip_y++];
if (offset >= 0)
{
int eol = 0;
@@ -1604,7 +1607,7 @@ intermediate_run:
#include "paint-glyph.h"
static inline void
-fz_paint_glyph_alpha(unsigned char *colorbv, int n, int span, unsigned char *dp, int da, fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
+fz_paint_glyph_alpha(const unsigned char * restrict colorbv, int n, int span, unsigned char * restrict dp, int da, const fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
{
if (da)
{
@@ -1645,7 +1648,7 @@ fz_paint_glyph_alpha(unsigned char *colorbv, int n, int span, unsigned char *dp,
}
static inline void
-fz_paint_glyph_solid(unsigned char *colorbv, int n, int span, unsigned char *dp, int da, fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
+fz_paint_glyph_solid(const unsigned char * restrict colorbv, int n, int span, unsigned char * restrict dp, int da, const fz_glyph * restrict glyph, int w, int h, int skip_x, int skip_y)
{
if (da)
{
@@ -1686,7 +1689,7 @@ fz_paint_glyph_solid(unsigned char *colorbv, int n, int span, unsigned char *dp,
}
void
-fz_paint_glyph(unsigned char *colorbv, fz_pixmap *dst, unsigned char *dp, fz_glyph *glyph, int w, int h, int skip_x, int skip_y)
+fz_paint_glyph(const unsigned char * restrict colorbv, fz_pixmap * restrict dst, unsigned char * restrict dp, const fz_glyph * restrict glyph, int w, int h, int skip_x, int skip_y)
{
int n = dst->n - dst->alpha;
if (dst->colorspace)
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 3385021f..a8c7da4c 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -117,7 +117,7 @@ fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, con
}
fz_irect *
-fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix, fz_irect *bbox)
+fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix, fz_irect *bbox)
{
bbox->x0 = pix->x;
bbox->y0 = pix->y;
@@ -127,7 +127,7 @@ fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix, fz_irect *bbox)
}
fz_irect *
-fz_pixmap_bbox_no_ctx(fz_pixmap *pix, fz_irect *bbox)
+fz_pixmap_bbox_no_ctx(const fz_pixmap *pix, fz_irect *bbox)
{
bbox->x0 = pix->x;
bbox->y0 = pix->y;