diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-01-21 16:42:45 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-02-17 18:05:39 +0100 |
commit | f84a189d5f94250e46d2cbd1a75aba00130e2dd6 (patch) | |
tree | 8ee614ab90de1baa8941f91ae4946ed5c2e70721 /source/xps/xps-image.c | |
parent | 681039767f2ccc72e236246178893eb0989169c9 (diff) | |
download | mupdf-f84a189d5f94250e46d2cbd1a75aba00130e2dd6.tar.xz |
Add ctx parameter and remove embedded contexts for API regularity.
Purge several embedded contexts:
Remove embedded context in fz_output.
Remove embedded context in fz_stream.
Remove embedded context in fz_device.
Remove fz_rebind_stream (since it is no longer necessary).
Remove embedded context in svg_device.
Remove embedded context in XML parser.
Add ctx argument to fz_document functions.
Remove embedded context in fz_document.
Remove embedded context in pdf_document.
Remove embedded context in pdf_obj.
Make fz_page independent of fz_document in the interface.
We shouldn't need to pass the document to all functions handling a page.
If a page is tied to the source document, it's redundant; otherwise it's
just pointless.
Fix reference counting oddity in fz_new_image_from_pixmap.
Diffstat (limited to 'source/xps/xps-image.c')
-rw-r--r-- | source/xps/xps-image.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/source/xps/xps-image.c b/source/xps/xps-image.c index d9b2ad11..b0d00a2f 100644 --- a/source/xps/xps-image.c +++ b/source/xps/xps-image.c @@ -1,7 +1,7 @@ #include "mupdf/xps.h" static fz_image * -xps_load_image(fz_context *ctx, xps_part *part) +xps_load_image(fz_context *ctx, xps_document *doc, xps_part *part) { /* Ownership of data always passes in here */ unsigned char *data = part->data; @@ -11,7 +11,7 @@ xps_load_image(fz_context *ctx, xps_part *part) /* FIXME: area unused! */ static void -xps_paint_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, +xps_paint_image_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *root, void *vimage) { fz_image *image = vimage; @@ -23,11 +23,11 @@ xps_paint_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *ar xs = image->w * 96 / image->xres; ys = image->h * 96 / image->yres; fz_pre_scale(&local_ctm, xs, ys); - fz_fill_image(doc->dev, image, &local_ctm, doc->opacity[doc->opacity_top]); + fz_fill_image(ctx, doc->dev, image, &local_ctm, doc->opacity[doc->opacity_top]); } static void -xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root, xps_part **image_part, xps_part **profile_part) +xps_find_image_brush_source_part(fz_context *ctx, xps_document *doc, char *base_uri, fz_xml *root, xps_part **image_part, xps_part **profile_part) { char *image_source_att; char buf[1024]; @@ -38,7 +38,7 @@ xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root image_source_att = fz_xml_att(root, "ImageSource"); if (!image_source_att) - fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find image source attribute"); + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find image source attribute"); /* "{ColorConvertedBitmap /Resources/Image.tiff /Resources/Profile.icc}" */ if (strstr(image_source_att, "{ColorConvertedBitmap") == image_source_att) @@ -69,20 +69,20 @@ xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root } if (!image_name) - fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find image source"); + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find image source"); if (image_part) { - xps_resolve_url(partname, base_uri, image_name, sizeof partname); - *image_part = xps_read_part(doc, partname); + xps_resolve_url(ctx, doc, partname, base_uri, image_name, sizeof partname); + *image_part = xps_read_part(ctx, doc, partname); } if (profile_part) { if (profile_name) { - xps_resolve_url(partname, base_uri, profile_name, sizeof partname); - *profile_part = xps_read_part(doc, partname); + xps_resolve_url(ctx, doc, partname, base_uri, profile_name, sizeof partname); + *profile_part = xps_read_part(ctx, doc, partname); } else *profile_part = NULL; @@ -90,40 +90,40 @@ xps_find_image_brush_source_part(xps_document *doc, char *base_uri, fz_xml *root } void -xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, +xps_parse_image_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *root) { xps_part *part; fz_image *image; - fz_try(doc->ctx) + fz_try(ctx) { - xps_find_image_brush_source_part(doc, base_uri, root, &part, NULL); + xps_find_image_brush_source_part(ctx, doc, base_uri, root, &part, NULL); } - fz_catch(doc->ctx) + fz_catch(ctx) { - fz_rethrow_if(doc->ctx, FZ_ERROR_TRYLATER); - fz_warn(doc->ctx, "cannot find image source"); + fz_rethrow_if(ctx, FZ_ERROR_TRYLATER); + fz_warn(ctx, "cannot find image source"); return; } - fz_try(doc->ctx) + fz_try(ctx) { - image = xps_load_image(doc->ctx, part); + image = xps_load_image(ctx, doc, part); image->invert_cmyk_jpeg = 1; } - fz_always(doc->ctx) + fz_always(ctx) { - xps_drop_part(doc, part); + xps_drop_part(ctx, doc, part); } - fz_catch(doc->ctx) + fz_catch(ctx) { - fz_rethrow_if(doc->ctx, FZ_ERROR_TRYLATER); - fz_warn(doc->ctx, "cannot decode image resource"); + fz_rethrow_if(ctx, FZ_ERROR_TRYLATER); + fz_warn(ctx, "cannot decode image resource"); return; } - xps_parse_tiling_brush(doc, ctm, area, base_uri, dict, root, xps_paint_image_brush, image); + xps_parse_tiling_brush(ctx, doc, ctm, area, base_uri, dict, root, xps_paint_image_brush, image); - fz_drop_image(doc->ctx, image); + fz_drop_image(ctx, image); } |