summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-01-12 17:30:59 +0000
committerRobin Watts <robin.watts@artifex.com>2016-01-13 12:32:58 +0000
commitad8936bf2bcf54c7042bdec20c49c96657649b34 (patch)
tree0d6e309f5747e493632b72b34acef1e53e1ed9d7 /source/fitz
parent881b7ea89588677e709aaa7d3d0ffe4aed63822a (diff)
downloadmupdf-ad8936bf2bcf54c7042bdec20c49c96657649b34.tar.xz
Add lots of consts.
In general, we should use 'const fz_blah' in device calls whenever the callee should not alter the fz_blah. Push this through. This shows up various places where we fz_keep and fz_drop these const things. I've updated the fz_keep and fz_drops with appropriate casts to remove the consts. We may need to do the union dance to avoid the consts for some compilers, but will only do that if required. I think this is nicer overall, even allowing for the const<->no const problems.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/bbox-device.c36
-rw-r--r--source/fitz/colorspace.c36
-rw-r--r--source/fitz/device.c38
-rw-r--r--source/fitz/draw-device.c44
-rw-r--r--source/fitz/draw-glyph.c10
-rw-r--r--source/fitz/draw-imp.h8
-rw-r--r--source/fitz/draw-mesh.c6
-rw-r--r--source/fitz/draw-path.c6
-rw-r--r--source/fitz/draw-scale-simple.c2
-rw-r--r--source/fitz/draw-unpack.c4
-rw-r--r--source/fitz/font.c62
-rw-r--r--source/fitz/image.c16
-rw-r--r--source/fitz/list-device.c48
-rw-r--r--source/fitz/path.c10
-rw-r--r--source/fitz/pixmap.c2
-rw-r--r--source/fitz/shade.c54
-rw-r--r--source/fitz/stext-device.c22
-rw-r--r--source/fitz/store.c12
-rw-r--r--source/fitz/svg-device.c59
-rw-r--r--source/fitz/test-device.c30
-rw-r--r--source/fitz/text.c12
-rw-r--r--source/fitz/trace-device.c44
22 files changed, 298 insertions, 263 deletions
diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c
index fcab733f..cc3afcd4 100644
--- a/source/fitz/bbox-device.c
+++ b/source/fitz/bbox-device.c
@@ -34,89 +34,89 @@ fz_bbox_add_rect(fz_context *ctx, fz_device *dev, const fz_rect *rect, int clip)
}
static void
-fz_bbox_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_bbox_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 0);
}
static void
-fz_bbox_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
+fz_bbox_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 0);
}
static void
-fz_bbox_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_bbox_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 0);
}
static void
-fz_bbox_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
+fz_bbox_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 0);
}
static void
-fz_bbox_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_bbox_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_shade(ctx, shade, ctm, &r), 0);
}
static void
-fz_bbox_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_bbox_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_rect r = fz_unit_rect;
fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
}
static void
-fz_bbox_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_bbox_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect r = fz_unit_rect;
fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
}
static void
-fz_bbox_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+fz_bbox_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 1);
}
static void
-fz_bbox_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_bbox_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 1);
}
static void
-fz_bbox_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_bbox_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 1);
}
static void
-fz_bbox_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_bbox_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_rect r;
fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 1);
}
static void
-fz_bbox_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+fz_bbox_clip_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
fz_rect r = fz_unit_rect;
fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 1);
@@ -133,7 +133,7 @@ fz_bbox_pop_clip(fz_context *ctx, fz_device *dev)
}
static void
-fz_bbox_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, float *color)
+fz_bbox_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, const fz_colorspace *colorspace, const float *color)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
fz_bbox_add_rect(ctx, dev, rect, 1);
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 5549496e..e579784c 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -28,27 +28,31 @@ fz_new_colorspace(fz_context *ctx, char *name, int n)
}
fz_colorspace *
-fz_keep_colorspace(fz_context *ctx, fz_colorspace *cs)
+fz_keep_colorspace(fz_context *ctx, const fz_colorspace *csc)
{
+ fz_colorspace *cs = (fz_colorspace *)csc; /* Explicit cast away of const */
+
return (fz_colorspace *)fz_keep_storable(ctx, &cs->storable);
}
void
-fz_drop_colorspace(fz_context *ctx, fz_colorspace *cs)
+fz_drop_colorspace(fz_context *ctx, const fz_colorspace *csc)
{
+ fz_colorspace *cs = (fz_colorspace *)csc; /* Explicit cast away of const */
+
fz_drop_storable(ctx, &cs->storable);
}
/* Device colorspace definitions */
-static void gray_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *gray, float *rgb)
+static void gray_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *gray, float *rgb)
{
rgb[0] = gray[0];
rgb[1] = gray[0];
rgb[2] = gray[0];
}
-static void rgb_to_gray(fz_context *ctx, fz_colorspace *cs, const float *rgb, float *gray)
+static void rgb_to_gray(fz_context *ctx, const fz_colorspace *cs, const float *rgb, float *gray)
{
float r = rgb[0];
float g = rgb[1];
@@ -56,28 +60,28 @@ static void rgb_to_gray(fz_context *ctx, fz_colorspace *cs, const float *rgb, fl
gray[0] = r * 0.3f + g * 0.59f + b * 0.11f;
}
-static void rgb_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *rgb, float *xyz)
+static void rgb_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *rgb, float *xyz)
{
xyz[0] = rgb[0];
xyz[1] = rgb[1];
xyz[2] = rgb[2];
}
-static void bgr_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *bgr, float *rgb)
+static void bgr_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *bgr, float *rgb)
{
rgb[0] = bgr[2];
rgb[1] = bgr[1];
rgb[2] = bgr[0];
}
-static void rgb_to_bgr(fz_context *ctx, fz_colorspace *cs, const float *rgb, float *bgr)
+static void rgb_to_bgr(fz_context *ctx, const fz_colorspace *cs, const float *rgb, float *bgr)
{
bgr[0] = rgb[2];
bgr[1] = rgb[1];
bgr[2] = rgb[0];
}
-static void cmyk_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *cmyk, float *rgb)
+static void cmyk_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *cmyk, float *rgb)
{
#ifdef SLOWCMYK /* from poppler */
float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
@@ -156,7 +160,7 @@ static void cmyk_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *cmyk, f
#endif
}
-static void rgb_to_cmyk(fz_context *ctx, fz_colorspace *cs, const float *rgb, float *cmyk)
+static void rgb_to_cmyk(fz_context *ctx, const fz_colorspace *cs, const float *rgb, float *cmyk)
{
float c, m, y, k;
c = 1 - rgb[0];
@@ -1005,8 +1009,8 @@ std_conv_color(fz_context *ctx, fz_color_converter *cc, float *dstv, const float
{
float rgb[3];
int i;
- fz_colorspace *srcs = cc->ss;
- fz_colorspace *dsts = cc->ds;
+ const fz_colorspace *srcs = cc->ss;
+ const fz_colorspace *dsts = cc->ds;
if (srcs != dsts)
{
@@ -1123,7 +1127,7 @@ cmyk2bgr(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv)
#endif
}
-void fz_lookup_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss)
+void fz_lookup_color_converter(fz_context *ctx, fz_color_converter *cc, const fz_colorspace *ds, const fz_colorspace *ss)
{
cc->ds = ds;
cc->ss = ss;
@@ -1178,7 +1182,7 @@ void fz_lookup_color_converter(fz_context *ctx, fz_color_converter *cc, fz_color
}
void
-fz_convert_color(fz_context *ctx, fz_colorspace *ds, float *dv, fz_colorspace *ss, const float *sv)
+fz_convert_color(fz_context *ctx, const fz_colorspace *ds, float *dv, const fz_colorspace *ss, const float *sv)
{
fz_color_converter cc;
fz_lookup_color_converter(ctx, &cc, ds, ss);
@@ -1195,7 +1199,7 @@ struct indexed
};
static void
-indexed_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *color, float *rgb)
+indexed_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *color, float *rgb)
{
struct indexed *idx = cs->data;
float alt[FZ_MAX_COLORS];
@@ -1208,7 +1212,7 @@ indexed_to_rgb(fz_context *ctx, fz_colorspace *cs, const float *color, float *rg
}
static void
-free_indexed(fz_context *ctx, fz_colorspace *cs)
+free_indexed(fz_context *ctx, const fz_colorspace *cs)
{
struct indexed *idx = cs->data;
if (idx->base)
@@ -1318,7 +1322,7 @@ static void fz_cached_color_convert(fz_context *ctx, fz_color_converter *cc_, fl
}
}
-void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss)
+void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, const fz_colorspace *ds, const fz_colorspace *ss)
{
int n = ss->n;
fz_cached_color_converter *cached = fz_malloc_struct(ctx, fz_cached_color_converter);
diff --git a/source/fitz/device.c b/source/fitz/device.c
index cd3435c9..f95ae32a 100644
--- a/source/fitz/device.c
+++ b/source/fitz/device.c
@@ -74,8 +74,8 @@ pop_clip_stack(fz_context *ctx, fz_device *dev)
}
void
-fz_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (dev->error_depth)
return;
@@ -84,8 +84,8 @@ fz_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const
}
void
-fz_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (dev->error_depth)
return;
@@ -94,7 +94,7 @@ fz_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *
}
void
-fz_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+fz_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
if (dev->error_depth)
{
@@ -127,7 +127,7 @@ fz_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect
}
void
-fz_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
if (dev->error_depth)
{
@@ -160,8 +160,8 @@ fz_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rec
}
void
-fz_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (dev->error_depth)
return;
@@ -170,8 +170,8 @@ fz_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ct
}
void
-fz_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (dev->error_depth)
return;
@@ -180,7 +180,7 @@ fz_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *
}
void
-fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
if (dev->error_depth)
{
@@ -208,7 +208,7 @@ fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ct
}
void
-fz_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
if (dev->error_depth)
{
@@ -236,7 +236,7 @@ fz_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
void
-fz_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
if (dev->error_depth)
return;
@@ -261,7 +261,7 @@ fz_pop_clip(fz_context *ctx, fz_device *dev)
}
void
-fz_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
if (dev->error_depth)
return;
@@ -270,7 +270,7 @@ fz_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix
}
void
-fz_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
if (dev->error_depth)
return;
@@ -279,8 +279,8 @@ fz_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix
}
void
-fz_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (dev->error_depth)
return;
@@ -289,7 +289,7 @@ fz_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
}
void
-fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+fz_clip_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
if (dev->error_depth)
{
@@ -313,7 +313,7 @@ fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_re
}
void
-fz_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *area, int luminosity, fz_colorspace *colorspace, float *bc)
+fz_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *area, int luminosity, const fz_colorspace *colorspace, const float *bc)
{
if (dev->error_depth)
{
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 38fe1c19..e2d3f736 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -265,8 +265,8 @@ static void fz_knockout_end(fz_context *ctx, fz_draw_device *dev)
}
static void
-fz_draw_fill_path(fz_context *ctx, fz_device *devp, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_draw_fill_path(fz_context *ctx, fz_device *devp, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_gel *gel = dev->gel;
@@ -319,8 +319,8 @@ fz_draw_fill_path(fz_context *ctx, fz_device *devp, fz_path *path, int even_odd,
}
static void
-fz_draw_stroke_path(fz_context *ctx, fz_device *devp, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_gel *gel = dev->gel;
@@ -382,7 +382,7 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, fz_path *path, fz_stroke_s
}
static void
-fz_draw_clip_path(fz_context *ctx, fz_device *devp, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_gel *gel = dev->gel;
@@ -448,7 +448,7 @@ fz_draw_clip_path(fz_context *ctx, fz_device *devp, fz_path *path, const fz_rect
}
static void
-fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_gel *gel = dev->gel;
@@ -558,8 +558,8 @@ draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_glyph *glyph,
}
static void
-fz_draw_fill_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_draw_state *state = &dev->stack[dev->top];
@@ -639,9 +639,9 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matr
}
static void
-fz_draw_stroke_text(fz_context *ctx, fz_device *devp, fz_text *text, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace,
- float *color, float alpha)
+fz_draw_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace,
+ const float *color, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_draw_state *state = &dev->stack[dev->top];
@@ -708,7 +708,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, fz_text *text, fz_stroke_s
}
static void
-fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matrix *ctm)
+fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_irect bbox;
@@ -821,7 +821,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, fz_text *text, const fz_matr
}
static void
-fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_irect bbox;
@@ -928,12 +928,12 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, fz_text *text, fz_str
}
static void
-fz_draw_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_draw_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
}
static void
-fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_draw_fill_shade(fz_context *ctx, fz_device *devp, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_rect bounds;
@@ -1026,7 +1026,7 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
}
static fz_pixmap *
-fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit, const fz_irect *clip)
+fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, const fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit, const fz_irect *clip)
{
fz_pixmap *scaled;
@@ -1083,7 +1083,7 @@ fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, fz_pixmap *image, fz_m
}
static void
-fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_draw_fill_image(fz_context *ctx, fz_device *devp, const fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_pixmap *converted = NULL;
@@ -1189,8 +1189,8 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
}
static void
-fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_draw_device *dev = (fz_draw_device*)devp;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -1261,7 +1261,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
}
static void
-fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_irect bbox;
@@ -1419,7 +1419,7 @@ fz_draw_pop_clip(fz_context *ctx, fz_device *devp)
}
static void
-fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, float *colorfv)
+fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int luminosity, const fz_colorspace *colorspace, const float *colorfv)
{
fz_draw_device *dev = (fz_draw_device*)devp;
fz_pixmap *dest;
@@ -2130,7 +2130,7 @@ fz_new_draw_device_type3(fz_context *ctx, fz_pixmap *dest)
}
fz_irect *
-fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect *scissor, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
+fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect *scissor, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
{
fz_gel *gel = fz_new_gel(ctx);
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c
index e7f8af30..34489924 100644
--- a/source/fitz/draw-glyph.c
+++ b/source/fitz/draw-glyph.c
@@ -11,7 +11,7 @@ typedef struct fz_glyph_key_s fz_glyph_key;
struct fz_glyph_key_s
{
- fz_font *font;
+ const fz_font *font;
int a, b;
int c, d;
unsigned short gid;
@@ -173,7 +173,7 @@ fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsig
}
fz_glyph *
-fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, fz_stroke_state *stroke, const fz_irect *scissor)
+fz_render_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor)
{
if (font->ft_face)
{
@@ -189,7 +189,7 @@ fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm,
}
fz_pixmap *
-fz_render_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, fz_stroke_state *stroke, const fz_irect *scissor)
+fz_render_stroked_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor)
{
if (font->ft_face)
{
@@ -241,7 +241,7 @@ move_to_front(fz_glyph_cache *cache, fz_glyph_cache_entry *entry)
}
fz_glyph *
-fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor)
+fz_render_glyph(fz_context *ctx, const fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor)
{
fz_glyph_cache *cache;
fz_glyph_key key;
@@ -407,7 +407,7 @@ unlock_and_return_val:
}
fz_pixmap *
-fz_render_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor)
+fz_render_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor)
{
fz_pixmap *val;
unsigned char qe, qf;
diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h
index 8a750860..18580585 100644
--- a/source/fitz/draw-imp.h
+++ b/source/fitz/draw-imp.h
@@ -19,11 +19,11 @@ fz_rect *fz_gel_scissor(fz_context *ctx, const fz_gel *gel, fz_rect *rect);
void fz_scan_convert(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *clip, fz_pixmap *pix, unsigned char *colorbv);
-void fz_flatten_fill_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_matrix *ctm, float flatness);
-void fz_flatten_stroke_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
-void fz_flatten_dash_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
+void fz_flatten_fill_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_matrix *ctm, float flatness);
+void fz_flatten_stroke_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
+void fz_flatten_dash_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
-fz_irect *fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect *scissor, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
+fz_irect *fz_bound_path_accurate(fz_context *ctx, fz_irect *bbox, const fz_irect *scissor, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth);
/*
* Plotting functions.
diff --git a/source/fitz/draw-mesh.c b/source/fitz/draw-mesh.c
index 03cffd06..3b031a55 100644
--- a/source/fitz/draw-mesh.c
+++ b/source/fitz/draw-mesh.c
@@ -157,7 +157,7 @@ fz_paint_triangle(fz_pixmap *pix, float *v[3], int n, const fz_irect *bbox)
struct paint_tri_data
{
- fz_shade *shade;
+ const fz_shade *shade;
fz_pixmap *dest;
const fz_irect *bbox;
fz_color_converter cc;
@@ -167,7 +167,7 @@ static void
prepare_vertex(fz_context *ctx, void *arg, fz_vertex *v, const float *input)
{
struct paint_tri_data *ptd = (struct paint_tri_data *)arg;
- fz_shade *shade = ptd->shade;
+ const fz_shade *shade = ptd->shade;
fz_pixmap *dest = ptd->dest;
float *output = v->c;
int i;
@@ -198,7 +198,7 @@ do_paint_tri(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex
}
void
-fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_irect *bbox)
+fz_paint_shade(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_irect *bbox)
{
unsigned char clut[256][FZ_MAX_COLORS];
fz_pixmap *temp = NULL;
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c
index 0d37c0da..2ba00604 100644
--- a/source/fitz/draw-path.c
+++ b/source/fitz/draw-path.c
@@ -215,7 +215,7 @@ static const fz_path_processor flatten_proc =
};
void
-fz_flatten_fill_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_matrix *ctm, float flatness)
+fz_flatten_fill_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_matrix *ctm, float flatness)
{
flatten_arg arg;
@@ -842,7 +842,7 @@ static const fz_path_processor stroke_proc =
};
void
-fz_flatten_stroke_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
+fz_flatten_stroke_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
{
struct sctx s;
@@ -1301,7 +1301,7 @@ static const fz_path_processor dash_proc =
};
void
-fz_flatten_dash_path(fz_context *ctx, fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
+fz_flatten_dash_path(fz_context *ctx, fz_gel *gel, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth)
{
struct sctx s;
float max_expand;
diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c
index 397ba732..a5cb43dd 100644
--- a/source/fitz/draw-scale-simple.c
+++ b/source/fitz/draw-scale-simple.c
@@ -1179,7 +1179,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
}
fz_pixmap *
-fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y)
+fz_scale_pixmap_cached(fz_context *ctx, const fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y)
{
fz_scale_filter *filter = &fz_scale_filter_simple;
fz_weights *contrib_rows = NULL;
diff --git a/source/fitz/draw-unpack.c b/source/fitz/draw-unpack.c
index 806fe448..d21e7303 100644
--- a/source/fitz/draw-unpack.c
+++ b/source/fitz/draw-unpack.c
@@ -172,7 +172,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
/* Apply decode array */
void
-fz_decode_indexed_tile(fz_context *ctx, fz_pixmap *pix, float *decode, int maxval)
+fz_decode_indexed_tile(fz_context *ctx, fz_pixmap *pix, const float *decode, int maxval)
{
int add[FZ_MAX_COLORS];
int mul[FZ_MAX_COLORS];
@@ -207,7 +207,7 @@ fz_decode_indexed_tile(fz_context *ctx, fz_pixmap *pix, float *decode, int maxva
}
void
-fz_decode_tile(fz_context *ctx, fz_pixmap *pix, float *decode)
+fz_decode_tile(fz_context *ctx, fz_pixmap *pix, const float *decode)
{
int add[FZ_MAX_COLORS];
int mul[FZ_MAX_COLORS];
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 600253eb..003cca0b 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -73,8 +73,10 @@ fz_new_font(fz_context *ctx, const char *name, int use_glyph_bbox, int glyph_cou
}
fz_font *
-fz_keep_font(fz_context *ctx, fz_font *font)
+fz_keep_font(fz_context *ctx, const fz_font *fontc)
{
+ fz_font *font = (fz_font *)fontc; /* Explicit cast away of const */
+
return fz_keep_imp(ctx, font, &font->refs);
}
@@ -112,10 +114,12 @@ void fz_decouple_type3_font(fz_context *ctx, fz_font *font, void *t3doc)
}
void
-fz_drop_font(fz_context *ctx, fz_font *font)
+fz_drop_font(fz_context *ctx, const fz_font *fontc)
{
int fterr;
int i;
+ /* Explicitly drop const */
+ fz_font *font = (fz_font *)fontc;
if (!fz_drop_imp(ctx, font, &font->refs))
return;
@@ -412,7 +416,7 @@ fz_new_font_from_buffer(fz_context *ctx, const char *name, fz_buffer *buffer, in
}
static fz_matrix *
-fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm)
+fz_adjust_ft_glyph_width(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm)
{
/* Fudge the font matrix to stretch the glyph if we've substituted the font. */
if (font->ft_stretch && font->width_table /* && font->wmode == 0 */)
@@ -459,7 +463,7 @@ pixmap_from_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap)
/* Takes the freetype lock, and returns with it held */
static FT_GlyphSlot
-do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa)
+do_ft_render_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa)
{
FT_Face face = font->ft_face;
FT_Matrix m;
@@ -558,7 +562,7 @@ retry_unhinted:
}
fz_pixmap *
-fz_render_ft_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa)
+fz_render_ft_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa)
{
FT_GlyphSlot slot = do_ft_render_glyph(ctx, font, gid, trm, aa);
fz_pixmap *pixmap;
@@ -587,7 +591,7 @@ fz_render_ft_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr
/* The glyph cache lock is always taken when this is called. */
fz_glyph *
-fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa)
+fz_render_ft_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa)
{
FT_GlyphSlot slot = do_ft_render_glyph(ctx, font, gid, trm, aa);
fz_glyph *glyph;
@@ -616,7 +620,7 @@ fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
/* Takes the freetype lock, and returns with it held */
static FT_Glyph
-do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, fz_stroke_state *state)
+do_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state)
{
FT_Face face = font->ft_face;
float expansion = fz_matrix_expansion(ctm);
@@ -712,7 +716,7 @@ do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_mat
}
fz_pixmap *
-fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, fz_stroke_state *state)
+fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state)
{
FT_Glyph glyph = do_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, state);
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
@@ -742,7 +746,7 @@ fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const
}
fz_glyph *
-fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, fz_stroke_state *state)
+fz_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state)
{
FT_Glyph glyph = do_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, state);
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
@@ -772,7 +776,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_mat
}
static fz_rect *
-fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_rect *bounds)
+fz_bound_ft_glyph(fz_context *ctx, const fz_font *font, int gid, fz_rect *bounds)
{
FT_Face face = font->ft_face;
FT_Error fterr;
@@ -917,7 +921,7 @@ static const FT_Outline_Funcs outline_funcs = {
};
fz_path *
-fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm)
+fz_outline_ft_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm)
{
struct closure cc;
FT_Face face = font->ft_face;
@@ -1023,7 +1027,7 @@ fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix)
}
void
-fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
+fz_prepare_t3_glyph(fz_context *ctx, const fz_font *font, int gid, int nested_depth)
{
fz_buffer *contents;
fz_device *dev;
@@ -1059,7 +1063,7 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
}
static fz_rect *
-fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_rect *bounds)
+fz_bound_t3_glyph(fz_context *ctx, const fz_font *font, int gid, fz_rect *bounds)
{
fz_display_list *list;
fz_device *dev;
@@ -1097,7 +1101,7 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_rect *bounds)
}
void
-fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_device *dev)
+fz_run_t3_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_device *dev)
{
fz_display_list *list;
fz_matrix ctm;
@@ -1111,7 +1115,7 @@ fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, f
}
fz_pixmap *
-fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor)
+fz_render_t3_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor)
{
fz_display_list *list;
fz_rect bounds;
@@ -1187,14 +1191,14 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr
}
fz_glyph *
-fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor)
+fz_render_t3_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor)
{
fz_pixmap *pixmap = fz_render_t3_glyph_pixmap(ctx, font, gid, trm, model, scissor);
return fz_new_glyph_from_pixmap(ctx, pixmap);
}
void
-fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nested_depth)
+fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, const fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nested_depth)
{
fz_matrix ctm;
void *contents;
@@ -1224,7 +1228,7 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi
}
void
-fz_print_font(fz_context *ctx, fz_output *out, fz_font *font)
+fz_print_font(fz_context *ctx, fz_output *out, const fz_font *font)
{
fz_printf(ctx, out, "font '%s' {\n", font->name);
@@ -1250,7 +1254,7 @@ fz_print_font(fz_context *ctx, fz_output *out, fz_font *font)
}
fz_rect *
-fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect)
+fz_bound_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect)
{
if (font->bbox_table && gid < font->glyph_count)
{
@@ -1275,14 +1279,14 @@ fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz
}
fz_path *
-fz_outline_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *ctm)
+fz_outline_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *ctm)
{
if (!font->ft_face)
return NULL;
return fz_outline_ft_glyph(ctx, font, gid, ctm);
}
-int fz_glyph_cacheable(fz_context *ctx, fz_font *font, int gid)
+int fz_glyph_cacheable(fz_context *ctx, const fz_font *font, int gid)
{
if (!font->t3procs || !font->t3flags || gid < 0 || gid >= font->glyph_count)
return 1;
@@ -1290,7 +1294,7 @@ int fz_glyph_cacheable(fz_context *ctx, fz_font *font, int gid)
}
static float
-fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid)
+fz_advance_ft_glyph(fz_context *ctx, const fz_font *font, int gid)
{
FT_Fixed adv;
int mask;
@@ -1313,7 +1317,7 @@ fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid)
}
static float
-fz_advance_t3_glyph(fz_context *ctx, fz_font *font, int gid)
+fz_advance_t3_glyph(fz_context *ctx, const fz_font *font, int gid)
{
if (gid < 0 || gid > 255)
return 0;
@@ -1321,8 +1325,12 @@ fz_advance_t3_glyph(fz_context *ctx, fz_font *font, int gid)
}
float
-fz_advance_glyph(fz_context *ctx, fz_font *font, int gid)
+fz_advance_glyph(fz_context *ctx, const fz_font *fontc, int gid)
{
+ /* Explicitly cast away the const, enable us to change a cache
+ * held within the font. */
+ fz_font *font = (fz_font *)fontc;
+
if (font->ft_face)
{
if (gid >= 0 && gid < font->glyph_count && gid < MAX_ADVANCE_CACHE)
@@ -1345,8 +1353,12 @@ fz_advance_glyph(fz_context *ctx, fz_font *font, int gid)
}
int
-fz_encode_character(fz_context *ctx, fz_font *font, int ucs)
+fz_encode_character(fz_context *ctx, const fz_font *fontc, int ucs)
{
+ /* Explicitly cast away the const, enable us to change a cache
+ * held within the font. */
+ fz_font *font = (fz_font *)fontc;
+
if (font->ft_face)
{
if (ucs >= 0 && ucs < 0x10000)
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 34f0dd6a..297e6263 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -3,13 +3,13 @@
#define SANE_DPI 72.0f
fz_image *
-fz_keep_image(fz_context *ctx, fz_image *image)
+fz_keep_image(fz_context *ctx, const fz_image *image)
{
return (fz_image *)fz_keep_storable(ctx, &image->storable);
}
void
-fz_drop_image(fz_context *ctx, fz_image *image)
+fz_drop_image(fz_context *ctx, const fz_image *image)
{
fz_drop_storable(ctx, &image->storable);
}
@@ -18,7 +18,7 @@ typedef struct fz_image_key_s fz_image_key;
struct fz_image_key_s {
int refs;
- fz_image *image;
+ const fz_image *image;
int l2factor;
};
@@ -74,7 +74,7 @@ static fz_store_type fz_image_store_type =
};
static void
-fz_mask_color_key(fz_pixmap *pix, int n, int *colorkey)
+fz_mask_color_key(fz_pixmap *pix, int n, const int *colorkey)
{
unsigned char *p = pix->samples;
int len = pix->w * pix->h;
@@ -93,7 +93,7 @@ fz_mask_color_key(fz_pixmap *pix, int n, int *colorkey)
}
static void
-fz_unblend_masked_tile(fz_context *ctx, fz_pixmap *tile, fz_image *image)
+fz_unblend_masked_tile(fz_context *ctx, fz_pixmap *tile, const fz_image *image)
{
fz_pixmap *mask = fz_get_pixmap_from_image(ctx, image->mask, tile->w, tile->h);
unsigned char *s = mask->samples, *end = s + mask->w * mask->h;
@@ -121,7 +121,7 @@ fz_unblend_masked_tile(fz_context *ctx, fz_pixmap *tile, fz_image *image)
}
fz_pixmap *
-fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, int indexed, int l2factor)
+fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, const fz_image *image, int indexed, int l2factor)
{
fz_pixmap *tile = NULL;
int stride, len, i;
@@ -218,7 +218,7 @@ fz_drop_image_imp(fz_context *ctx, fz_storable *image_)
}
static fz_pixmap *
-standard_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h, int *l2factor)
+standard_image_get_pixmap(fz_context *ctx, const fz_image *image, int w, int h, int *l2factor)
{
int native_l2factor;
fz_stream *stm;
@@ -285,7 +285,7 @@ standard_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h, int *l
}
fz_pixmap *
-fz_get_pixmap_from_image(fz_context *ctx, fz_image *image, int w, int h)
+fz_get_pixmap_from_image(fz_context *ctx, const fz_image *image, int w, int h)
{
fz_pixmap *tile;
int l2factor, l2factor_remaining;
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c
index 14e2278c..d5a869c7 100644
--- a/source/fitz/list-device.c
+++ b/source/fitz/list-device.c
@@ -154,12 +154,12 @@ fz_append_display_node(
fz_display_command cmd,
int flags,
const fz_rect *rect,
- fz_path *path,
- float *color,
- fz_colorspace *colorspace,
- float *alpha,
+ const fz_path *path,
+ const float *color,
+ const fz_colorspace *colorspace,
+ const float *alpha,
const fz_matrix *ctm,
- fz_stroke_state *stroke,
+ const fz_stroke_state *stroke,
void *private_data,
int private_data_len)
{
@@ -678,8 +678,8 @@ fz_list_end_page(fz_context *ctx, fz_device *dev)
}
static void
-fz_list_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_list_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect rect;
@@ -701,8 +701,8 @@ fz_list_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd,
}
static void
-fz_list_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
+fz_list_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect rect;
@@ -724,7 +724,7 @@ fz_list_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_st
}
static void
-fz_list_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+fz_list_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
fz_rect rect2;
@@ -748,7 +748,7 @@ fz_list_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect
}
static void
-fz_list_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_list_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_rect rect2;
@@ -772,8 +772,8 @@ fz_list_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const f
}
static void
-fz_list_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_list_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
@@ -804,8 +804,8 @@ fz_list_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matri
}
static void
-fz_list_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_list_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
@@ -836,7 +836,7 @@ fz_list_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
static void
-fz_list_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_list_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
@@ -867,7 +867,7 @@ fz_list_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matri
}
static void
-fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
@@ -898,7 +898,7 @@ fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stro
}
static void
-fz_list_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_list_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
@@ -948,7 +948,7 @@ fz_list_pop_clip(fz_context *ctx, fz_device *dev)
}
static void
-fz_list_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_list_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
fz_shade *shade2 = fz_keep_shade(ctx, shade);
fz_rect rect;
@@ -979,7 +979,7 @@ fz_list_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
}
static void
-fz_list_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_list_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_image *image2 = fz_keep_image(ctx, image);
fz_rect rect = fz_unit_rect;
@@ -1010,8 +1010,8 @@ fz_list_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
}
static void
-fz_list_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_list_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_image *image2 = fz_keep_image(ctx, image);
fz_rect rect = fz_unit_rect;
@@ -1042,7 +1042,7 @@ fz_list_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
}
static void
-fz_list_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+fz_list_clip_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
fz_image *image2 = fz_keep_image(ctx, image);
fz_rect rect2 = fz_unit_rect;
@@ -1075,7 +1075,7 @@ fz_list_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
}
static void
-fz_list_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, float *color)
+fz_list_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, const fz_colorspace *colorspace, const float *color)
{
fz_append_display_node(
ctx,
diff --git a/source/fitz/path.c b/source/fitz/path.c
index fbc5ef47..d5b662d2 100644
--- a/source/fitz/path.c
+++ b/source/fitz/path.c
@@ -907,7 +907,7 @@ static const fz_path_processor bound_path_proc =
};
fz_rect *
-fz_bound_path(fz_context *ctx, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r)
+fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r)
{
bound_path_arg arg;
@@ -1422,8 +1422,10 @@ const fz_stroke_state fz_default_stroke_state = {
};
fz_stroke_state *
-fz_keep_stroke_state(fz_context *ctx, fz_stroke_state *stroke)
+fz_keep_stroke_state(fz_context *ctx, const fz_stroke_state *strokec)
{
+ fz_stroke_state *stroke = (fz_stroke_state *)strokec; /* Explicit cast away of const */
+
if (!stroke)
return NULL;
@@ -1435,8 +1437,10 @@ fz_keep_stroke_state(fz_context *ctx, fz_stroke_state *stroke)
}
void
-fz_drop_stroke_state(fz_context *ctx, fz_stroke_state *stroke)
+fz_drop_stroke_state(fz_context *ctx, const fz_stroke_state *strokec)
{
+ fz_stroke_state *stroke = (fz_stroke_state *)strokec; /* Explicit cast away of const */
+
if (fz_drop_imp(ctx, stroke, &stroke->refs))
fz_free(ctx, stroke);
}
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index faabea2c..d2086d6f 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -981,7 +981,7 @@ png_from_pixmap(fz_context *ctx, fz_pixmap *pix, int drop)
}
fz_buffer *
-fz_new_buffer_from_image_as_png(fz_context *ctx, fz_image *image, int w, int h)
+fz_new_buffer_from_image_as_png(fz_context *ctx, const fz_image *image, int w, int h)
{
return png_from_pixmap(ctx, fz_get_pixmap_from_image(ctx, image, image->w, image->h), 1);
}
diff --git a/source/fitz/shade.c b/source/fitz/shade.c
index d543b020..2a036770 100644
--- a/source/fitz/shade.c
+++ b/source/fitz/shade.c
@@ -3,7 +3,7 @@
typedef struct fz_mesh_processor_s fz_mesh_processor;
struct fz_mesh_processor_s {
- fz_shade *shade;
+ const fz_shade *shade;
fz_mesh_prepare_fn *prepare;
fz_mesh_process_fn *process;
void *process_arg;
@@ -70,7 +70,7 @@ fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, con
}
static void
-fz_process_mesh_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type1(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
float *p = shade->u.f.fn_vals;
int xdivs = shade->u.f.xdivs;
@@ -127,7 +127,7 @@ fz_point_on_circle(fz_point p, float r, float theta)
}
static void
-fz_process_mesh_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type2(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_point p0, p1, dir;
fz_vertex v0, v1, v2, v3;
@@ -240,7 +240,7 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
}
static void
-fz_process_mesh_type3(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type3(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_point p0, p1;
float r0, r1;
@@ -302,7 +302,7 @@ static inline float read_sample(fz_context *ctx, fz_stream *stream, int bits, fl
}
static void
-fz_process_mesh_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type4(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex v[4];
@@ -318,8 +318,8 @@ fz_process_mesh_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
float x1 = shade->u.m.x1;
float y0 = shade->u.m.y0;
float y1 = shade->u.m.y1;
- float *c0 = shade->u.m.c0;
- float *c1 = shade->u.m.c1;
+ const float *c0 = shade->u.m.c0;
+ const float *c1 = shade->u.m.c1;
float x, y, c[FZ_MAX_COLORS];
fz_try(ctx)
@@ -381,7 +381,7 @@ fz_process_mesh_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
}
static void
-fz_process_mesh_type5(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type5(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex *buf = NULL;
@@ -396,8 +396,8 @@ fz_process_mesh_type5(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
float x1 = shade->u.m.x1;
float y0 = shade->u.m.y0;
float y1 = shade->u.m.y1;
- float *c0 = shade->u.m.c0;
- float *c1 = shade->u.m.c1;
+ const float *c0 = shade->u.m.c0;
+ const float *c1 = shade->u.m.c1;
float x, y, c[FZ_MAX_COLORS];
fz_var(buf);
@@ -696,7 +696,7 @@ make_tensor_patch(tensor_patch *p, int type, fz_point *pt)
#define SUBDIV 3 /* how many levels to subdivide patches */
static void
-fz_process_mesh_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type6(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
float color_storage[2][4][FZ_MAX_COLORS];
@@ -711,8 +711,8 @@ fz_process_mesh_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
float x1 = shade->u.m.x1;
float y0 = shade->u.m.y0;
float y1 = shade->u.m.y1;
- float *c0 = shade->u.m.c0;
- float *c1 = shade->u.m.c1;
+ const float *c0 = shade->u.m.c0;
+ const float *c1 = shade->u.m.c1;
fz_try(ctx)
{
@@ -809,7 +809,7 @@ fz_process_mesh_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
}
static void
-fz_process_mesh_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_mesh_type7(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
int bpflag = shade->u.m.bpflag;
@@ -819,8 +819,8 @@ fz_process_mesh_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
float x1 = shade->u.m.x1;
float y0 = shade->u.m.y0;
float y1 = shade->u.m.y1;
- float *c0 = shade->u.m.c0;
- float *c1 = shade->u.m.c1;
+ const float *c0 = shade->u.m.c0;
+ const float *c1 = shade->u.m.c1;
float color_storage[2][4][FZ_MAX_COLORS];
fz_point point_storage[2][16];
int store = 0;
@@ -922,7 +922,7 @@ fz_process_mesh_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz
}
void
-fz_process_mesh(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
+fz_process_mesh(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm,
fz_mesh_prepare_fn *prepare, fz_mesh_process_fn *process, void *process_arg)
{
fz_mesh_processor painter;
@@ -952,7 +952,7 @@ fz_process_mesh(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
}
static fz_rect *
-fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+fz_bound_mesh_type1(fz_context *ctx, const fz_shade *shade, fz_rect *bbox)
{
bbox->x0 = shade->u.f.domain[0][0];
bbox->y0 = shade->u.f.domain[0][1];
@@ -962,7 +962,7 @@ fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
}
static fz_rect *
-fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+fz_bound_mesh_type2(fz_context *ctx, const fz_shade *shade, fz_rect *bbox)
{
/* FIXME: If axis aligned and not extended, the bbox may only be
* infinite in one direction */
@@ -971,7 +971,7 @@ fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
}
static fz_rect *
-fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+fz_bound_mesh_type3(fz_context *ctx, const fz_shade *shade, fz_rect *bbox)
{
fz_point p0, p1;
float r0, r1;
@@ -1016,7 +1016,7 @@ fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
}
static fz_rect *
-fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+fz_bound_mesh_type4567(fz_context *ctx, const fz_shade *shade, fz_rect *bbox)
{
bbox->x0 = shade->u.m.x0;
bbox->y0 = shade->u.m.y0;
@@ -1026,7 +1026,7 @@ fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
}
static fz_rect *
-fz_bound_mesh(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+fz_bound_mesh(fz_context *ctx, const fz_shade *shade, fz_rect *bbox)
{
if (shade->type == FZ_FUNCTION_BASED)
fz_bound_mesh_type1(ctx, shade, bbox);
@@ -1046,8 +1046,10 @@ fz_bound_mesh(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
}
fz_shade *
-fz_keep_shade(fz_context *ctx, fz_shade *shade)
+fz_keep_shade(fz_context *ctx, const fz_shade *shadec)
{
+ fz_shade *shade = (fz_shade *)shadec;
+
return (fz_shade *)fz_keep_storable(ctx, &shade->storable);
}
@@ -1065,13 +1067,15 @@ fz_drop_shade_imp(fz_context *ctx, fz_storable *shade_)
}
void
-fz_drop_shade(fz_context *ctx, fz_shade *shade)
+fz_drop_shade(fz_context *ctx, const fz_shade *shadec)
{
+ fz_shade *shade = (fz_shade *)shadec;
+
fz_drop_storable(ctx, &shade->storable);
}
fz_rect *
-fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_rect *s)
+fz_bound_shade(fz_context *ctx, const fz_shade *shade, const fz_matrix *ctm, fz_rect *s)
{
fz_matrix local_ctm;
fz_rect rect;
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index a9dadc9b..c15eaca2 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -438,7 +438,7 @@ fz_lookup_stext_style_imp(fz_context *ctx, fz_stext_sheet *sheet,
static fz_stext_style *
fz_lookup_stext_style(fz_context *ctx, fz_stext_sheet *sheet, fz_text_span *span, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha, fz_stroke_state *stroke)
+ const fz_colorspace *colorspace, const float *color, float alpha, const fz_stroke_state *stroke)
{
float size = 1.0f;
fz_font *font = span ? span->font : NULL;
@@ -826,8 +826,8 @@ fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, cons
}
static void
-fz_stext_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_stext_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
@@ -840,8 +840,8 @@ fz_stext_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matr
}
static void
-fz_stext_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_stext_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
@@ -854,7 +854,7 @@ fz_stext_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_s
}
static void
-fz_stext_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_stext_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
@@ -867,7 +867,7 @@ fz_stext_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matr
}
static void
-fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
@@ -880,7 +880,7 @@ fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_str
}
static void
-fz_stext_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_stext_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_style *style;
@@ -893,8 +893,8 @@ fz_stext_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_ma
}
static void
-fz_stext_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm,
- fz_colorspace *cspace, float *color, float alpha)
+fz_stext_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *img, const fz_matrix *ctm,
+ const fz_colorspace *cspace, const float *color, float alpha)
{
fz_stext_device *tdev = (fz_stext_device*)dev;
fz_stext_page *page = tdev->page;
@@ -929,7 +929,7 @@ fz_stext_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *img, const f
}
static void
-fz_stext_fill_image(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm, float alpha)
+fz_stext_fill_image(fz_context *ctx, fz_device *dev, const fz_image *img, const fz_matrix *ctm, float alpha)
{
fz_stext_fill_image_mask(ctx, dev, img, ctm, NULL, NULL, alpha);
}
diff --git a/source/fitz/store.c b/source/fitz/store.c
index 4bb54c19..c2c86b00 100644
--- a/source/fitz/store.c
+++ b/source/fitz/store.c
@@ -54,14 +54,22 @@ fz_new_store_context(fz_context *ctx, unsigned int max)
}
void *
-fz_keep_storable(fz_context *ctx, fz_storable *s)
+fz_keep_storable(fz_context *ctx, const fz_storable *sc)
{
+ /* Explicitly drop const to allow us to use const
+ * sanely throughout the code. */
+ fz_storable *s = (fz_storable *)sc;
+
return fz_keep_imp(ctx, s, &s->refs);
}
void
-fz_drop_storable(fz_context *ctx, fz_storable *s)
+fz_drop_storable(fz_context *ctx, const fz_storable *sc)
{
+ /* Explicitly drop const to allow us to use const
+ * sanely throughout the code. */
+ fz_storable *s = (fz_storable *)sc;
+
/*
If we are dropping the last reference to an object, then
it cannot possibly be in the store (as the store always
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index 4dd60727..08912687 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -128,7 +128,7 @@ static const fz_path_processor svg_path_proc =
};
static void
-svg_dev_path(fz_context *ctx, svg_device *sdev, fz_path *path)
+svg_dev_path(fz_context *ctx, svg_device *sdev, const fz_path *path)
{
fz_printf(ctx, sdev->out, " d=\"");
fz_process_path(ctx, &svg_path_proc, sdev->out, path);
@@ -148,7 +148,7 @@ svg_dev_ctm(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm)
}
static void
-svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, fz_stroke_state *stroke_state, const fz_matrix *ctm)
+svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, const fz_stroke_state *stroke_state, const fz_matrix *ctm)
{
fz_output *out = sdev->out;
float exp;
@@ -179,7 +179,7 @@ svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, fz_stroke_state *stroke_
}
static void
-svg_dev_fill_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_fill_color(fz_context *ctx, svg_device *sdev, const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = sdev->out;
float rgb[FZ_MAX_COLORS];
@@ -202,7 +202,7 @@ svg_dev_fill_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspace,
}
static void
-svg_dev_stroke_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_stroke_color(fz_context *ctx, svg_device *sdev, const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = sdev->out;
float rgb[FZ_MAX_COLORS];
@@ -229,7 +229,7 @@ is_xml_wspace(int c)
}
static void
-svg_dev_text(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, fz_text *text)
+svg_dev_text(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const fz_text *text)
{
fz_output *out = sdev->out;
@@ -403,8 +403,8 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
}
static void
-svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, fz_text_span *span, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha, font *fnt)
+svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, const fz_text_span *span, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha, font *fnt)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -443,13 +443,12 @@ svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, fz_text_span *s
}
static void
-svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, fz_text_span *span,
- fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha, font *fnt)
+svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, const fz_text_span *span,
+ const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha, font *fnt)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
-
fz_matrix local_trm, local_trm2;
int i;
fz_matrix shift = { 1, 0, 0, 1, 0, 0};
@@ -487,8 +486,8 @@ svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, fz_text_span
/* Entry points */
static void
-svg_dev_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -503,8 +502,8 @@ svg_dev_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd,
}
static void
-svg_dev_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -518,7 +517,7 @@ svg_dev_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_st
}
static void
-svg_dev_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+svg_dev_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out;
@@ -538,7 +537,7 @@ svg_dev_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect
}
static void
-svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
@@ -563,8 +562,8 @@ svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const f
}
static void
-svg_dev_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -583,8 +582,8 @@ svg_dev_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matri
}
static void
-svg_dev_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -603,7 +602,7 @@ svg_dev_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
}
static void
-svg_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -633,7 +632,7 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matri
}
static void
-svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
@@ -664,7 +663,7 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stro
}
static void
-svg_dev_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+svg_dev_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -715,7 +714,7 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
}
static void
-svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+svg_dev_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -757,7 +756,7 @@ svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
}
static void
-svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+svg_dev_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
@@ -802,8 +801,8 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
}
static void
-svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
-fz_colorspace *colorspace, float *color, float alpha)
+svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
svg_device *sdev = (svg_device*)dev;
@@ -847,7 +846,7 @@ fz_colorspace *colorspace, float *color, float alpha)
}
static void
-svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out;
@@ -898,7 +897,7 @@ svg_dev_pop_clip(fz_context *ctx, fz_device *dev)
}
static void
-svg_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, fz_colorspace *colorspace, float *color)
+svg_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, const fz_colorspace *colorspace, const float *color)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out;
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c
index 86b39161..339b1e94 100644
--- a/source/fitz/test-device.c
+++ b/source/fitz/test-device.c
@@ -26,7 +26,7 @@ is_rgb_color_u8(int threshold_u8, int r, int g, int b)
}
static void
-fz_test_color(fz_context *ctx, fz_device *dev, fz_colorspace *colorspace, const float *color)
+fz_test_color(fz_context *ctx, fz_device *dev, const fz_colorspace *colorspace, const float *color)
{
fz_test_device *t = (fz_test_device*)dev;
@@ -56,32 +56,32 @@ fz_test_color(fz_context *ctx, fz_device *dev, fz_colorspace *colorspace, const
}
static void
-fz_test_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_test_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (alpha != 0.0f)
fz_test_color(ctx, dev, colorspace, color);
}
static void
-fz_test_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
+fz_test_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace, const float *color, float alpha)
{
if (alpha != 0.0f)
fz_test_color(ctx, dev, colorspace, color);
}
static void
-fz_test_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_test_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
if (alpha != 0.0f)
fz_test_color(ctx, dev, colorspace, color);
}
static void
-fz_test_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
+fz_test_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke,
+ const fz_matrix *ctm, const fz_colorspace *colorspace, const float *color, float alpha)
{
if (alpha != 0.0f)
fz_test_color(ctx, dev, colorspace, color);
@@ -90,7 +90,7 @@ fz_test_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_st
struct shadearg
{
fz_device *dev;
- fz_shade *shade;
+ const fz_shade *shade;
};
static void
@@ -98,13 +98,13 @@ prepare_vertex(fz_context *ctx, void *arg_, fz_vertex *v, const float *color)
{
struct shadearg *arg = arg_;
fz_device *dev = arg->dev;
- fz_shade *shade = arg->shade;
+ const fz_shade *shade = arg->shade;
if (!shade->use_function)
fz_test_color(ctx, dev, shade->colorspace, color);
}
static void
-fz_test_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_test_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
if (shade->use_function)
{
@@ -122,7 +122,7 @@ fz_test_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
}
static void
-fz_test_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_test_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_test_device *t = (fz_test_device*)dev;
@@ -241,8 +241,8 @@ fz_test_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
}
static void
-fz_test_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_test_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
/* We assume that at least some of the image pixels are non-zero */
fz_test_color(ctx, dev, colorspace, color);
diff --git a/source/fitz/text.c b/source/fitz/text.c
index 5490f72e..c9dfda9d 100644
--- a/source/fitz/text.c
+++ b/source/fitz/text.c
@@ -9,14 +9,18 @@ fz_new_text(fz_context *ctx)
}
fz_text *
-fz_keep_text(fz_context *ctx, fz_text *text)
+fz_keep_text(fz_context *ctx, const fz_text *textc)
{
+ fz_text *text = (fz_text *)textc; /* Explicit cast away of const */
+
return fz_keep_imp(ctx, text, &text->refs);
}
void
-fz_drop_text(fz_context *ctx, fz_text *text)
+fz_drop_text(fz_context *ctx, const fz_text *textc)
{
+ fz_text *text = (fz_text *)textc; /* Explicit cast away of const */
+
if (fz_drop_imp(ctx, text, &text->refs))
{
fz_text_span *span = text->head;
@@ -95,7 +99,7 @@ fz_add_text(fz_context *ctx, fz_text *text, fz_font *font, int wmode, const fz_m
}
fz_rect *
-fz_bound_text(fz_context *ctx, fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *bbox)
+fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *bbox)
{
fz_text_span *span;
fz_matrix tm, trm;
@@ -140,7 +144,7 @@ fz_bound_text(fz_context *ctx, fz_text *text, const fz_stroke_state *stroke, con
}
fz_text *
-fz_clone_text(fz_context *ctx, fz_text *text)
+fz_clone_text(fz_context *ctx, const fz_text *text)
{
fz_text *new_text;
fz_text_span *span;
diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c
index 1f972642..6d12a396 100644
--- a/source/fitz/trace-device.c
+++ b/source/fitz/trace-device.c
@@ -14,7 +14,7 @@ fz_trace_matrix(fz_context *ctx, fz_output *out, const fz_matrix *ctm)
}
static void
-fz_trace_color(fz_context *ctx, fz_output *out, fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_color(fz_context *ctx, fz_output *out, const fz_colorspace *colorspace, const float *color, float alpha)
{
int i;
fz_printf(ctx, out, " colorspace=\"%s\" color=\"", colorspace->name);
@@ -50,7 +50,7 @@ fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span)
}
static void
-fz_trace_text(fz_context *ctx, fz_output *out, fz_text *text)
+fz_trace_text(fz_context *ctx, fz_output *out, const fz_text *text)
{
fz_text_span *span;
for (span = text->head; span; span = span->next)
@@ -94,7 +94,7 @@ static const fz_path_processor trace_path_proc =
};
static void
-fz_trace_path(fz_context *ctx, fz_output *out, fz_path *path)
+fz_trace_path(fz_context *ctx, fz_output *out, const fz_path *path)
{
fz_process_path(ctx, &trace_path_proc, out, path);
}
@@ -116,8 +116,8 @@ fz_trace_end_page(fz_context *ctx, fz_device *dev)
}
static void
-fz_trace_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<fill_path");
@@ -133,8 +133,8 @@ fz_trace_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd,
}
static void
-fz_trace_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
int i;
@@ -163,7 +163,7 @@ fz_trace_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_s
}
static void
-fz_trace_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
+fz_trace_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_path");
@@ -181,7 +181,7 @@ fz_trace_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect
}
static void
-fz_trace_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_trace_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_rect *rect, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_stroke_path");
@@ -192,8 +192,8 @@ fz_trace_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const
}
static void
-fz_trace_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<fill_text");
@@ -205,8 +205,8 @@ fz_trace_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matr
}
static void
-fz_trace_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<stroke_text");
@@ -218,7 +218,7 @@ fz_trace_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_s
}
static void
-fz_trace_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_trace_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_text");
@@ -229,7 +229,7 @@ fz_trace_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matr
}
static void
-fz_trace_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_trace_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_stroke_text");
@@ -240,7 +240,7 @@ fz_trace_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_str
}
static void
-fz_trace_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm)
+fz_trace_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<ignore_text");
@@ -251,7 +251,7 @@ fz_trace_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_ma
}
static void
-fz_trace_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_trace_fill_image(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<fill_image alpha=\"%g\"", alpha);
@@ -261,7 +261,7 @@ fz_trace_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_m
}
static void
-fz_trace_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_trace_fill_shade(fz_context *ctx, fz_device *dev, const fz_shade *shade, const fz_matrix *ctm, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<fill_shade alpha=\"%g\"", alpha);
@@ -270,8 +270,8 @@ fz_trace_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_m
}
static void
-fz_trace_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
-fz_colorspace *colorspace, float *color, float alpha)
+fz_trace_fill_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_matrix *ctm,
+ const fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<fill_image_mask");
@@ -282,7 +282,7 @@ fz_colorspace *colorspace, float *color, float alpha)
}
static void
-fz_trace_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
+fz_trace_clip_image_mask(fz_context *ctx, fz_device *dev, const fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<clip_image_mask");
@@ -299,7 +299,7 @@ fz_trace_pop_clip(fz_context *ctx, fz_device *dev)
}
static void
-fz_trace_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, fz_colorspace *colorspace, float *color)
+fz_trace_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, const fz_colorspace *colorspace, const float *color)
{
fz_output *out = ((fz_trace_device*)dev)->out;
fz_printf(ctx, out, "<mask bbox=\"%g %g %g %g\" s=\"%s\"",