diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-10-23 13:54:44 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-10-24 17:12:13 +0200 |
commit | f0367fc24d95a2172ed0ebb38adc0632de9fb7ce (patch) | |
tree | 0e35507f1dd4a1b1205f85e4ed436410e46444b3 /source/fitz | |
parent | 75e7fd0e6ea72ecfe369030b5d1879b0c594da52 (diff) | |
download | mupdf-f0367fc24d95a2172ed0ebb38adc0632de9fb7ce.tar.xz |
Pass context to fz_paint_image to allow for printing warnings.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/draw-affine.c | 32 | ||||
-rw-r--r-- | source/fitz/draw-device.c | 8 | ||||
-rw-r--r-- | source/fitz/draw-imp.h | 4 |
3 files changed, 29 insertions, 15 deletions
diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c index 1397166a..bf829426 100644 --- a/source/fitz/draw-affine.c +++ b/source/fitz/draw-affine.c @@ -3867,7 +3867,18 @@ fz_gridfit_matrix(int as_tiled, fz_matrix m) /* Draw an image with an affine transform on destination */ static void -fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, const fz_pixmap *img, fz_matrix ctm, const byte *color, int alpha, int lerp_allowed, int as_tiled, const fz_overprint *eop) +fz_paint_image_imp(fz_context *ctx, + fz_pixmap *dst, + const fz_irect *scissor, + fz_pixmap *shape, + fz_pixmap *group_alpha, + fz_pixmap *img, + fz_matrix ctm, + const byte *color, + int alpha, + int lerp_allowed, + int as_tiled, + const fz_overprint *eop) { byte *dp, *sp, *hp, *gp; int u, v, fa, fb, fc, fd; @@ -3978,6 +3989,13 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz gp = NULL; } + /* image size overflows 16.16 fixed point math */ + if (sw >= 32768 || sh >= 32768) + { + fz_warn(ctx, "image too large for fixed point math: %d x %d", sw, sh); + return; + } + /* TODO: if (fb == 0 && fa == 1) call fz_paint_span */ /* Sometimes we can get an alpha only input to be @@ -4043,10 +4061,6 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz if (dolerp) { - /* image size overflows 16.16 fixed point math */ - if (sw >= 32768 || sh >= 32768) - return; - u -= 32768; v -= 32768; sw = (sw<<16) + 32768; @@ -4065,14 +4079,14 @@ fz_paint_image_imp(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz } void -fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, const fz_pixmap *img, fz_matrix ctm, const byte *color, int lerp_allowed, int as_tiled, const fz_overprint *eop) +fz_paint_image_with_color(fz_context *ctx, fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, fz_pixmap *img, fz_matrix ctm, const byte *color, int lerp_allowed, int as_tiled, const fz_overprint *eop) { assert(img->n == 1); - fz_paint_image_imp(dst, scissor, shape, group_alpha, img, ctm, color, 255, lerp_allowed, as_tiled, eop); + fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, color, 255, lerp_allowed, as_tiled, eop); } void -fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, const fz_pixmap *img, fz_matrix ctm, int alpha, int lerp_allowed, int as_tiled, const fz_overprint *eop) +fz_paint_image(fz_context *ctx, fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, fz_pixmap *img, fz_matrix ctm, int alpha, int lerp_allowed, int as_tiled, const fz_overprint *eop) { - fz_paint_image_imp(dst, scissor, shape, group_alpha, img, ctm, NULL, alpha, lerp_allowed, as_tiled, eop); + fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, NULL, alpha, lerp_allowed, as_tiled, eop); } diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 6d530eba..d0946966 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1036,7 +1036,7 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, fz_matr fz_matrix mat; mat.a = pixmap->w; mat.b = mat.c = 0; mat.d = pixmap->h; mat.e = x + pixmap->x; mat.f = y + pixmap->y; - fz_paint_image(state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, mat, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); + fz_paint_image(ctx, state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, mat, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); } fz_drop_glyph(ctx, glyph); } @@ -1815,7 +1815,7 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, fz_matrix pixmap = convert_pixmap_for_painting(ctx, pixmap, model, src_cs, state->dest, color_params, dev, &eop); } - fz_paint_image(state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, local_ctm, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); + fz_paint_image(ctx, state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, local_ctm, alpha * 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); } fz_always(ctx) { @@ -1925,7 +1925,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, fz_ma eop = resolve_color(ctx, &op, color, colorspace, alpha, color_params, colorbv, state->dest); - fz_paint_image_with_color(state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, local_ctm, colorbv, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); + fz_paint_image_with_color(ctx, state->dest, &state->scissor, state->shape, state->group_alpha, pixmap, local_ctm, colorbv, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, eop); if (state->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_end(ctx, dev); @@ -2030,7 +2030,7 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, fz_ma if (state[1].group_alpha) fz_dump_blend(ctx, "/GA=", state[1].group_alpha); #endif - fz_paint_image(state[1].mask, &bbox, state[1].shape, state[1].group_alpha, pixmap, local_ctm, 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, 0); + fz_paint_image(ctx, state[1].mask, &bbox, state[1].shape, state[1].group_alpha, pixmap, local_ctm, 255, !(devp->hints & FZ_DONT_INTERPOLATE_IMAGES), devp->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, 0); #ifdef DUMP_GROUP_BLENDS fz_dump_blend(ctx, " to get ", state[1].mask); if (state[1].shape) diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h index e9d93512..9e09ffbc 100644 --- a/source/fitz/draw-imp.h +++ b/source/fitz/draw-imp.h @@ -454,8 +454,8 @@ fz_solid_color_painter_t *fz_get_solid_color_painter(int n, const unsigned char fz_span_painter_t *fz_get_span_painter(int da, int sa, int n, int alpha, const fz_overprint *eop); fz_span_color_painter_t *fz_get_span_color_painter(int n, int da, const unsigned char *color, const fz_overprint *eop); -void fz_paint_image(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, const fz_pixmap *img, fz_matrix ctm, int alpha, int lerp_allowed, int gridfit_as_tiled, const fz_overprint *eop); -void fz_paint_image_with_color(fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, const fz_pixmap *img, fz_matrix ctm, const unsigned char *colorbv, int lerp_allowed, int gridfit_as_tiled, const fz_overprint *eop); +void fz_paint_image(fz_context *ctx, fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, fz_pixmap *img, fz_matrix ctm, int alpha, int lerp_allowed, int gridfit_as_tiled, const fz_overprint *eop); +void fz_paint_image_with_color(fz_context *ctx, fz_pixmap *dst, const fz_irect *scissor, fz_pixmap *shape, fz_pixmap *group_alpha, fz_pixmap *img, fz_matrix ctm, const unsigned char *colorbv, int lerp_allowed, int gridfit_as_tiled, const fz_overprint *eop); void fz_paint_pixmap(fz_pixmap *dst, const fz_pixmap *src, int alpha); void fz_paint_pixmap_alpha(fz_pixmap *dst, const fz_pixmap *src, int alpha); |