summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-06-25 13:15:50 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-07-05 15:32:34 +0200
commit4a99615a609eec2b84bb2341d74fac46a5998137 (patch)
tree486eacff07448e4c655df1fa1bcb20df709dd8df /include
parent2aa62902447760764e7a763dea322145d9c4808c (diff)
downloadmupdf-4a99615a609eec2b84bb2341d74fac46a5998137.tar.xz
Pass rect and matrix by value in geometry functions.
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/annotation.h2
-rw-r--r--include/mupdf/fitz/display-list.h4
-rw-r--r--include/mupdf/fitz/document.h6
-rw-r--r--include/mupdf/fitz/font.h4
-rw-r--r--include/mupdf/fitz/geometry.h110
-rw-r--r--include/mupdf/fitz/glyph.h4
-rw-r--r--include/mupdf/fitz/link.h2
-rw-r--r--include/mupdf/fitz/path.h6
-rw-r--r--include/mupdf/fitz/pixmap.h16
-rw-r--r--include/mupdf/fitz/shade.h4
-rw-r--r--include/mupdf/fitz/structured-text.h2
-rw-r--r--include/mupdf/fitz/text.h4
-rw-r--r--include/mupdf/pdf/annot.h8
-rw-r--r--include/mupdf/pdf/document.h2
-rw-r--r--include/mupdf/pdf/object.h12
-rw-r--r--include/mupdf/pdf/page.h2
-rw-r--r--include/mupdf/pdf/resource.h8
-rw-r--r--include/mupdf/pdf/widget.h2
18 files changed, 86 insertions, 112 deletions
diff --git a/include/mupdf/fitz/annotation.h b/include/mupdf/fitz/annotation.h
index 8f7385f6..e7efb4cd 100644
--- a/include/mupdf/fitz/annotation.h
+++ b/include/mupdf/fitz/annotation.h
@@ -38,6 +38,6 @@ fz_annot *fz_next_annot(fz_context *ctx, fz_annot *annot);
/*
fz_bound_annot: Return the bounding rectangle of the annotation.
*/
-fz_rect *fz_bound_annot(fz_context *ctx, fz_annot *annot, fz_rect *rect);
+fz_rect fz_bound_annot(fz_context *ctx, fz_annot *annot);
#endif
diff --git a/include/mupdf/fitz/display-list.h b/include/mupdf/fitz/display-list.h
index b6a23e43..02bb4e4a 100644
--- a/include/mupdf/fitz/display-list.h
+++ b/include/mupdf/fitz/display-list.h
@@ -32,7 +32,7 @@ typedef struct fz_display_list_s fz_display_list;
mediabox: Bounds of the page (in points) represented by the display list.
*/
-fz_display_list *fz_new_display_list(fz_context *ctx, const fz_rect *mediabox);
+fz_display_list *fz_new_display_list(fz_context *ctx, fz_rect mediabox);
/*
fz_new_list_device: Create a rendering device for a display list.
@@ -89,7 +89,7 @@ void fz_drop_display_list(fz_context *ctx, fz_display_list *list);
/*
fz_bound_display_list: Return the bounding box of the page recorded in a display list.
*/
-fz_rect *fz_bound_display_list(fz_context *ctx, fz_display_list *list, fz_rect *bounds);
+fz_rect fz_bound_display_list(fz_context *ctx, fz_display_list *list);
/*
Create a new image from a display list.
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 95e59632..9920a054 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -127,7 +127,7 @@ typedef void (fz_page_drop_page_fn)(fz_context *ctx, fz_page *page);
bounding box of a page. See fz_bound_page for more
information.
*/
-typedef fz_rect *(fz_page_bound_page_fn)(fz_context *ctx, fz_page *page, fz_rect *);
+typedef fz_rect (fz_page_bound_page_fn)(fz_context *ctx, fz_page *page);
/*
fz_page_run_page_contents_fn: Type for a function to run the
@@ -186,7 +186,7 @@ typedef int (fz_page_uses_overprint_fn)(fz_context *ctx, fz_page *page);
typedef void (fz_annot_drop_fn)(fz_context *ctx, fz_annot *annot);
typedef fz_annot *(fz_annot_next_fn)(fz_context *ctx, fz_annot *annot);
-typedef fz_rect *(fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot, fz_rect *rect);
+typedef fz_rect (fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot);
typedef void (fz_annot_run_fn)(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
/*
@@ -469,7 +469,7 @@ fz_page *fz_new_page_of_size(fz_context *ctx, int size);
fz_bound_page: Determine the size of a page at 72 dpi.
*/
-fz_rect *fz_bound_page(fz_context *ctx, fz_page *page, fz_rect *rect);
+fz_rect fz_bound_page(fz_context *ctx, fz_page *page);
/*
fz_run_page: Run a page through a device.
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index aa6d4dd5..13c2bf65 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -372,7 +372,7 @@ fz_font *fz_load_fallback_font(fz_context *ctx, int script, int language, int se
Returns a new font handle, or throws exception on
allocation failure.
*/
-fz_font *fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix);
+fz_font *fz_new_type3_font(fz_context *ctx, const char *name, fz_matrix matrix);
/*
fz_new_font_from_memory: Create a new font from a font
@@ -468,7 +468,7 @@ void fz_set_font_bbox(fz_context *ctx, fz_font *font, float xmin, float ymin, fl
Returns r, after filling it in with the bounds of the given glyph.
*/
-fz_rect *fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_rect *r);
+fz_rect fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm);
/*
fz_glyph_cacheable: Determine if a given glyph in a font
diff --git a/include/mupdf/fitz/geometry.h b/include/mupdf/fitz/geometry.h
index 9127c34f..f44b4f6c 100644
--- a/include/mupdf/fitz/geometry.h
+++ b/include/mupdf/fitz/geometry.h
@@ -163,22 +163,6 @@ static inline fz_rect fz_make_rect(float x0, float y0, float x1, float y1)
}
/*
- fz_rect_min: get the minimum point from a rectangle as a fz_point.
-*/
-static inline fz_point *fz_rect_min(fz_rect *f)
-{
- return (fz_point *)&f->x0;
-}
-
-/*
- fz_rect_max: get the maximum point from a rectangle as a fz_point.
-*/
-static inline fz_point *fz_rect_max(fz_rect *f)
-{
- return (fz_point *)&f->x1;
-}
-
-/*
fz_irect is a rectangle using integers instead of floats.
It's used in the draw device and for pixmap dimensions.
@@ -226,16 +210,14 @@ extern const fz_irect fz_infinite_irect;
An empty rectangle is defined as one whose area is zero.
*/
-static inline int
-fz_is_empty_rect(const fz_rect *r)
+static inline int fz_is_empty_rect(fz_rect r)
{
- return ((r)->x0 == (r)->x1 || (r)->y0 == (r)->y1);
+ return (r.x0 == r.x1 || r.y0 == r.y1);
}
-static inline int
-fz_is_empty_irect(const fz_irect *r)
+static inline int fz_is_empty_irect(fz_irect r)
{
- return ((r)->x0 == (r)->x1 || (r)->y0 == (r)->y1);
+ return (r.x0 == r.x1 || r.y0 == r.y1);
}
/*
@@ -244,10 +226,9 @@ fz_is_empty_irect(const fz_irect *r)
An infinite rectangle is defined as one where either of the
two relationships between corner coordinates are not true.
*/
-static inline int
-fz_is_infinite_rect(const fz_rect *r)
+static inline int fz_is_infinite_rect(fz_rect r)
{
- return ((r)->x0 > (r)->x1 || (r)->y0 > (r)->y1);
+ return (r.x0 > r.x1 || r.y0 > r.y1);
}
/*
@@ -257,10 +238,9 @@ fz_is_infinite_rect(const fz_rect *r)
An infinite rectangle is defined as one where either of the
two relationships between corner coordinates are not true.
*/
-static inline int
-fz_is_infinite_irect(const fz_irect *r)
+static inline int fz_is_infinite_irect(fz_irect r)
{
- return ((r)->x0 > (r)->x1 || (r)->y0 > (r)->y1);
+ return (r.x0 > r.x1 || r.y0 > r.y1);
}
/*
@@ -293,12 +273,6 @@ static inline fz_matrix fz_make_matrix(float a, float b, float c, float d, float
return m;
}
-static inline fz_matrix *fz_copy_matrix(fz_matrix *FZ_RESTRICT m, const fz_matrix *FZ_RESTRICT s)
-{
- *m = *s;
- return m;
-}
-
/*
fz_concat: Multiply two matrices.
@@ -307,7 +281,7 @@ static inline fz_matrix *fz_copy_matrix(fz_matrix *FZ_RESTRICT m, const fz_matri
Returns result.
*/
-fz_matrix *fz_concat(fz_matrix *result, const fz_matrix *left, const fz_matrix *right);
+fz_matrix fz_concat(fz_matrix left, fz_matrix right);
/*
fz_scale: Create a scaling matrix.
@@ -322,7 +296,7 @@ fz_matrix *fz_concat(fz_matrix *result, const fz_matrix *left, const fz_matrix *
Returns m.
*/
-fz_matrix *fz_scale(fz_matrix *m, float sx, float sy);
+fz_matrix fz_scale(float sx, float sy);
/*
fz_pre_scale: Scale a matrix by premultiplication.
@@ -335,7 +309,7 @@ fz_matrix *fz_scale(fz_matrix *m, float sx, float sy);
Returns m (updated).
*/
-fz_matrix *fz_pre_scale(fz_matrix *m, float sx, float sy);
+fz_matrix fz_pre_scale(fz_matrix m, float sx, float sy);
/*
fz_post_scale: Scale a matrix by postmultiplication.
@@ -348,7 +322,7 @@ fz_matrix *fz_pre_scale(fz_matrix *m, float sx, float sy);
Returns m (updated).
*/
-fz_matrix *fz_post_scale(fz_matrix *m, float sx, float sy);
+fz_matrix fz_post_scale(fz_matrix m, float sx, float sy);
/*
fz_shear: Create a shearing matrix.
@@ -362,7 +336,7 @@ fz_matrix *fz_post_scale(fz_matrix *m, float sx, float sy);
Returns m.
*/
-fz_matrix *fz_shear(fz_matrix *m, float sx, float sy);
+fz_matrix fz_shear(float sx, float sy);
/*
fz_pre_shear: Premultiply a matrix with a shearing matrix.
@@ -376,7 +350,7 @@ fz_matrix *fz_shear(fz_matrix *m, float sx, float sy);
Returns m (updated).
*/
-fz_matrix *fz_pre_shear(fz_matrix *m, float sx, float sy);
+fz_matrix fz_pre_shear(fz_matrix m, float sx, float sy);
/*
fz_rotate: Create a rotation matrix.
@@ -391,7 +365,7 @@ fz_matrix *fz_pre_shear(fz_matrix *m, float sx, float sy);
Returns m.
*/
-fz_matrix *fz_rotate(fz_matrix *m, float degrees);
+fz_matrix fz_rotate(float degrees);
/*
fz_pre_rotate: Rotate a transformation by premultiplying.
@@ -406,7 +380,7 @@ fz_matrix *fz_rotate(fz_matrix *m, float degrees);
Returns m (updated).
*/
-fz_matrix *fz_pre_rotate(fz_matrix *m, float degrees);
+fz_matrix fz_pre_rotate(fz_matrix m, float degrees);
/*
fz_translate: Create a translation matrix.
@@ -421,7 +395,7 @@ fz_matrix *fz_pre_rotate(fz_matrix *m, float degrees);
Returns m.
*/
-fz_matrix *fz_translate(fz_matrix *m, float tx, float ty);
+fz_matrix fz_translate(float tx, float ty);
/*
fz_pre_translate: Translate a matrix by premultiplication.
@@ -434,7 +408,7 @@ fz_matrix *fz_translate(fz_matrix *m, float tx, float ty);
Returns m.
*/
-fz_matrix *fz_pre_translate(fz_matrix *m, float tx, float ty);
+fz_matrix fz_pre_translate(fz_matrix m, float tx, float ty);
/*
fz_invert_matrix: Create an inverse matrix.
@@ -447,7 +421,7 @@ fz_matrix *fz_pre_translate(fz_matrix *m, float tx, float ty);
Returns inverse.
*/
-fz_matrix *fz_invert_matrix(fz_matrix *inverse, const fz_matrix *matrix);
+fz_matrix fz_invert_matrix(fz_matrix matrix);
/*
fz_try_invert_matrix: Attempt to create an inverse matrix.
@@ -459,7 +433,7 @@ fz_matrix *fz_invert_matrix(fz_matrix *inverse, const fz_matrix *matrix);
Returns 1 if matrix is degenerate (singular), or 0 otherwise.
*/
- int fz_try_invert_matrix(fz_matrix *inverse, const fz_matrix *matrix);
+int fz_try_invert_matrix(fz_matrix *inv, fz_matrix src);
/*
fz_is_rectilinear: Check if a transformation is rectilinear.
@@ -469,12 +443,12 @@ fz_matrix *fz_invert_matrix(fz_matrix *inverse, const fz_matrix *matrix);
is used to make sure that axis-aligned rectangles before the
transformation are still axis-aligned rectangles afterwards.
*/
-int fz_is_rectilinear(const fz_matrix *m);
+int fz_is_rectilinear(fz_matrix m);
/*
fz_matrix_expansion: Calculate average scaling factor of matrix.
*/
-float fz_matrix_expansion(const fz_matrix *m); /* sumatrapdf */
+float fz_matrix_expansion(fz_matrix m);
/*
fz_intersect_rect: Compute intersection of two rectangles.
@@ -487,7 +461,7 @@ float fz_matrix_expansion(const fz_matrix *m); /* sumatrapdf */
Should both rectangles be infinite, then the intersection is
also infinite.
*/
-fz_rect *fz_intersect_rect(fz_rect *FZ_RESTRICT a, const fz_rect *FZ_RESTRICT b);
+fz_rect fz_intersect_rect(fz_rect a, fz_rect b);
/*
fz_intersect_irect: Compute intersection of two bounding boxes.
@@ -495,7 +469,7 @@ fz_rect *fz_intersect_rect(fz_rect *FZ_RESTRICT a, const fz_rect *FZ_RESTRICT b)
Similar to fz_intersect_rect but operates on two bounding
boxes instead of two rectangles.
*/
-fz_irect *fz_intersect_irect(fz_irect *FZ_RESTRICT a, const fz_irect *FZ_RESTRICT b);
+fz_irect fz_intersect_irect(fz_irect a, fz_irect b);
/*
fz_union_rect: Compute union of two rectangles.
@@ -507,7 +481,7 @@ fz_irect *fz_intersect_irect(fz_irect *FZ_RESTRICT a, const fz_irect *FZ_RESTRIC
non-empty rectangle. Should both rectangles be empty, then the
union is also empty.
*/
-fz_rect *fz_union_rect(fz_rect *FZ_RESTRICT a, const fz_rect *FZ_RESTRICT b);
+fz_rect fz_union_rect(fz_rect a, fz_rect b);
/*
fz_irect_from_rect: Convert a rect into the minimal bounding box
@@ -525,7 +499,7 @@ fz_rect *fz_union_rect(fz_rect *FZ_RESTRICT a, const fz_rect *FZ_RESTRICT b);
Returns bbox (updated).
*/
-fz_irect *fz_irect_from_rect(fz_irect *FZ_RESTRICT bbox, const fz_rect *FZ_RESTRICT rect);
+fz_irect fz_irect_from_rect(fz_rect rect);
/*
fz_round_rect: Round rectangle coordinates.
@@ -541,7 +515,7 @@ fz_irect *fz_irect_from_rect(fz_irect *FZ_RESTRICT bbox, const fz_rect *FZ_RESTR
allows for a small amount of rounding error when calculating
the bbox.
*/
-fz_irect *fz_round_rect(fz_irect *FZ_RESTRICT bbox, const fz_rect *FZ_RESTRICT rect);
+fz_irect fz_round_rect(fz_rect rect);
/*
fz_rect_from_irect: Convert a bbox into a rect.
@@ -555,13 +529,13 @@ fz_irect *fz_round_rect(fz_irect *FZ_RESTRICT bbox, const fz_rect *FZ_RESTRICT r
Returns rect (updated).
*/
-fz_rect *fz_rect_from_irect(fz_rect *FZ_RESTRICT rect, const fz_irect *FZ_RESTRICT bbox);
+fz_rect fz_rect_from_irect(fz_irect bbox);
/*
fz_expand_rect: Expand a bbox by a given amount in all directions.
*/
-fz_rect *fz_expand_rect(fz_rect *b, float expand);
-fz_irect *fz_expand_irect(fz_irect *a, int expand);
+fz_rect fz_expand_rect(fz_rect b, float expand);
+fz_irect fz_expand_irect(fz_irect a, int expand);
/*
fz_include_point_in_rect: Expand a bbox to include a given point.
@@ -569,22 +543,22 @@ fz_irect *fz_expand_irect(fz_irect *a, int expand);
rectangle must first be set to be the empty rectangle at one of
the points before including the others.
*/
-fz_rect *fz_include_point_in_rect(fz_rect *r, const fz_point *p);
+fz_rect fz_include_point_in_rect(fz_rect r, fz_point p);
/*
fz_translate_irect: Translate bounding box.
Translate a bbox by a given x and y offset. Allows for overflow.
*/
-fz_rect *fz_translate_rect(fz_rect *a, float xoff, float yoff);
-fz_irect *fz_translate_irect(fz_irect *a, int xoff, int yoff);
+fz_rect fz_translate_rect(fz_rect a, float xoff, float yoff);
+fz_irect fz_translate_irect(fz_irect a, int xoff, int yoff);
/*
fz_contains_rect: Test rectangle inclusion.
Return true if a entirely contains b.
*/
-int fz_contains_rect(const fz_rect *a, const fz_rect *b);
+int fz_contains_rect(fz_rect a, fz_rect b);
/*
fz_transform_point: Apply a transformation to a point.
@@ -597,8 +571,8 @@ int fz_contains_rect(const fz_rect *a, const fz_rect *b);
Returns transform (unchanged).
*/
-fz_point *fz_transform_point(fz_point *FZ_RESTRICT point, const fz_matrix *FZ_RESTRICT transform);
-fz_point *fz_transform_point_xy(fz_point *FZ_RESTRICT point, const fz_matrix *FZ_RESTRICT transform, float x, float y);
+fz_point fz_transform_point(fz_point point, fz_matrix m);
+fz_point fz_transform_point_xy(float x, float y, fz_matrix m);
/*
fz_transform_vector: Apply a transformation to a vector.
@@ -609,7 +583,7 @@ fz_point *fz_transform_point_xy(fz_point *FZ_RESTRICT point, const fz_matrix *FZ
vector: Pointer to vector to update.
*/
-fz_point *fz_transform_vector(fz_point *FZ_RESTRICT vector, const fz_matrix *FZ_RESTRICT transform);
+fz_point fz_transform_vector(fz_point vector, fz_matrix m);
/*
fz_transform_rect: Apply a transform to a rectangle.
@@ -626,16 +600,16 @@ fz_point *fz_transform_vector(fz_point *FZ_RESTRICT vector, const fz_matrix *FZ_
fz_empty_rect and fz_infinite_rect, may be used but are
returned unchanged as expected.
*/
-fz_rect *fz_transform_rect(fz_rect *FZ_RESTRICT rect, const fz_matrix *FZ_RESTRICT transform);
+fz_rect fz_transform_rect(fz_rect rect, fz_matrix m);
/*
fz_normalize_vector: Normalize a vector to length one.
*/
-void fz_normalize_vector(fz_point *p);
+fz_point fz_normalize_vector(fz_point p);
-void fz_gridfit_matrix(int as_tiled, fz_matrix *m);
+fz_matrix fz_gridfit_matrix(int as_tiled, fz_matrix m);
-float fz_matrix_max_expansion(const fz_matrix *m);
+float fz_matrix_max_expansion(fz_matrix m);
typedef struct fz_quad_s fz_quad;
struct fz_quad_s
@@ -644,7 +618,7 @@ struct fz_quad_s
};
fz_rect fz_rect_from_quad(fz_quad q);
-fz_quad *fz_transform_quad(fz_quad *q, const fz_matrix *m);
+fz_quad fz_transform_quad(fz_quad q, fz_matrix m);
int fz_is_point_inside_rect(fz_point p, fz_rect r);
int fz_is_point_inside_irect(int x, int y, fz_irect r);
diff --git a/include/mupdf/fitz/glyph.h b/include/mupdf/fitz/glyph.h
index 4b2bfdbb..1f697e5e 100644
--- a/include/mupdf/fitz/glyph.h
+++ b/include/mupdf/fitz/glyph.h
@@ -16,7 +16,7 @@ typedef struct fz_glyph_s fz_glyph;
/*
fz_glyph_bbox: Return the bounding box for a glyph.
*/
-fz_irect *fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph, fz_irect *bbox);
+fz_irect fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph);
/*
fz_glyph_width: Return the width of the glyph in pixels.
@@ -120,7 +120,7 @@ struct fz_glyph_s
unsigned char data[1];
};
-fz_irect *fz_glyph_bbox_no_ctx(fz_glyph *src, fz_irect *bbox);
+fz_irect fz_glyph_bbox_no_ctx(fz_glyph *src);
static inline size_t
fz_glyph_size(fz_context *ctx, fz_glyph *glyph)
diff --git a/include/mupdf/fitz/link.h b/include/mupdf/fitz/link.h
index 3aa5116f..af1461ce 100644
--- a/include/mupdf/fitz/link.h
+++ b/include/mupdf/fitz/link.h
@@ -39,7 +39,7 @@ struct fz_link_s
char *uri;
};
-fz_link *fz_new_link(fz_context *ctx, const fz_rect *bbox, void *doc, const char *uri);
+fz_link *fz_new_link(fz_context *ctx, fz_rect bbox, void *doc, const char *uri);
fz_link *fz_keep_link(fz_context *ctx, fz_link *link);
/*
diff --git a/include/mupdf/fitz/path.h b/include/mupdf/fitz/path.h
index 47e80841..aac7232d 100644
--- a/include/mupdf/fitz/path.h
+++ b/include/mupdf/fitz/path.h
@@ -323,7 +323,7 @@ void fz_closepath(fz_context *ctx, fz_path *path);
Throws exceptions if the path is packed, or on failure
to allocate.
*/
-void fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *transform);
+void fz_transform_path(fz_context *ctx, fz_path *path, fz_matrix transform);
/*
fz_bound_path: Return a bounding rectangle for a path.
@@ -341,8 +341,8 @@ void fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *transfor
Returns r, updated to contain the bounding rectangle.
*/
-fz_rect *fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r);
-fz_rect *fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm);
+fz_rect fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, fz_matrix ctm);
+fz_rect fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect rect, const fz_stroke_state *stroke, fz_matrix ctm);
extern const fz_stroke_state fz_default_stroke_state;
diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h
index 050f5aba..18e01790 100644
--- a/include/mupdf/fitz/pixmap.h
+++ b/include/mupdf/fitz/pixmap.h
@@ -21,7 +21,7 @@ typedef struct fz_overprint_s fz_overprint;
/*
fz_pixmap_bbox: Return the bounding box for a pixmap.
*/
-fz_irect *fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix, fz_irect *bbox);
+fz_irect fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix);
/*
fz_pixmap_width: Return the width of the pixmap in pixels.
@@ -83,7 +83,7 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, fz_se
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *bbox, fz_separations *seps, int alpha);
+fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha);
/*
fz_new_pixmap_with_data: Create a new pixmap, with its origin at
@@ -133,7 +133,7 @@ fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, i
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *rect, fz_separations *seps, int alpha, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect rect, fz_separations *seps, int alpha, unsigned char *samples);
/*
fz_new_pixmap_from_pixmap: Create a new pixmap that represents
@@ -244,7 +244,7 @@ void fz_fill_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, fz_colorspace *c
r: the rectangle.
*/
-void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, const fz_irect *r);
+void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_irect r);
/*
fz_clear_pixmap_with_value: Sets all components (including alpha) of
@@ -274,7 +274,7 @@ void fz_tint_pixmap(fz_context *ctx, fz_pixmap *pix, int r, int g, int b);
pixmap. All components of all pixels in the rectangle are inverted
(except alpha, which is unchanged).
*/
-void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, const fz_irect *rect);
+void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, fz_irect rect);
/*
fz_gamma_pixmap: Apply gamma correction to a pixmap. All components
@@ -367,12 +367,12 @@ enum
void fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix);
-void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_irect *r, const fz_default_colorspaces *default_cs);
+void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect r, const fz_default_colorspaces *default_cs);
void fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix);
fz_pixmap *fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray);
size_t fz_pixmap_size(fz_context *ctx, fz_pixmap *pix);
-fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_irect *clip);
+fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip);
typedef struct fz_scale_cache_s fz_scale_cache;
@@ -382,7 +382,7 @@ fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, const fz_pixmap *src, float x
void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor);
-fz_irect *fz_pixmap_bbox_no_ctx(const fz_pixmap *src, fz_irect *bbox);
+fz_irect fz_pixmap_bbox_no_ctx(const fz_pixmap *src);
void fz_decode_tile(fz_context *ctx, fz_pixmap *pix, const float *decode);
void fz_decode_indexed_tile(fz_context *ctx, fz_pixmap *pix, const float *decode, int maxval);
diff --git a/include/mupdf/fitz/shade.h b/include/mupdf/fitz/shade.h
index 24cb4cb2..7b821a34 100644
--- a/include/mupdf/fitz/shade.h
+++ b/include/mupdf/fitz/shade.h
@@ -115,7 +115,7 @@ void fz_drop_shade_imp(fz_context *ctx, fz_storable *shade);
Returns r, updated to contain the bounds for the shading.
*/
-fz_rect *fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_rect *r);
+fz_rect fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm);
/*
fz_paint_shade: Render a shade to a given pixmap.
@@ -194,7 +194,7 @@ typedef void (fz_shade_process_fn)(fz_context *ctx, void *arg, fz_vertex *av, fz
process_arg: An opaque argument passed through from caller
to callback functions.
*/
-void fz_process_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
+void fz_process_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm,
fz_shade_prepare_fn *prepare,
fz_shade_process_fn *process,
void *process_arg);
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h
index 2adfa73a..67dde472 100644
--- a/include/mupdf/fitz/structured-text.h
+++ b/include/mupdf/fitz/structured-text.h
@@ -111,7 +111,7 @@ extern const char *fz_stext_options_usage;
mediabox: optional mediabox information.
*/
-fz_stext_page *fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox);
+fz_stext_page *fz_new_stext_page(fz_context *ctx, fz_rect mediabox);
void fz_drop_stext_page(fz_context *ctx, fz_stext_page *page);
/*
diff --git a/include/mupdf/fitz/text.h b/include/mupdf/fitz/text.h
index d2b9d21f..cce357ae 100644
--- a/include/mupdf/fitz/text.h
+++ b/include/mupdf/fitz/text.h
@@ -113,7 +113,7 @@ void fz_drop_text(fz_context *ctx, const fz_text *text);
Throws exception on failure to allocate.
*/
-void fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int glyph, int unicode, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language);
+void fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix trm, int glyph, int unicode, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language);
/*
fz_show_string: Add a UTF8 string to a text object.
@@ -156,7 +156,7 @@ void fz_show_string(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix *tr
Returns a pointer to r, which is updated to contain the
bounding box for the text object.
*/
-fz_rect *fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r);
+fz_rect fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm);
/*
Convert ISO 639 (639-{1,2,3,5}) language specification
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index bd4e8722..1e9361fd 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -87,7 +87,7 @@ pdf_annot *pdf_next_annot(fz_context *ctx, pdf_annot *annot);
/*
pdf_bound_annot: Return the rectangle for an annotation on a page.
*/
-fz_rect *pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect);
+fz_rect pdf_bound_annot(fz_context *ctx, pdf_annot *annot);
/*
pdf_annot_type: Return the type of an annotation
@@ -132,7 +132,7 @@ pdf_obj *pdf_load_name_tree(fz_context *ctx, pdf_document *doc, pdf_obj *which);
int pdf_resolve_link(fz_context *ctx, pdf_document *doc, const char *uri, float *xp, float *yp);
fz_link *pdf_load_link_annots(fz_context *ctx, pdf_document *, pdf_obj *annots, int pagenum, const fz_matrix *page_ctm);
-void pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm);
+fz_matrix pdf_annot_transform(fz_context *ctx, pdf_annot *annot);
void pdf_load_annots(fz_context *ctx, pdf_page *page, pdf_obj *annots);
void pdf_update_annot(fz_context *ctx, pdf_annot *annot);
void pdf_drop_annots(fz_context *ctx, pdf_annot *annot_list);
@@ -160,7 +160,7 @@ int pdf_annot_has_open(fz_context *ctx, pdf_annot *annot);
int pdf_annot_has_author(fz_context *ctx, pdf_annot *annot);
int pdf_annot_flags(fz_context *ctx, pdf_annot *annot);
-void pdf_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect *rect);
+fz_rect pdf_annot_rect(fz_context *ctx, pdf_annot *annot);
float pdf_annot_border(fz_context *ctx, pdf_annot *annot);
float pdf_annot_opacity(fz_context *ctx, pdf_annot *annot);
void pdf_annot_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4]);
@@ -178,7 +178,7 @@ int pdf_annot_ink_list_stroke_count(fz_context *ctx, pdf_annot *annot, int i);
fz_point pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k);
void pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags);
-void pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect);
+void pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect rect);
void pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float width);
void pdf_set_annot_opacity(fz_context *ctx, pdf_annot *annot, float opacity);
void pdf_set_annot_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]);
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index 57e726d3..4ca9a3a8 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -822,7 +822,7 @@ fz_device *pdf_page_write(fz_context *ctx, pdf_document *doc, const fz_rect *med
contents: The page contents for the new page (typically
create by pdf_page_write).
*/
-pdf_obj *pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int rotate, pdf_obj *resources, fz_buffer *contents);
+pdf_obj *pdf_add_page(fz_context *ctx, pdf_document *doc, fz_rect mediabox, int rotate, pdf_obj *resources, fz_buffer *contents);
/*
pdf_insert_page: Insert a page previously created by
diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h
index 71a8d9d8..e4a9b313 100644
--- a/include/mupdf/pdf/object.h
+++ b/include/mupdf/pdf/object.h
@@ -23,8 +23,8 @@ pdf_obj *pdf_new_text_string(fz_context *ctx, const char *s);
pdf_obj *pdf_new_indirect(fz_context *ctx, pdf_document *doc, int num, int gen);
pdf_obj *pdf_new_array(fz_context *ctx, pdf_document *doc, int initialcap);
pdf_obj *pdf_new_dict(fz_context *ctx, pdf_document *doc, int initialcap);
-pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, const fz_rect *rect);
-pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, const fz_matrix *mtx);
+pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, fz_rect rect);
+pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, fz_matrix mtx);
pdf_obj *pdf_copy_array(fz_context *ctx, pdf_obj *array);
pdf_obj *pdf_copy_dict(fz_context *ctx, pdf_obj *dict);
pdf_obj *pdf_deep_copy_obj(fz_context *ctx, pdf_obj *obj);
@@ -127,8 +127,8 @@ void pdf_dict_put_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key, double x);
void pdf_dict_put_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
void pdf_dict_put_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x, size_t n);
void pdf_dict_put_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
-void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_rect *x);
-void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_matrix *x);
+void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_rect x);
+void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_matrix x);
pdf_obj *pdf_dict_put_array(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial);
pdf_obj *pdf_dict_put_dict(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial);
@@ -178,8 +178,8 @@ char *pdf_new_utf8_from_pdf_string_obj(fz_context *ctx, pdf_obj *src);
char *pdf_new_utf8_from_pdf_stream_obj(fz_context *ctx, pdf_obj *src);
char *pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src);
-fz_rect *pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *rect);
-fz_matrix *pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *mat);
+fz_rect pdf_to_rect(fz_context *ctx, pdf_obj *array);
+fz_matrix pdf_to_matrix(fz_context *ctx, pdf_obj *array);
pdf_document *pdf_get_indirect_document(fz_context *ctx, pdf_obj *obj);
pdf_document *pdf_get_bound_document(fz_context *ctx, pdf_obj *obj);
diff --git a/include/mupdf/pdf/page.h b/include/mupdf/pdf/page.h
index bd0cec9d..25043b1d 100644
--- a/include/mupdf/pdf/page.h
+++ b/include/mupdf/pdf/page.h
@@ -58,7 +58,7 @@ fz_link *pdf_load_links(fz_context *ctx, pdf_page *page);
exists (visible area after cropping), otherwise the media box will
be used (possibly including printing marks).
*/
-fz_rect *pdf_bound_page(fz_context *ctx, pdf_page *page, fz_rect *);
+fz_rect pdf_bound_page(fz_context *ctx, pdf_page *page);
/*
pdf_run_page: Interpret a loaded page and render it on a device.
diff --git a/include/mupdf/pdf/resource.h b/include/mupdf/pdf/resource.h
index b6a2a4b5..d8968996 100644
--- a/include/mupdf/pdf/resource.h
+++ b/include/mupdf/pdf/resource.h
@@ -79,12 +79,12 @@ void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat);
* XObject
*/
-pdf_obj *pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const fz_matrix *mat, pdf_obj *res, fz_buffer *buffer);
-void pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *xobj, const fz_rect *bbox, const fz_matrix *mat, pdf_obj *res, fz_buffer *buffer);
+pdf_obj *pdf_new_xobject(fz_context *ctx, pdf_document *doc, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *buffer);
+void pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *xobj, fz_rect bbox, fz_matrix mat, pdf_obj *res, fz_buffer *buffer);
pdf_obj *pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj);
-fz_rect *pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj, fz_rect *bbox);
-fz_matrix *pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj, fz_matrix *matrix);
+fz_rect pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj);
+fz_matrix pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj);
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj);
int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj);
int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj);
diff --git a/include/mupdf/pdf/widget.h b/include/mupdf/pdf/widget.h
index 04c9f887..7e2ae591 100644
--- a/include/mupdf/pdf/widget.h
+++ b/include/mupdf/pdf/widget.h
@@ -65,7 +65,7 @@ int pdf_widget_type(fz_context *ctx, pdf_widget *widget);
/*
pdf_bound_widget: get the bounding box of a widget.
*/
-fz_rect *pdf_bound_widget(fz_context *ctx, pdf_widget *widget, fz_rect *);
+fz_rect pdf_bound_widget(fz_context *ctx, pdf_widget *widget);
/*
pdf_text_widget_text: Get the text currently displayed in