summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-09-14 17:36:57 +0100
committerRobin Watts <Robin.Watts@artifex.com>2011-09-15 14:50:17 +0100
commitb51ef0eea028c73b6379e832eaa34fff3fbbb927 (patch)
tree1ab685ccd356e7fdc832b2e3322c0486b2670cfb /draw
parent89ae81f651bfa112b8e07317eb6983beaf7cb212 (diff)
downloadmupdf-b51ef0eea028c73b6379e832eaa34fff3fbbb927.tar.xz
Add context to mupdf.
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
Diffstat (limited to 'draw')
-rw-r--r--draw/draw_device.c230
-rw-r--r--draw/draw_edge.c28
-rw-r--r--draw/draw_glyph.c36
-rw-r--r--draw/draw_mesh.c10
-rw-r--r--draw/draw_scale.c28
5 files changed, 167 insertions, 165 deletions
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 76b55276..3e289f3e 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -38,6 +38,7 @@ struct fz_draw_device_s
{
fz_glyph_cache *cache;
fz_gel *gel;
+ fz_context *ctx;
fz_pixmap *dest;
fz_pixmap *shape;
@@ -88,9 +89,8 @@ static void dump_spaces(int x, const char *s)
#endif
-static void fz_knockout_begin(void *user)
+static void fz_knockout_begin(fz_draw_device *dev)
{
- fz_draw_device *dev = user;
fz_bbox bbox;
fz_pixmap *dest, *shape;
int isolated = dev->blendmode & FZ_BLEND_ISOLATED;
@@ -106,7 +106,7 @@ static void fz_knockout_begin(void *user)
bbox = fz_bound_pixmap(dev->dest);
bbox = fz_intersect_bbox(bbox, dev->scissor);
- dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, dev->dest->colorspace, bbox);
if (isolated)
{
@@ -130,7 +130,7 @@ static void fz_knockout_begin(void *user)
}
else
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
dev->stack[dev->top].blendmode = dev->blendmode;
@@ -148,9 +148,8 @@ static void fz_knockout_begin(void *user)
dev->blendmode &= ~FZ_BLEND_MODEMASK;
}
-static void fz_knockout_end(void *user)
+static void fz_knockout_end(fz_draw_device *dev)
{
- fz_draw_device *dev = user;
fz_pixmap *group = dev->dest;
fz_pixmap *shape = dev->shape;
int blendmode;
@@ -194,14 +193,14 @@ static void fz_knockout_end(void *user)
else
fz_blend_pixmap(dev->dest, group, 255, blendmode, isolated, shape);
- fz_drop_pixmap(group);
+ fz_drop_pixmap(dev->ctx, group);
if (shape != dev->shape)
{
if (dev->shape)
{
fz_paint_pixmap(dev->shape, shape, 255);
}
- fz_drop_pixmap(shape);
+ fz_drop_pixmap(dev->ctx, shape);
}
#ifdef DUMP_GROUP_BLENDS
fz_dump_blend(dev->dest, " to get ");
@@ -213,10 +212,10 @@ static void fz_knockout_end(void *user)
}
static void
-fz_draw_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm,
+fz_draw_fill_path(fz_device *devp, fz_path *path, int even_odd, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
@@ -259,10 +258,10 @@ fz_draw_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm,
}
static void
-fz_draw_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm,
+fz_draw_stroke_path(fz_device *devp, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
@@ -315,9 +314,9 @@ fz_draw_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matri
}
static void
-fz_draw_clip_path(void *user, fz_path *path, fz_rect *rect, int even_odd, fz_matrix ctm)
+fz_draw_clip_path(fz_device *devp, fz_path *path, fz_rect *rect, int even_odd, fz_matrix ctm)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
@@ -354,14 +353,14 @@ fz_draw_clip_path(void *user, fz_path *path, fz_rect *rect, int even_odd, fz_mat
return;
}
- mask = fz_new_pixmap_with_rect(NULL, bbox);
+ mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(mask);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
if (dev->shape)
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
else
@@ -385,9 +384,9 @@ fz_draw_clip_path(void *user, fz_path *path, fz_rect *rect, int even_odd, fz_mat
}
static void
-fz_draw_clip_stroke_path(void *user, fz_path *path, fz_rect *rect, fz_stroke_state *stroke, fz_matrix ctm)
+fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, fz_rect *rect, fz_stroke_state *stroke, fz_matrix ctm)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
@@ -416,14 +415,14 @@ fz_draw_clip_stroke_path(void *user, fz_path *path, fz_rect *rect, fz_stroke_sta
if (rect)
bbox = fz_intersect_bbox(bbox, fz_round_rect(*rect));
- mask = fz_new_pixmap_with_rect(NULL, bbox);
+ mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(mask);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
if (dev->shape)
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
else
@@ -484,10 +483,10 @@ draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_pixmap *msk,
}
static void
-fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm,
+fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
unsigned char colorbv[FZ_MAX_COLORS + 1];
unsigned char shapebv;
@@ -521,7 +520,7 @@ fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm,
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_glyph(dev->cache, text->font, gid, trm, model);
+ glyph = fz_render_glyph(dev->ctx, dev->cache, text->font, gid, trm, model);
if (glyph)
{
if (glyph->n == 1)
@@ -535,7 +534,7 @@ fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm,
fz_matrix ctm = {glyph->w, 0.0, 0.0, -glyph->h, x + glyph->x, y + glyph->y + glyph->h};
fz_paint_image(dev->dest, dev->scissor, dev->shape, glyph, ctm, alpha * 255);
}
- fz_drop_pixmap(glyph);
+ fz_drop_pixmap(dev->ctx, glyph);
}
}
@@ -544,10 +543,10 @@ fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm,
}
static void
-fz_draw_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm,
+fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
unsigned char colorbv[FZ_MAX_COLORS + 1];
float colorfv[FZ_MAX_COLORS];
@@ -579,13 +578,13 @@ fz_draw_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matri
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_stroked_glyph(dev->cache, text->font, gid, trm, ctm, stroke);
+ glyph = fz_render_stroked_glyph(dev->ctx, dev->cache, text->font, gid, trm, ctm, stroke);
if (glyph)
{
draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor);
if (dev->shape)
draw_glyph(colorbv, dev->shape, glyph, x, y, dev->scissor);
- fz_drop_pixmap(glyph);
+ fz_drop_pixmap(dev->ctx, glyph);
}
}
@@ -594,9 +593,9 @@ fz_draw_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matri
}
static void
-fz_draw_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate)
+fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_bbox bbox;
fz_pixmap *mask, *dest, *shape;
@@ -628,14 +627,14 @@ fz_draw_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate)
if (accumulate == 0 || accumulate == 1)
{
- mask = fz_new_pixmap_with_rect(NULL, bbox);
+ mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(mask);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
if (dev->shape)
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
else
@@ -678,22 +677,22 @@ fz_draw_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate)
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_glyph(dev->cache, text->font, gid, trm, model);
+ glyph = fz_render_glyph(dev->ctx, dev->cache, text->font, gid, trm, model);
if (glyph)
{
draw_glyph(NULL, mask, glyph, x, y, bbox);
if (dev->shape)
draw_glyph(NULL, dev->shape, glyph, x, y, bbox);
- fz_drop_pixmap(glyph);
+ fz_drop_pixmap(dev->ctx, glyph);
}
}
}
}
static void
-fz_draw_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm)
+fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_bbox bbox;
fz_pixmap *mask, *dest, *shape;
@@ -711,14 +710,14 @@ fz_draw_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_
bbox = fz_round_rect(fz_bound_text(text, ctm));
bbox = fz_intersect_bbox(bbox, dev->scissor);
- mask = fz_new_pixmap_with_rect(NULL, bbox);
+ mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(mask);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
if (dev->shape)
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
else
@@ -756,27 +755,27 @@ fz_draw_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_
trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX);
trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX);
- glyph = fz_render_stroked_glyph(dev->cache, text->font, gid, trm, ctm, stroke);
+ glyph = fz_render_stroked_glyph(dev->ctx, dev->cache, text->font, gid, trm, ctm, stroke);
if (glyph)
{
draw_glyph(NULL, mask, glyph, x, y, bbox);
if (dev->shape)
draw_glyph(NULL, dev->shape, glyph, x, y, bbox);
- fz_drop_pixmap(glyph);
+ fz_drop_pixmap(dev->ctx, glyph);
}
}
}
}
static void
-fz_draw_ignore_text(void *user, fz_text *text, fz_matrix ctm)
+fz_draw_ignore_text(fz_device *dev, fz_text *text, fz_matrix ctm)
{
}
static void
-fz_draw_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
+fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_pixmap *dest = dev->dest;
fz_rect bounds;
@@ -801,7 +800,7 @@ fz_draw_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
if (alpha < 1)
{
- dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, dev->dest->colorspace, bbox);
fz_clear_pixmap(dest);
}
@@ -840,14 +839,14 @@ fz_draw_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
}
}
- fz_paint_shade(shade, ctm, dest, bbox);
+ fz_paint_shade(dev->ctx, shade, ctm, dest, bbox);
if (dev->shape)
fz_clear_pixmap_rect_with_color(dev->shape, 255, bbox);
if (alpha < 1)
{
fz_paint_pixmap(dev->dest, dest, alpha * 255);
- fz_drop_pixmap(dest);
+ fz_drop_pixmap(dev->ctx, dest);
}
if (dev->blendmode & FZ_BLEND_KNOCKOUT)
@@ -855,14 +854,14 @@ fz_draw_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
}
static fz_pixmap *
-fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit)
+fz_transform_pixmap(fz_context *ctx, fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit)
{
fz_pixmap *scaled;
if (ctm->a != 0 && ctm->b == 0 && ctm->c == 0 && ctm->d != 0)
{
/* Unrotated or X-flip or Y-flip or XY-flip */
- scaled = fz_scale_pixmap_gridfit(image, ctm->e, ctm->f, ctm->a, ctm->d, gridfit);
+ scaled = fz_scale_pixmap_gridfit(ctx, image, ctm->e, ctm->f, ctm->a, ctm->d, gridfit);
if (scaled == NULL)
return NULL;
ctm->a = scaled->w;
@@ -875,7 +874,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
if (ctm->a == 0 && ctm->b != 0 && ctm->c != 0 && ctm->d == 0)
{
/* Other orthogonal flip/rotation cases */
- scaled = fz_scale_pixmap_gridfit(image, ctm->f, ctm->e, ctm->b, ctm->c, gridfit);
+ scaled = fz_scale_pixmap_gridfit(ctx, image, ctm->f, ctm->e, ctm->b, ctm->c, gridfit);
if (scaled == NULL)
return NULL;
ctm->b = scaled->w;
@@ -888,7 +887,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
/* Downscale, non rectilinear case */
if (dx > 0 && dy > 0)
{
- scaled = fz_scale_pixmap(image, 0, 0, (float)dx, (float)dy);
+ scaled = fz_scale_pixmap(ctx, image, 0, 0, (float)dx, (float)dy);
return scaled;
}
@@ -896,9 +895,9 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
}
static void
-fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
+fz_draw_fill_image(fz_device *devp, fz_pixmap *image, fz_matrix ctm, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_pixmap *converted = NULL;
fz_pixmap *scaled = NULL;
@@ -927,8 +926,8 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
if (image->colorspace != model && !after)
{
- converted = fz_new_pixmap_with_rect(model, fz_bound_pixmap(image));
- fz_convert_pixmap(image, converted);
+ converted = fz_new_pixmap_with_rect(dev->ctx, model, fz_bound_pixmap(image));
+ fz_convert_pixmap(dev->ctx, image, converted);
image = converted;
}
@@ -937,14 +936,14 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
if (dx < image->w && dy < image->h)
{
int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
+ scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
if (scaled != NULL)
image = scaled;
@@ -959,8 +958,8 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
}
else
{
- converted = fz_new_pixmap_with_rect(model, fz_bound_pixmap(image));
- fz_convert_pixmap(image, converted);
+ converted = fz_new_pixmap_with_rect(dev->ctx, model, fz_bound_pixmap(image));
+ fz_convert_pixmap(dev->ctx, image, converted);
image = converted;
}
}
@@ -968,19 +967,19 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
fz_paint_image(dev->dest, dev->scissor, dev->shape, image, ctm, alpha * 255);
if (scaled)
- fz_drop_pixmap(scaled);
+ fz_drop_pixmap(dev->ctx, scaled);
if (converted)
- fz_drop_pixmap(converted);
+ fz_drop_pixmap(dev->ctx, converted);
if (dev->blendmode & FZ_BLEND_KNOCKOUT)
fz_knockout_end(dev);
}
static void
-fz_draw_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
+fz_draw_fill_image_mask(fz_device *devp, fz_pixmap *image, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
unsigned char colorbv[FZ_MAX_COLORS + 1];
float colorfv[FZ_MAX_COLORS];
@@ -999,14 +998,14 @@ fz_draw_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
if (dx < image->w && dy < image->h)
{
int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
+ scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
if (scaled != NULL)
image = scaled;
@@ -1020,16 +1019,16 @@ fz_draw_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
fz_paint_image_with_color(dev->dest, dev->scissor, dev->shape, image, ctm, colorbv);
if (scaled)
- fz_drop_pixmap(scaled);
+ fz_drop_pixmap(dev->ctx, scaled);
if (dev->blendmode & FZ_BLEND_KNOCKOUT)
fz_knockout_begin(dev);
}
static void
-fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix ctm)
+fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_matrix ctm)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_bbox bbox;
fz_pixmap *mask, *dest, *shape;
@@ -1062,14 +1061,14 @@ fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix c
if (rect)
bbox = fz_intersect_bbox(bbox, fz_round_rect(*rect));
- mask = fz_new_pixmap_with_rect(NULL, bbox);
+ mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(mask);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
if (dev->shape)
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
else
@@ -1080,14 +1079,14 @@ fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix c
if (dx < image->w && dy < image->h)
{
int gridfit = !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
+ scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
dx = 1;
if (dy < 1)
dy = 1;
- scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy);
+ scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
if (scaled != NULL)
image = scaled;
@@ -1096,7 +1095,7 @@ fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix c
fz_paint_image(mask, bbox, dev->shape, image, ctm, 255);
if (scaled)
- fz_drop_pixmap(scaled);
+ fz_drop_pixmap(dev->ctx, scaled);
dev->stack[dev->top].scissor = dev->scissor;
dev->stack[dev->top].mask = mask;
@@ -1111,9 +1110,9 @@ fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix c
}
static void
-fz_draw_pop_clip(void *user)
+fz_draw_pop_clip(fz_device *devp)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_pixmap *mask, *dest, *shape;
if (dev->top > 0)
{
@@ -1147,11 +1146,11 @@ fz_draw_pop_clip(void *user)
{
assert(shape != dev->shape);
fz_paint_pixmap_with_mask(shape, dev->shape, mask);
- fz_drop_pixmap(dev->shape);
+ fz_drop_pixmap(dev->ctx, dev->shape);
dev->shape = shape;
}
- fz_drop_pixmap(mask);
- fz_drop_pixmap(dev->dest);
+ fz_drop_pixmap(dev->ctx, mask);
+ fz_drop_pixmap(dev->ctx, dev->dest);
dev->dest = dest;
#ifdef DUMP_GROUP_BLENDS
fz_dump_blend(dev->dest, " to get ");
@@ -1172,9 +1171,9 @@ fz_draw_pop_clip(void *user)
}
static void
-fz_draw_begin_mask(void *user, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *colorfv)
+fz_draw_begin_mask(fz_device *devp, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *colorfv)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_pixmap *dest;
fz_pixmap *shape = dev->shape;
fz_bbox bbox;
@@ -1187,7 +1186,7 @@ fz_draw_begin_mask(void *user, fz_rect rect, int luminosity, fz_colorspace *colo
bbox = fz_round_rect(rect);
bbox = fz_intersect_bbox(bbox, dev->scissor);
- dest = fz_new_pixmap_with_rect(fz_device_gray, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, fz_device_gray, bbox);
if (dev->shape)
{
/* FIXME: If we ever want to support AIS true, then we
@@ -1232,9 +1231,9 @@ fz_draw_begin_mask(void *user, fz_rect rect, int luminosity, fz_colorspace *colo
}
static void
-fz_draw_end_mask(void *user)
+fz_draw_end_mask(fz_device *devp)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_pixmap *mask = dev->dest;
fz_pixmap *maskshape = dev->shape;
fz_pixmap *temp, *dest;
@@ -1257,13 +1256,13 @@ fz_draw_end_mask(void *user)
dev->shape = dev->stack[dev->top].shape;
/* convert to alpha mask */
- temp = fz_alpha_from_gray(mask, luminosity);
- fz_drop_pixmap(mask);
- fz_drop_pixmap(maskshape);
+ temp = fz_alpha_from_gray(dev->ctx, mask, luminosity);
+ fz_drop_pixmap(dev->ctx, mask);
+ fz_drop_pixmap(dev->ctx, maskshape);
/* create new dest scratch buffer */
bbox = fz_bound_pixmap(temp);
- dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, dev->dest->colorspace, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
@@ -1278,7 +1277,7 @@ fz_draw_end_mask(void *user)
if (dev->shape)
{
dev->stack[dev->top].shape = dev->shape;
- dev->shape = fz_new_pixmap_with_rect(NULL, bbox);
+ dev->shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(dev->shape);
}
dev->scissor = bbox;
@@ -1291,9 +1290,9 @@ fz_draw_end_mask(void *user)
}
static void
-fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int blendmode, float alpha)
+fz_draw_begin_group(fz_device *devp, fz_rect rect, int isolated, int knockout, int blendmode, float alpha)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_bbox bbox;
fz_pixmap *dest, *shape;
@@ -1309,7 +1308,7 @@ fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int bl
bbox = fz_round_rect(rect);
bbox = fz_intersect_bbox(bbox, dev->scissor);
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
#ifndef ATTEMPT_KNOCKOUT_AND_ISOLATED
knockout = 0;
@@ -1333,7 +1332,7 @@ fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int bl
}
else
{
- shape = fz_new_pixmap_with_rect(NULL, bbox);
+ shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox);
fz_clear_pixmap(shape);
}
@@ -1354,9 +1353,9 @@ fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, int bl
}
static void
-fz_draw_end_group(void *user)
+fz_draw_end_group(fz_device *devp)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_pixmap *group = dev->dest;
fz_pixmap *shape = dev->shape;
int blendmode;
@@ -1396,14 +1395,14 @@ fz_draw_end_group(void *user)
else
fz_blend_pixmap(dev->dest, group, alpha * 255, blendmode, isolated, shape);
- fz_drop_pixmap(group);
+ fz_drop_pixmap(dev->ctx, group);
if (shape != dev->shape)
{
if (dev->shape)
{
fz_paint_pixmap(dev->shape, shape, alpha * 255);
}
- fz_drop_pixmap(shape);
+ fz_drop_pixmap(dev->ctx, shape);
}
#ifdef DUMP_GROUP_BLENDS
fz_dump_blend(dev->dest, " to get ");
@@ -1418,9 +1417,9 @@ fz_draw_end_group(void *user)
}
static void
-fz_draw_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm)
+fz_draw_begin_tile(fz_device *devp, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_colorspace *model = dev->dest->colorspace;
fz_pixmap *dest;
fz_bbox bbox;
@@ -1438,7 +1437,7 @@ fz_draw_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ys
fz_knockout_begin(dev);
bbox = fz_round_rect(fz_transform_rect(ctm, view));
- dest = fz_new_pixmap_with_rect(model, bbox);
+ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox);
/* FIXME: See note #1 */
fz_clear_pixmap(dest);
@@ -1461,9 +1460,9 @@ fz_draw_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ys
}
static void
-fz_draw_end_tile(void *user)
+fz_draw_end_tile(fz_device *devp)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
fz_pixmap *tile = dev->dest;
float xstep, ystep;
fz_matrix ctm, ttm;
@@ -1504,7 +1503,7 @@ fz_draw_end_tile(void *user)
}
}
- fz_drop_pixmap(tile);
+ fz_drop_pixmap(dev->ctx, tile);
}
if (dev->blendmode & FZ_BLEND_KNOCKOUT)
@@ -1512,35 +1511,36 @@ fz_draw_end_tile(void *user)
}
static void
-fz_draw_free_user(void *user)
+fz_draw_free_user(fz_device *devp)
{
- fz_draw_device *dev = user;
+ fz_draw_device *dev = devp->user;
/* TODO: pop and free the stacks */
if (dev->top > 0)
fz_warn("items left on stack in draw device: %d", dev->top);
fz_free_gel(dev->gel);
- fz_free(dev);
+ fz_free(devp->ctx, dev);
}
fz_device *
-fz_new_draw_device(fz_glyph_cache *cache, fz_pixmap *dest)
+fz_new_draw_device(fz_context *ctx, fz_glyph_cache *cache, fz_pixmap *dest)
{
fz_device *dev;
- fz_draw_device *ddev = fz_malloc(sizeof(fz_draw_device));
+ fz_draw_device *ddev = fz_malloc(ctx, sizeof(fz_draw_device));
ddev->cache = cache;
- ddev->gel = fz_new_gel();
+ ddev->gel = fz_new_gel(ctx);
ddev->dest = dest;
ddev->shape = NULL;
ddev->top = 0;
ddev->blendmode = 0;
ddev->flags = 0;
+ ddev->ctx = ctx;
ddev->scissor.x0 = dest->x;
ddev->scissor.y0 = dest->y;
ddev->scissor.x1 = dest->x + dest->w;
ddev->scissor.y1 = dest->y + dest->h;
- dev = fz_new_device(ddev);
+ dev = fz_new_device(ctx, ddev);
dev->free_user = fz_draw_free_user;
dev->fill_path = fz_draw_fill_path;
@@ -1573,9 +1573,9 @@ fz_new_draw_device(fz_glyph_cache *cache, fz_pixmap *dest)
}
fz_device *
-fz_new_draw_device_type3(fz_glyph_cache *cache, fz_pixmap *dest)
+fz_new_draw_device_type3(fz_context *ctx, fz_glyph_cache *cache, fz_pixmap *dest)
{
- fz_device *dev = fz_new_draw_device(cache, dest);
+ fz_device *dev = fz_new_draw_device(ctx, cache, dest);
fz_draw_device *ddev = dev->user;
ddev->flags |= FZ_DRAWDEV_FLAGS_TYPE3;
return dev;
diff --git a/draw/draw_edge.c b/draw/draw_edge.c
index 123c3268..ee218bc9 100644
--- a/draw/draw_edge.c
+++ b/draw/draw_edge.c
@@ -127,17 +127,19 @@ struct fz_gel_s
fz_edge *edges;
int acap, alen;
fz_edge **active;
+ fz_context *ctx;
};
fz_gel *
-fz_new_gel(void)
+fz_new_gel(fz_context *ctx)
{
fz_gel *gel;
- gel = fz_malloc(sizeof(fz_gel));
+ gel = fz_malloc(ctx, sizeof(fz_gel));
+ gel->ctx = ctx;
gel->cap = 512;
gel->len = 0;
- gel->edges = fz_calloc(gel->cap, sizeof(fz_edge));
+ gel->edges = fz_calloc(ctx, gel->cap, sizeof(fz_edge));
gel->clip.x0 = gel->clip.y0 = BBOX_MAX;
gel->clip.x1 = gel->clip.y1 = BBOX_MIN;
@@ -147,7 +149,7 @@ fz_new_gel(void)
gel->acap = 64;
gel->alen = 0;
- gel->active = fz_calloc(gel->acap, sizeof(fz_edge*));
+ gel->active = fz_calloc(ctx, gel->acap, sizeof(fz_edge*));
return gel;
}
@@ -176,9 +178,9 @@ fz_reset_gel(fz_gel *gel, fz_bbox clip)
void
fz_free_gel(fz_gel *gel)
{
- fz_free(gel->active);
- fz_free(gel->edges);
- fz_free(gel);
+ fz_free(gel->ctx, gel->active);
+ fz_free(gel->ctx, gel->edges);
+ fz_free(gel->ctx, gel);
}
fz_bbox
@@ -253,7 +255,7 @@ fz_insert_gel_raw(fz_gel *gel, int x0, int y0, int x1, int y1)
if (gel->len + 1 == gel->cap) {
gel->cap = gel->cap + 512;
- gel->edges = fz_realloc(gel->edges, gel->cap, sizeof(fz_edge));
+ gel->edges = fz_realloc(gel->ctx, gel->edges, gel->cap * sizeof(fz_edge));
}
edge = &gel->edges[gel->len++];
@@ -443,7 +445,7 @@ insert_active(fz_gel *gel, int y, int *e)
while (*e < gel->len && gel->edges[*e].y == y) {
if (gel->alen + 1 == gel->acap) {
int newcap = gel->acap + 64;
- fz_edge **newactive = fz_realloc(gel->active, newcap, sizeof(fz_edge*));
+ fz_edge **newactive = fz_realloc(gel->ctx, gel->active, newcap * sizeof(fz_edge*));
gel->active = newactive;
gel->acap = newcap;
}
@@ -593,8 +595,8 @@ fz_scan_convert_aa(fz_gel *gel, int eofill, fz_bbox clip,
assert(clip.x0 >= xmin);
assert(clip.x1 <= xmax);
- alphas = fz_malloc(xmax - xmin + 1);
- deltas = fz_malloc((xmax - xmin + 1) * sizeof(int));
+ alphas = fz_malloc(gel->ctx, xmax - xmin + 1);
+ deltas = fz_malloc(gel->ctx, (xmax - xmin + 1) * sizeof(int));
memset(deltas, 0, (xmax - xmin + 1) * sizeof(int));
e = 0;
@@ -640,8 +642,8 @@ fz_scan_convert_aa(fz_gel *gel, int eofill, fz_bbox clip,
blit_aa(dst, xmin + skipx, yd, alphas + skipx, clipn, color);
}
- fz_free(deltas);
- fz_free(alphas);
+ fz_free(gel->ctx, deltas);
+ fz_free(gel->ctx, alphas);
}
/*
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c
index 95f3955d..1d94f767 100644
--- a/draw/draw_glyph.c
+++ b/draw/draw_glyph.c
@@ -22,19 +22,19 @@ struct fz_glyph_key_s
};
fz_glyph_cache *
-fz_new_glyph_cache(void)
+fz_new_glyph_cache(fz_context *ctx)
{
fz_glyph_cache *cache;
- cache = fz_malloc(sizeof(fz_glyph_cache));
- cache->hash = fz_new_hash_table(509, sizeof(fz_glyph_key));
+ cache = fz_malloc(ctx, sizeof(fz_glyph_cache));
+ cache->hash = fz_new_hash_table(ctx, 509, sizeof(fz_glyph_key));
cache->total = 0;
return cache;
}
static void
-fz_evict_glyph_cache(fz_glyph_cache *cache)
+fz_evict_glyph_cache(fz_context *ctx, fz_glyph_cache *cache)
{
fz_glyph_key *key;
fz_pixmap *pixmap;
@@ -44,10 +44,10 @@ fz_evict_glyph_cache(fz_glyph_cache *cache)
{
key = fz_hash_get_key(cache->hash, i);
if (key->font)
- fz_drop_font(key->font);
+ fz_drop_font(ctx, key->font);
pixmap = fz_hash_get_val(cache->hash, i);
if (pixmap)
- fz_drop_pixmap(pixmap);
+ fz_drop_pixmap(ctx, pixmap);
}
cache->total = 0;
@@ -56,23 +56,23 @@ fz_evict_glyph_cache(fz_glyph_cache *cache)
}
void
-fz_free_glyph_cache(fz_glyph_cache *cache)
+fz_free_glyph_cache(fz_context *ctx, fz_glyph_cache *cache)
{
- fz_evict_glyph_cache(cache);
- fz_free_hash(cache->hash);
- fz_free(cache);
+ fz_evict_glyph_cache(ctx, cache);
+ fz_free_hash(ctx, cache->hash);
+ fz_free(ctx, cache);
}
fz_pixmap *
-fz_render_stroked_glyph(fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke)
+fz_render_stroked_glyph(fz_context *ctx, fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke)
{
if (font->ft_face)
- return fz_render_ft_stroked_glyph(font, gid, trm, ctm, stroke);
- return fz_render_glyph(cache, font, gid, trm, NULL);
+ return fz_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, stroke);
+ return fz_render_glyph(ctx, cache, font, gid, trm, NULL);
}
fz_pixmap *
-fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix ctm, fz_colorspace *model)
+fz_render_glyph(fz_context *ctx, fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix ctm, fz_colorspace *model)
{
fz_glyph_key key;
fz_pixmap *val;
@@ -104,11 +104,11 @@ fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix ctm, fz
if (font->ft_face)
{
- val = fz_render_ft_glyph(font, gid, ctm);
+ val = fz_render_ft_glyph(ctx, font, gid, ctm);
}
else if (font->t3procs)
{
- val = fz_render_t3_glyph(font, gid, ctm, model);
+ val = fz_render_t3_glyph(ctx, font, gid, ctm, model);
}
else
{
@@ -121,9 +121,9 @@ fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int gid, fz_matrix ctm, fz
if (val->w < MAX_GLYPH_SIZE && val->h < MAX_GLYPH_SIZE)
{
if (cache->total + val->w * val->h > MAX_CACHE_SIZE)
- fz_evict_glyph_cache(cache);
+ fz_evict_glyph_cache(ctx, cache);
fz_keep_font(key.font);
- fz_hash_insert(cache->hash, &key, val);
+ fz_hash_insert(ctx, cache->hash, &key, val);
cache->total += val->w * val->h;
return fz_keep_pixmap(val);
}
diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c
index 4254cb64..6df30307 100644
--- a/draw/draw_mesh.c
+++ b/draw/draw_mesh.c
@@ -520,7 +520,7 @@ fz_paint_mesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
}
void
-fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
+fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
{
unsigned char clut[256][FZ_MAX_COLORS];
fz_pixmap *temp, *conv;
@@ -538,8 +538,8 @@ fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
clut[i][k] = color[k] * 255;
clut[i][k] = shade->function[i][shade->colorspace->n] * 255;
}
- conv = fz_new_pixmap_with_rect(dest->colorspace, bbox);
- temp = fz_new_pixmap_with_rect(fz_device_gray, bbox);
+ conv = fz_new_pixmap_with_rect(ctx, dest->colorspace, bbox);
+ temp = fz_new_pixmap_with_rect(ctx, fz_device_gray, bbox);
fz_clear_pixmap(temp);
}
else
@@ -568,7 +568,7 @@ fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
*d++ = a;
}
fz_paint_pixmap(dest, conv, 255);
- fz_drop_pixmap(conv);
- fz_drop_pixmap(temp);
+ fz_drop_pixmap(ctx, conv);
+ fz_drop_pixmap(ctx, temp);
}
}
diff --git a/draw/draw_scale.c b/draw/draw_scale.c
index 427512ce..045de810 100644
--- a/draw/draw_scale.c
+++ b/draw/draw_scale.c
@@ -256,7 +256,7 @@ struct fz_weights_s
};
static fz_weights *
-new_weights(fz_scale_filter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip)
+new_weights(fz_context *ctx, fz_scale_filter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip)
{
int max_len;
fz_weights *weights;
@@ -282,7 +282,7 @@ new_weights(fz_scale_filter *filter, int src_w, float dst_w, int dst_w_i, int n,
* plus (2+max_len)*sizeof(int) for the weights
* plus room for an extra set of weights for reordering.
*/
- weights = fz_malloc(sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int));
+ weights = fz_malloc(ctx, sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int));
if (weights == NULL)
return NULL;
weights->count = -1;
@@ -490,7 +490,7 @@ check_weights(fz_weights *weights, int j, int w, float x, float wf)
}
static fz_weights *
-make_weights(int src_w, float x, float dst_w, fz_scale_filter *filter, int vertical, int dst_w_int, int n, int flip)
+make_weights(fz_context *ctx, int src_w, float x, float dst_w, fz_scale_filter *filter, int vertical, int dst_w_int, int n, int flip)
{
fz_weights *weights;
float F, G;
@@ -511,7 +511,7 @@ make_weights(int src_w, float x, float dst_w, fz_scale_filter *filter, int verti
}
window = filter->width / F;
DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window));
- weights = new_weights(filter, src_w, dst_w, dst_w_int, n, flip);
+ weights = new_weights(ctx, filter, src_w, dst_w, dst_w_int, n, flip);
if (weights == NULL)
return NULL;
for (j = 0; j < dst_w_int; j++)
@@ -1005,7 +1005,7 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in
#endif /* SINGLE_PIXEL_SPECIALS */
fz_pixmap *
-fz_scale_pixmap_gridfit(fz_pixmap *src, float x, float y, float w, float h, int gridfit)
+fz_scale_pixmap_gridfit(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, int gridfit)
{
if (gridfit) {
float n;
@@ -1060,11 +1060,11 @@ fz_scale_pixmap_gridfit(fz_pixmap *src, float x, float y, float w, float h, int
h = n - 1.0f;
}
}
- return fz_scale_pixmap(src, x, y, w, h);
+ return fz_scale_pixmap(ctx, src, x, y, w, h);
}
fz_pixmap *
-fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h)
+fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h)
{
fz_scale_filter *filter = &fz_scale_filter_simple;
fz_weights *contrib_rows = NULL;
@@ -1146,7 +1146,7 @@ fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h)
else
#endif /* SINGLE_PIXEL_SPECIALS */
{
- contrib_cols = make_weights(src->w, x, w, filter, 0, dst_w_int, src->n, flip_x);
+ contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, src->n, flip_x);
if (contrib_cols == NULL)
goto cleanup;
}
@@ -1158,14 +1158,14 @@ fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h)
else
#endif /* SINGLE_PIXEL_SPECIALS */
{
- contrib_rows = make_weights(src->h, y, h, filter, 1, dst_h_int, src->n, flip_y);
+ contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, src->n, flip_y);
if (contrib_rows == NULL)
goto cleanup;
}
assert(contrib_cols == NULL || contrib_cols->count == dst_w_int);
assert(contrib_rows == NULL || contrib_rows->count == dst_h_int);
- output = fz_new_pixmap(src->colorspace, dst_w_int, dst_h_int);
+ output = fz_new_pixmap(ctx, src->colorspace, dst_w_int, dst_h_int);
output->x = dst_x_int;
output->y = dst_y_int;
@@ -1199,7 +1199,7 @@ fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h)
temp_rows = contrib_rows->max_len;
if (temp_span <= 0 || temp_rows > INT_MAX / temp_span)
goto cleanup;
- temp = fz_calloc(temp_span*temp_rows, sizeof(int));
+ temp = fz_calloc(ctx, temp_span*temp_rows, sizeof(int));
if (temp == NULL)
goto cleanup;
switch (src->n)
@@ -1240,11 +1240,11 @@ fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h)
DBUG(("scaling row %d from temp\n", row));
scale_row_from_temp(&output->samples[row*output->w*output->n], temp, contrib_rows, temp_span, row);
}
- fz_free(temp);
+ fz_free(ctx, temp);
}
cleanup:
- fz_free(contrib_rows);
- fz_free(contrib_cols);
+ fz_free(ctx, contrib_rows);
+ fz_free(ctx, contrib_cols);
return output;
}