summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--platform/gl/gl-annotate.c66
-rw-r--r--platform/gl/gl-font.c2
-rw-r--r--platform/gl/gl-input.c2
-rw-r--r--platform/gl/gl-main.c54
-rw-r--r--platform/gl/gl-ui.c2
-rw-r--r--platform/java/mupdf_native.c69
-rw-r--r--platform/java/mupdf_native.h4
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/DisplayList.java6
-rw-r--r--platform/x11/pdfapp.c53
-rw-r--r--source/cbz/mucbz.c15
-rw-r--r--source/cbz/muimg.c15
-rw-r--r--source/fitz/bbox-device.c52
-rw-r--r--source/fitz/colorspace.c6
-rw-r--r--source/fitz/device.c18
-rw-r--r--source/fitz/document.c28
-rw-r--r--source/fitz/draw-affine.c185
-rw-r--r--source/fitz/draw-blend.c14
-rw-r--r--source/fitz/draw-device.c347
-rw-r--r--source/fitz/draw-glyph.c2
-rw-r--r--source/fitz/draw-imp.h6
-rw-r--r--source/fitz/draw-mesh.c10
-rw-r--r--source/fitz/draw-paint.c35
-rw-r--r--source/fitz/draw-path.c22
-rw-r--r--source/fitz/draw-rasterize.c60
-rw-r--r--source/fitz/draw-scale-simple.c2
-rw-r--r--source/fitz/font.c73
-rw-r--r--source/fitz/geometry.c571
-rw-r--r--source/fitz/glyph.c26
-rw-r--r--source/fitz/image.c7
-rw-r--r--source/fitz/link.c4
-rw-r--r--source/fitz/list-device.c93
-rw-r--r--source/fitz/path.c127
-rw-r--r--source/fitz/pixmap.c89
-rw-r--r--source/fitz/separation.c2
-rw-r--r--source/fitz/shade.c169
-rw-r--r--source/fitz/stext-device.c76
-rw-r--r--source/fitz/stext-output.c2
-rw-r--r--source/fitz/svg-device.c55
-rw-r--r--source/fitz/test-device.c2
-rw-r--r--source/fitz/text.c49
-rw-r--r--source/fitz/util.c56
-rw-r--r--source/gprf/gprf-skeleton.c2
-rw-r--r--source/html/epub-doc.c18
-rw-r--r--source/html/html-doc.c15
-rw-r--r--source/html/html-imp.h2
-rw-r--r--source/html/html-layout.c42
-rw-r--r--source/pdf/pdf-annot.c103
-rw-r--r--source/pdf/pdf-appearance.c51
-rw-r--r--source/pdf/pdf-device.c22
-rw-r--r--source/pdf/pdf-font.c4
-rw-r--r--source/pdf/pdf-form.c6
-rw-r--r--source/pdf/pdf-interpret.c16
-rw-r--r--source/pdf/pdf-link.c8
-rw-r--r--source/pdf/pdf-object.c28
-rw-r--r--source/pdf/pdf-op-filter.c19
-rw-r--r--source/pdf/pdf-op-run.c59
-rw-r--r--source/pdf/pdf-page.c33
-rw-r--r--source/pdf/pdf-parse.c38
-rw-r--r--source/pdf/pdf-pattern.c7
-rw-r--r--source/pdf/pdf-run.c8
-rw-r--r--source/pdf/pdf-shade.c15
-rw-r--r--source/pdf/pdf-signature.c4
-rw-r--r--source/pdf/pdf-type3.c6
-rw-r--r--source/pdf/pdf-write.c2
-rw-r--r--source/pdf/pdf-xobject.c24
-rw-r--r--source/svg/svg-doc.c10
-rw-r--r--source/svg/svg-parse.c14
-rw-r--r--source/svg/svg-run.c16
-rw-r--r--source/tools/muconvert.c2
-rw-r--r--source/tools/mudraw.c41
-rw-r--r--source/tools/murun.c22
-rw-r--r--source/tools/mutrace.c2
-rw-r--r--source/tools/pdfcreate.c2
-rw-r--r--source/tools/pdfinfo.c2
-rw-r--r--source/tools/pdfpages.c2
-rw-r--r--source/tools/pdfportfolio.c2
-rw-r--r--source/xps/xps-common.c58
-rw-r--r--source/xps/xps-doc.c11
-rw-r--r--source/xps/xps-glyphs.c30
-rw-r--r--source/xps/xps-gradient.c62
-rw-r--r--source/xps/xps-image.c9
-rw-r--r--source/xps/xps-imp.h36
-rw-r--r--source/xps/xps-link.c39
-rw-r--r--source/xps/xps-path.c58
-rw-r--r--source/xps/xps-tile.c103
103 files changed, 1720 insertions, 2007 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
diff --git a/platform/gl/gl-annotate.c b/platform/gl/gl-annotate.c
index 92458824..dca7519a 100644
--- a/platform/gl/gl-annotate.c
+++ b/platform/gl/gl-annotate.c
@@ -115,7 +115,7 @@ static void new_annot(int type)
case PDF_ANNOT_SOUND:
{
fz_rect icon_rect = { 12, 12, 12+20, 12+20 };
- pdf_set_annot_rect(ctx, selected_annot, &icon_rect);
+ pdf_set_annot_rect(ctx, selected_annot, icon_rect);
pdf_set_annot_color(ctx, selected_annot, 3, yellow);
}
break;
@@ -123,7 +123,7 @@ static void new_annot(int type)
case PDF_ANNOT_FREE_TEXT:
{
fz_rect text_rect = { 12, 12, 12+200, 12+100 };
- pdf_set_annot_rect(ctx, selected_annot, &text_rect);
+ pdf_set_annot_rect(ctx, selected_annot, text_rect);
pdf_set_annot_border(ctx, selected_annot, 0);
pdf_set_annot_default_appearance(ctx, selected_annot, "Helv", 12, black);
}
@@ -132,7 +132,7 @@ static void new_annot(int type)
case PDF_ANNOT_STAMP:
{
fz_rect stamp_rect = { 12, 12, 12+190, 12+50 };
- pdf_set_annot_rect(ctx, selected_annot, &stamp_rect);
+ pdf_set_annot_rect(ctx, selected_annot, stamp_rect);
pdf_set_annot_color(ctx, selected_annot, 3, red);
}
break;
@@ -140,7 +140,7 @@ static void new_annot(int type)
case PDF_ANNOT_CARET:
{
fz_rect caret_rect = { 12, 12, 12+18, 12+15 };
- pdf_set_annot_rect(ctx, selected_annot, &caret_rect);
+ pdf_set_annot_rect(ctx, selected_annot, caret_rect);
pdf_set_annot_color(ctx, selected_annot, 3, blue);
}
break;
@@ -158,7 +158,7 @@ static void new_annot(int type)
case PDF_ANNOT_CIRCLE:
{
fz_rect shape_rect = { 12, 12, 12+100, 12+50 };
- pdf_set_annot_rect(ctx, selected_annot, &shape_rect);
+ pdf_set_annot_rect(ctx, selected_annot, shape_rect);
pdf_set_annot_border(ctx, selected_annot, 1);
pdf_set_annot_color(ctx, selected_annot, 3, red);
}
@@ -553,8 +553,8 @@ void do_annotate_panel(void)
/* common annotation properties */
- pdf_annot_rect(ctx, selected_annot, &rect);
- fz_irect_from_rect(&irect, &rect);
+ rect = pdf_annot_rect(ctx, selected_annot);
+ irect = fz_irect_from_rect(rect);
ui_label("Rect: %d %d %d %d", irect.x0, irect.y0, irect.x1, irect.y1);
do_annotate_flags();
@@ -778,9 +778,8 @@ static void do_edit_icon(fz_irect canvas_area, fz_irect area, fz_rect *rect)
moving = 0;
if (fz_abs(start_pt.x - rect->x0) > 0.1f || fz_abs(start_pt.x - rect->y0) > 0.1f)
{
- fz_rect trect = *rect;
- fz_transform_rect(&trect, &view_page_inv_ctm);
- pdf_set_annot_rect(ctx, selected_annot, &trect);
+ fz_rect trect = fz_transform_rect(*rect, view_page_inv_ctm);
+ pdf_set_annot_rect(ctx, selected_annot, trect);
}
}
}
@@ -800,7 +799,7 @@ static void do_edit_rect(fz_irect canvas_area, fz_irect area, fz_rect *rect)
static fz_rect start_rect;
static int state = ER_NONE;
- fz_expand_irect(&area, 5);
+ area = fz_expand_irect(area, 5);
if (ui_mouse_inside(&canvas_area) && ui_mouse_inside(&area))
{
ui.hot = selected_annot;
@@ -839,9 +838,8 @@ static void do_edit_rect(fz_irect canvas_area, fz_irect area, fz_rect *rect)
state = ER_NONE;
if (rects_differ(&start_rect, rect, 1))
{
- fz_rect trect = *rect;
- fz_transform_rect(&trect, &view_page_inv_ctm);
- pdf_set_annot_rect(ctx, selected_annot, &trect);
+ fz_rect trect = fz_transform_rect(*rect, view_page_inv_ctm);
+ pdf_set_annot_rect(ctx, selected_annot, trect);
}
}
}
@@ -856,7 +854,7 @@ static void do_edit_line(fz_irect canvas_area, fz_irect area, fz_rect *rect)
fz_point a, b;
float lw;
- fz_expand_irect(&area, 5);
+ area = fz_expand_irect(area, 5);
if (ui_mouse_inside(&canvas_area) && ui_mouse_inside(&area))
{
ui.hot = selected_annot;
@@ -864,12 +862,12 @@ static void do_edit_line(fz_irect canvas_area, fz_irect area, fz_rect *rect)
{
ui.active = selected_annot;
pdf_annot_line(ctx, selected_annot, &start_a, &start_b);
- fz_transform_point(&start_a, &view_page_ctm);
- fz_transform_point(&start_b, &view_page_ctm);
+ start_a = fz_transform_point(start_a, view_page_ctm);
+ start_b = fz_transform_point(start_b, view_page_ctm);
a_grab = fz_make_irect(start_a.x, start_a.y, start_a.x, start_a.y);
b_grab = fz_make_irect(start_b.x, start_b.y, start_b.x, start_b.y);
- fz_expand_irect(&a_grab, 10);
- fz_expand_irect(&b_grab, 10);
+ a_grab = fz_expand_irect(a_grab, 10);
+ b_grab = fz_expand_irect(b_grab, 10);
state = EL_NONE;
if (ui_mouse_inside(&a_grab)) state |= EL_A;
if (ui_mouse_inside(&b_grab)) state |= EL_B;
@@ -895,7 +893,7 @@ static void do_edit_line(fz_irect canvas_area, fz_irect area, fz_rect *rect)
rect->x1 = fz_max(a.x, b.x);
rect->y1 = fz_max(a.y, b.y);
lw = pdf_annot_border(ctx, selected_annot);
- fz_expand_rect(rect, fz_matrix_expansion(&view_page_ctm) * lw);
+ *rect = fz_expand_rect(*rect, fz_matrix_expansion(view_page_ctm) * lw);
/* cancel on right click */
if (ui.right)
@@ -907,8 +905,8 @@ static void do_edit_line(fz_irect canvas_area, fz_irect area, fz_rect *rect)
state = EL_NONE;
if (points_differ(&start_a, &a, 1) || points_differ(&start_b, &b, 1))
{
- fz_transform_point(&a, &view_page_inv_ctm);
- fz_transform_point(&b, &view_page_inv_ctm);
+ a = fz_transform_point(a, view_page_inv_ctm);
+ b = fz_transform_point(b, view_page_inv_ctm);
pdf_set_annot_line(ctx, selected_annot, a, b);
}
}
@@ -938,11 +936,11 @@ static void do_edit_polygon(fz_irect canvas_area, int close)
if (n > 0)
{
p = pdf_annot_vertex(ctx, selected_annot, n-1);
- fz_transform_point(&p, &view_page_ctm);
+ p = fz_transform_point(p, view_page_ctm);
if (close)
{
a = pdf_annot_vertex(ctx, selected_annot, 0);
- fz_transform_point(&a, &view_page_ctm);
+ a = fz_transform_point(a, view_page_ctm);
}
glBegin(GL_LINE_STRIP);
glColor4f(1, 0, 0, 1);
@@ -966,8 +964,7 @@ static void do_edit_polygon(fz_irect canvas_area, int close)
/* commit point on mouse-up */
if (!ui.down)
{
- fz_point p = { ui.x, ui.y };
- fz_transform_point(&p, &view_page_inv_ctm);
+ fz_point p = fz_transform_point_xy(ui.x, ui.y, view_page_inv_ctm);
pdf_add_annot_vertex(ctx, selected_annot, p);
drawing = 0;
}
@@ -1029,7 +1026,7 @@ static void do_edit_ink(fz_irect canvas_area)
if (n > 1)
{
for (i = 0; i < n; ++i)
- fz_transform_point(&p[i], &view_page_inv_ctm);
+ p[i] = fz_transform_point(p[i], view_page_inv_ctm);
pdf_add_annot_ink_list(ctx, selected_annot, n, p);
}
drawing = 0;
@@ -1064,8 +1061,8 @@ static void do_edit_quad_points(void)
fz_point page_a = { pt.x, pt.y };
fz_point page_b = { ui.x, ui.y };
- fz_transform_point(&page_a, &view_page_inv_ctm);
- fz_transform_point(&page_b, &view_page_inv_ctm);
+ page_a = fz_transform_point(page_a, view_page_inv_ctm);
+ page_b = fz_transform_point(page_b, view_page_inv_ctm);
n = fz_highlight_selection(ctx, page_text, page_a, page_b, hits, nelem(hits));
@@ -1076,8 +1073,7 @@ static void do_edit_quad_points(void)
glBegin(GL_QUADS);
for (i = 0; i < n; ++i)
{
- fz_quad thit = hits[i];
- fz_transform_quad(&thit, &view_page_ctm);
+ fz_quad thit = fz_transform_quad(hits[i], view_page_ctm);
glVertex2f(thit.ul.x, thit.ul.y);
glVertex2f(thit.ur.x, thit.ur.y);
glVertex2f(thit.lr.x, thit.lr.y);
@@ -1114,9 +1110,9 @@ void do_annotate_canvas(fz_irect canvas_area)
for (annot = pdf_first_annot(ctx, page); annot; annot = pdf_next_annot(ctx, annot))
{
- pdf_bound_annot(ctx, annot, &bounds);
- fz_transform_rect(&bounds, &view_page_ctm);
- fz_irect_from_rect(&area, &bounds);
+ bounds = pdf_bound_annot(ctx, annot);
+ bounds = fz_transform_rect(bounds, view_page_ctm);
+ area = fz_irect_from_rect(bounds);
if (ui_mouse_inside(&canvas_area) && ui_mouse_inside(&area))
{
@@ -1189,7 +1185,7 @@ void do_annotate_canvas(fz_irect canvas_area)
glEnable(GL_BLEND);
glColor4f(1, 1, 1, 1);
glBegin(GL_LINE_LOOP);
- fz_irect_from_rect(&area, &bounds);
+ area = fz_irect_from_rect(bounds);
glVertex2f(area.x0-0.5f, area.y0-0.5f);
glVertex2f(area.x1+0.5f, area.y0-0.5f);
glVertex2f(area.x1+0.5f, area.y1+0.5f);
diff --git a/platform/gl/gl-font.c b/platform/gl/gl-font.c
index 08dd773a..8a331b3e 100644
--- a/platform/gl/gl-font.c
+++ b/platform/gl/gl-font.c
@@ -137,7 +137,7 @@ static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp)
int w, h;
/* match fitz's glyph cache quantization */
- fz_scale(&trm, g_font_size, -g_font_size);
+ trm = fz_scale(g_font_size, -g_font_size);
trm.e = *xp;
trm.f = *yp;
fz_subpixel_adjust(ctx, &trm, &subpix_trm, &subx, &suby);
diff --git a/platform/gl/gl-input.c b/platform/gl/gl-input.c
index 56fcf74d..c3898f50 100644
--- a/platform/gl/gl-input.c
+++ b/platform/gl/gl-input.c
@@ -409,7 +409,7 @@ int ui_input(struct input *input, int width, int height)
area = ui_pack(width, ui.lineheight * height + 6);
ui_draw_bevel_rect(area, UI_COLOR_TEXT_BG, 1);
- fz_expand_irect(&area, -2);
+ area = fz_expand_irect(area, -2);
if (height > 1)
area.x1 -= ui.lineheight;
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 899dc4ec..5b26a48f 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -207,20 +207,18 @@ void update_title(void)
void transform_page(void)
{
- fz_rect rect = page_bounds;
+ fz_rect rect;
fz_matrix matrix;
- draw_page_bounds = page_bounds;
-
- fz_scale(&draw_page_ctm, currentzoom / 72, currentzoom / 72);
- fz_pre_rotate(&draw_page_ctm, -currentrotate);
+ draw_page_ctm = fz_scale(currentzoom / 72, currentzoom / 72);
+ draw_page_ctm = fz_pre_rotate(draw_page_ctm, -currentrotate);
/* fix the page origin at 0,0 after rotation */
- fz_transform_rect(&rect, &draw_page_ctm);
- fz_translate(&matrix, -rect.x0, -rect.y0);
- fz_concat(&draw_page_ctm, &draw_page_ctm, &matrix);
+ rect = fz_transform_rect(page_bounds, draw_page_ctm);
+ matrix = fz_translate(-rect.x0, -rect.y0);
+ draw_page_ctm = fz_concat(draw_page_ctm, matrix);
- fz_transform_rect(&draw_page_bounds, &draw_page_ctm);
+ draw_page_bounds = fz_transform_rect(page_bounds, draw_page_ctm);
}
void load_page(void)
@@ -245,10 +243,10 @@ void load_page(void)
page_text = fz_new_stext_page_from_page(ctx, fzpage, NULL);
/* compute bounds here for initial window size */
- fz_bound_page(ctx, fzpage, &page_bounds);
+ page_bounds = fz_bound_page(ctx, fzpage);
transform_page();
- fz_irect_from_rect(&area, &draw_page_bounds);
+ area = fz_irect_from_rect(draw_page_bounds);
page_tex.w = area.x1 - area.x0;
page_tex.h = area.y1 - area.y0;
}
@@ -281,16 +279,14 @@ static struct mark save_mark()
{
struct mark mark;
mark.page = currentpage;
- mark.scroll.x = scroll_x;
- mark.scroll.y = scroll_y;
- fz_transform_point(&mark.scroll, &view_page_inv_ctm);
+ mark.scroll = fz_transform_point_xy(scroll_x, scroll_y, view_page_inv_ctm);
return mark;
}
static void restore_mark(struct mark mark)
{
currentpage = mark.page;
- fz_transform_point(&mark.scroll, &draw_page_ctm);
+ mark.scroll = fz_transform_point(mark.scroll, draw_page_ctm);
scroll_x = mark.scroll.x;
scroll_y = mark.scroll.y;
}
@@ -337,9 +333,8 @@ static void jump_to_page(int newpage)
static void jump_to_page_xy(int newpage, float x, float y)
{
- fz_point p = { x, y };
+ fz_point p = fz_transform_point_xy(x, y, draw_page_ctm);
newpage = fz_clampi(newpage, 0, fz_count_pages(ctx, doc) - 1);
- fz_transform_point(&p, &draw_page_ctm);
clear_future();
push_history();
currentpage = newpage;
@@ -427,8 +422,8 @@ static void do_links(fz_link *link)
while (link)
{
bounds = link->rect;
- fz_transform_rect(&bounds, &view_page_ctm);
- fz_irect_from_rect(&area, &bounds);
+ bounds = fz_transform_rect(link->rect, view_page_ctm);
+ area = fz_irect_from_rect(bounds);
if (ui_mouse_inside(&area))
{
@@ -493,8 +488,8 @@ static void do_page_selection(void)
fz_point page_a = { pt.x, pt.y };
fz_point page_b = { ui.x, ui.y };
- fz_transform_point(&page_a, &view_page_inv_ctm);
- fz_transform_point(&page_b, &view_page_inv_ctm);
+ page_a = fz_transform_point(page_a, view_page_inv_ctm);
+ page_b = fz_transform_point(page_b, view_page_inv_ctm);
if (ui.mod == GLUT_ACTIVE_CTRL)
fz_snap_selection(ctx, page_text, &page_a, &page_b, FZ_SELECT_WORDS);
@@ -510,8 +505,7 @@ static void do_page_selection(void)
glBegin(GL_QUADS);
for (i = 0; i < n; ++i)
{
- fz_quad thit = hits[i];
- fz_transform_quad(&thit, &view_page_ctm);
+ fz_quad thit = fz_transform_quad(hits[i], view_page_ctm);
glVertex2f(thit.ul.x, thit.ul.y);
glVertex2f(thit.ur.x, thit.ur.y);
glVertex2f(thit.lr.x, thit.lr.y);
@@ -546,8 +540,7 @@ static void do_search_hits(void)
glBegin(GL_QUADS);
for (i = 0; i < search_hit_count; ++i)
{
- fz_quad thit = search_hit_quads[i];
- fz_transform_quad(&thit, &view_page_ctm);
+ fz_quad thit = fz_transform_quad(search_hit_quads[i], view_page_ctm);
glVertex2f(thit.ul.x, thit.ul.y);
glVertex2f(thit.ur.x, thit.ur.y);
glVertex2f(thit.lr.x, thit.lr.y);
@@ -567,9 +560,7 @@ static void do_forms(void)
if (!pdf || search_active)
return;
- p.x = ui.x;
- p.y = ui.y;
- fz_transform_point(&p, &view_page_inv_ctm);
+ p = fz_transform_point_xy(ui.x, ui.y, view_page_inv_ctm);
if (ui.down && !ui.active)
{
@@ -1131,10 +1122,9 @@ static void do_canvas(void)
view_page_ctm = draw_page_ctm;
view_page_ctm.e += page_x;
view_page_ctm.f += page_y;
- fz_invert_matrix(&view_page_inv_ctm, &view_page_ctm);
- view_page_bounds = page_bounds;
- fz_transform_rect(&view_page_bounds, &view_page_ctm);
- fz_irect_from_rect(&view_page_area, &view_page_bounds);
+ view_page_inv_ctm = fz_invert_matrix(view_page_ctm);
+ view_page_bounds = fz_transform_rect(page_bounds, view_page_ctm);
+ view_page_area = fz_irect_from_rect(view_page_bounds);
ui_draw_image(&page_tex, page_x, page_y);
diff --git a/platform/gl/gl-ui.c b/platform/gl/gl-ui.c
index 2d8fd5be..9539af7b 100644
--- a/platform/gl/gl-ui.c
+++ b/platform/gl/gl-ui.c
@@ -687,7 +687,7 @@ void ui_dialog_begin(int w, int h)
y = (ui.window_h-h)/3;
area = fz_make_irect(x, y, x+w, y+h);
ui_draw_bevel_rect(area, UI_COLOR_PANEL, 0);
- fz_expand_irect(&area, -14);
+ area = fz_expand_irect(area, -14);
ui_pack_push(area);
}
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 2a8e517a..928732e5 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -1462,22 +1462,22 @@ static inline jobject to_Point_safe(fz_context *ctx, JNIEnv *env, fz_point point
return (*env)->NewObject(env, cls_Point, mid_Point_init, point.x, point.y);
}
-static inline jobject to_Rect_safe(fz_context *ctx, JNIEnv *env, const fz_rect *rect)
+static inline jobject to_Rect_safe(fz_context *ctx, JNIEnv *env, fz_rect rect)
{
- if (!ctx || !rect) return NULL;
+ if (!ctx) return NULL;
- return (*env)->NewObject(env, cls_Rect, mid_Rect_init, rect->x0, rect->y0, rect->x1, rect->y1);
+ return (*env)->NewObject(env, cls_Rect, mid_Rect_init, rect.x0, rect.y0, rect.x1, rect.y1);
}
-static inline jobject to_Quad_safe(fz_context *ctx, JNIEnv *env, const fz_quad *quad)
+static inline jobject to_Quad_safe(fz_context *ctx, JNIEnv *env, fz_quad quad)
{
- if (!ctx || !quad) return NULL;
+ if (!ctx) return NULL;
return (*env)->NewObject(env, cls_Quad, mid_Quad_init,
- quad->ul.x, quad->ul.y,
- quad->ur.x, quad->ur.y,
- quad->ll.x, quad->ll.y,
- quad->lr.x, quad->lr.y);
+ quad.ul.x, quad.ul.y,
+ quad.ur.x, quad.ur.y,
+ quad.ll.x, quad.ll.y,
+ quad.lr.x, quad.lr.y);
}
static inline jobjectArray to_jQuadArray_safe(fz_context *ctx, JNIEnv *env, const fz_quad *quads, jint n)
@@ -1492,7 +1492,7 @@ static inline jobjectArray to_jQuadArray_safe(fz_context *ctx, JNIEnv *env, cons
for (i = 0; i < n; i++)
{
- jobject jquad = to_Quad_safe(ctx, env, &quads[i]);
+ jobject jquad = to_Quad_safe(ctx, env, quads[i]);
if (!jquad) return NULL;
(*env)->SetObjectArrayElement(env, arr, i, jquad);
@@ -4108,7 +4108,7 @@ FUN(Path_transform)(JNIEnv *env, jobject self, jobject jctm)
if (!ctx || !path) return;
fz_try(ctx)
- fz_transform_path(ctx, path, &ctm);
+ fz_transform_path(ctx, path, ctm);
fz_catch(ctx)
jni_rethrow(env, ctx);
}
@@ -4146,14 +4146,14 @@ FUN(Path_getBounds)(JNIEnv *env, jobject self, jobject jstroke, jobject jctm)
if (!stroke) { jni_throw_arg(env, "stroke must not be null"); return NULL; }
fz_try(ctx)
- fz_bound_path(ctx, path, stroke, &ctm, &rect);
+ rect = fz_bound_path(ctx, path, stroke, ctm);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
return NULL;
}
- return to_Rect_safe(ctx, env, &rect);
+ return to_Rect_safe(ctx, env, rect);
}
typedef struct
@@ -4247,7 +4247,7 @@ FUN(Rect_adjustForStroke)(JNIEnv *env, jobject self, jobject jstroke, jobject jc
if (!stroke) { jni_throw_arg(env, "stroke must not be null"); return; }
fz_try(ctx)
- fz_adjust_rect_for_stroke(ctx, &rect, stroke, &ctm);
+ rect = fz_adjust_rect_for_stroke(ctx, rect, stroke, ctm);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
@@ -4424,14 +4424,14 @@ FUN(Text_getBounds)(JNIEnv *env, jobject self, jobject jstroke, jobject jctm)
if (!stroke) { jni_throw_arg(env, "stroke must not be null"); return NULL; }
fz_try(ctx)
- fz_bound_text(ctx, text, stroke, &ctm, &rect);
+ rect = fz_bound_text(ctx, text, stroke, ctm);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
return NULL;
}
- return to_Rect_safe(ctx, env, &rect);
+ return to_Rect_safe(ctx, env, rect);
}
JNIEXPORT void JNICALL
@@ -4446,7 +4446,7 @@ FUN(Text_showGlyph)(JNIEnv *env, jobject self, jobject jfont, jobject jtrm, jint
if (!font) { jni_throw_arg(env, "font must not be null"); return; }
fz_try(ctx)
- fz_show_glyph(ctx, text, font, &trm, glyph, unicode, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, trm, glyph, unicode, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
fz_catch(ctx)
jni_rethrow(env, ctx);
}
@@ -4773,14 +4773,14 @@ FUN(Annotation_getBounds)(JNIEnv *env, jobject self)
if (!ctx || !annot) return NULL;
fz_try(ctx)
- fz_bound_annot(ctx, annot, &rect);
+ rect = fz_bound_annot(ctx, annot);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
return NULL;
}
- return to_Rect_safe(ctx, env, &rect);
+ return to_Rect_safe(ctx, env, rect);
}
JNIEXPORT jobject JNICALL
@@ -5386,14 +5386,14 @@ FUN(Page_getBounds)(JNIEnv *env, jobject self)
if (!ctx || !page) return NULL;
fz_try(ctx)
- fz_bound_page(ctx, page, &rect);
+ rect = fz_bound_page(ctx, page);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
return NULL;
}
- return to_Rect_safe(ctx, env, &rect);
+ return to_Rect_safe(ctx, env, rect);
}
JNIEXPORT void JNICALL
@@ -5553,7 +5553,7 @@ FUN(Page_getLinks)(JNIEnv *env, jobject self)
jobject juri = NULL;
int page = 0;
- jbounds = to_Rect_safe(ctx, env, &link->rect);
+ jbounds = to_Rect_safe(ctx, env, link->rect);
if (!jbounds) return NULL;
if (fz_is_external_link(ctx, link->uri))
@@ -5692,10 +5692,8 @@ FUN(Page_textAsHtml)(JNIEnv *env, jobject self)
fz_try(ctx)
{
- fz_rect mediabox;
-
ctm = fz_identity;
- text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
+ text = fz_new_stext_page(ctx, fz_bound_page(ctx, page));
dev = fz_new_stext_device(ctx, text, NULL);
fz_run_page(ctx, page, dev, &ctm, NULL);
fz_close_device(ctx, dev);
@@ -5778,16 +5776,17 @@ FUN(Cookie_abort)(JNIEnv *env, jobject self)
/* DisplayList interface */
JNIEXPORT jlong JNICALL
-FUN(DisplayList_newNative)(JNIEnv *env, jobject self)
+FUN(DisplayList_newNative)(JNIEnv *env, jobject self, jobject jmediabox)
{
fz_context *ctx = get_context(env);
+ fz_rect mediabox = from_Rect(env, jmediabox);
fz_display_list *list = NULL;
if (!ctx) return 0;
fz_try(ctx)
- list = fz_new_display_list(ctx, NULL);
+ list = fz_new_display_list(ctx, mediabox);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
@@ -6513,7 +6512,7 @@ FUN(StructuredText_getBlocks)(JNIEnv *env, jobject self)
if (!jblock) return NULL;
/* set block's bbox */
- jrect = to_Rect_safe(ctx, env, &(block->bbox));
+ jrect = to_Rect_safe(ctx, env, block->bbox);
if (!jrect) return NULL;
(*env)->SetObjectField(env, jblock, fid_TextBlock_bbox, jrect);
@@ -6534,7 +6533,7 @@ FUN(StructuredText_getBlocks)(JNIEnv *env, jobject self)
if (!jline) return NULL;
/* set line's bbox */
- jrect = to_Rect_safe(ctx, env, &(line->bbox));
+ jrect = to_Rect_safe(ctx, env, line->bbox);
if (!jrect) return NULL;
(*env)->SetObjectField(env, jline, fid_TextLine_bbox, jrect);
@@ -6556,7 +6555,7 @@ FUN(StructuredText_getBlocks)(JNIEnv *env, jobject self)
if (!jchar) return NULL;
/* set the char's bbox */
- jquad = to_Quad_safe(ctx, env, &ch->quad);
+ jquad = to_Quad_safe(ctx, env, ch->quad);
if (!jquad) return NULL;
(*env)->SetObjectField(env, jchar, fid_TextChar_quad, jquad);
@@ -7129,7 +7128,7 @@ FUN(PDFDocument_addPageBuffer)(JNIEnv *env, jobject self, jobject jmediabox, jin
if (!contents) { jni_throw_arg(env, "contents must not be null"); return NULL; }
fz_try(ctx)
- ind = pdf_add_page(ctx, pdf, &mediabox, rotate, resources, contents);
+ ind = pdf_add_page(ctx, pdf, mediabox, rotate, resources, contents);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
@@ -7165,7 +7164,7 @@ FUN(PDFDocument_addPageString)(JNIEnv *env, jobject self, jobject jmediabox, jin
size_t len = strlen(scontents);
data = fz_malloc(ctx, len);
contents = fz_new_buffer_from_data(ctx, data, len);
- ind = pdf_add_page(ctx, pdf, &mediabox, rotate, resources, contents);
+ ind = pdf_add_page(ctx, pdf, mediabox, rotate, resources, contents);
}
fz_always(ctx)
{
@@ -8951,14 +8950,14 @@ FUN(PDFAnnotation_getRect)(JNIEnv *env, jobject self)
if (!ctx || !annot) return NULL;
fz_try(ctx)
- pdf_annot_rect(ctx, annot, &rect);
+ rect = pdf_annot_rect(ctx, annot);
fz_catch(ctx)
{
jni_rethrow(env, ctx);
return NULL;
}
- return to_Rect_safe(ctx, env, &rect);
+ return to_Rect_safe(ctx, env, rect);
}
JNIEXPORT void JNICALL
@@ -8971,7 +8970,7 @@ FUN(PDFAnnotation_setRect)(JNIEnv *env, jobject self, jobject jrect)
if (!ctx || !annot) return;
fz_try(ctx)
- pdf_set_annot_rect(ctx, annot, &rect);
+ pdf_set_annot_rect(ctx, annot, rect);
fz_catch(ctx)
jni_rethrow(env, ctx);
}
diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h
index 3f223a13..37ea6ed2 100644
--- a/platform/java/mupdf_native.h
+++ b/platform/java/mupdf_native.h
@@ -466,10 +466,10 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_DisplayList_finalize
/*
* Class: com_artifex_mupdf_fitz_DisplayList
* Method: newNative
- * Signature: ()J
+ * Signature: (Lcom/artifex/mupdf/fitz/Rect;)J
*/
JNIEXPORT jlong JNICALL Java_com_artifex_mupdf_fitz_DisplayList_newNative
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jobject);
/*
* Class: com_artifex_mupdf_fitz_DisplayList
diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
index c6c33f20..5b64583f 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java
@@ -15,10 +15,10 @@ public class DisplayList
pointer = 0;
}
- private native long newNative();
+ private native long newNative(Rect mediabox);
- public DisplayList() {
- pointer = newNative();
+ public DisplayList(Rect mediabox) {
+ pointer = newNative(mediabox);
}
private DisplayList(long p) {
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index 17af3d0f..20f4cc46 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -148,8 +148,7 @@ void pdfapp_setresolution(pdfapp_t *app, int res)
void pdfapp_invert(pdfapp_t *app, const fz_rect *rect)
{
- fz_irect b;
- fz_invert_pixmap_rect(app->ctx, app->image, fz_round_rect(&b, rect));
+ fz_invert_pixmap_rect(app->ctx, app->image, fz_round_rect(*rect));
}
void pdfapp_reloadfile(pdfapp_t *app)
@@ -262,7 +261,7 @@ static int make_fake_doc(pdfapp_t *app)
/* Create enough copies of our blank(ish) page so that the
* page number is preserved if and when a subsequent load
* works. */
- page_obj = pdf_add_page(ctx, pdf, &mediabox, 0, NULL, contents);
+ page_obj = pdf_add_page(ctx, pdf, mediabox, 0, NULL, contents);
for (i = 0; i < app->pagecount; i++)
pdf_insert_page(ctx, pdf, -1, page_obj);
}
@@ -606,7 +605,7 @@ int pdfapp_preclose(pdfapp_t *app)
static void pdfapp_viewctm(fz_matrix *mat, pdfapp_t *app)
{
- fz_pre_rotate(fz_scale(mat, app->resolution/72.0f, app->resolution/72.0f), app->rotate);
+ *mat = fz_pre_rotate(fz_scale(app->resolution/72.0f, app->resolution/72.0f), app->rotate);
}
static void pdfapp_panview(pdfapp_t *app, int newx, int newy)
@@ -671,8 +670,7 @@ static void pdfapp_loadpage(pdfapp_t *app, int no_cache)
fz_try(app->ctx)
{
app->page = fz_load_page(app->ctx, app->doc, app->pageno - 1);
-
- fz_bound_page(app->ctx, app->page, &app->page_bbox);
+ app->page_bbox = fz_bound_page(app->ctx, app->page);
}
fz_catch(app->ctx)
{
@@ -687,7 +685,7 @@ static void pdfapp_loadpage(pdfapp_t *app, int no_cache)
{
fz_annot *annot;
/* Create display lists */
- app->page_list = fz_new_display_list(app->ctx, NULL);
+ app->page_list = fz_new_display_list(app->ctx, fz_infinite_rect);
mdev = fz_new_list_device(app->ctx, app->page_list);
if (no_cache)
fz_enable_device_hints(app->ctx, mdev, FZ_NO_CACHE);
@@ -696,7 +694,7 @@ static void pdfapp_loadpage(pdfapp_t *app, int no_cache)
fz_close_device(app->ctx, mdev);
fz_drop_device(app->ctx, mdev);
mdev = NULL;
- app->annotations_list = fz_new_display_list(app->ctx, NULL);
+ app->annotations_list = fz_new_display_list(app->ctx, fz_infinite_rect);
mdev = fz_new_list_device(app->ctx, app->annotations_list);
for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
fz_run_annot(app->ctx, annot, mdev, &fz_identity, &cookie);
@@ -757,7 +755,7 @@ static void pdfapp_recreate_annotationslist(pdfapp_t *app)
{
fz_annot *annot;
/* Create display list */
- app->annotations_list = fz_new_display_list(app->ctx, NULL);
+ app->annotations_list = fz_new_display_list(app->ctx, fz_infinite_rect);
mdev = fz_new_list_device(app->ctx, app->annotations_list);
for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
fz_run_annot(app->ctx, annot, mdev, &fz_identity, &cookie);
@@ -813,9 +811,10 @@ static void pdfapp_updatepage(pdfapp_t *app)
fz_annot *annot = (fz_annot*)pannot;
fz_rect bounds;
fz_irect ibounds;
- fz_transform_rect(fz_bound_annot(app->ctx, annot, &bounds), &ctm);
- fz_rect_from_irect(&bounds, fz_round_rect(&ibounds, &bounds));
- fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, &ibounds);
+ bounds = fz_transform_rect(fz_bound_annot(app->ctx, annot), ctm);
+ ibounds = fz_round_rect(bounds);
+ bounds = fz_rect_from_irect(ibounds);
+ fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, ibounds);
idev = fz_new_draw_device_with_bbox(app->ctx, NULL, app->image, &ibounds);
fz_try(app->ctx)
{
@@ -878,7 +877,8 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
app->hit_count = 0;
/* Extract text */
- app->page_text = fz_new_stext_page(app->ctx, fz_bound_page(app->ctx, app->page, &mediabox));
+ mediabox = fz_bound_page(app->ctx, app->page);
+ app->page_text = fz_new_stext_page(app->ctx, mediabox);
if (app->page_list || app->annotations_list)
{
@@ -914,9 +914,9 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
wintitle(app, buf);
pdfapp_viewctm(&ctm, app);
- bounds = app->page_bbox;
- fz_round_rect(&ibounds, fz_transform_rect(&bounds, &ctm));
- fz_rect_from_irect(&bounds, &ibounds);
+ bounds = fz_transform_rect(app->page_bbox, ctm);
+ ibounds = fz_round_rect(bounds);
+ bounds = fz_rect_from_irect(ibounds);
/* Draw */
fz_drop_pixmap(app->ctx, app->image);
@@ -931,7 +931,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
fz_try(app->ctx)
{
- app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds, NULL, 1);
+ app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, ibounds, NULL, 1);
fz_clear_pixmap_with_value(app->ctx, app->image, 255);
if (app->page_list || app->annotations_list)
{
@@ -958,7 +958,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
colorspace = fz_device_gray(app->ctx);
else
colorspace = app->colorspace;
- app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds, NULL, 1);
+ app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, ibounds, NULL, 1);
app->duration = 0;
fz_page_presentation(app->ctx, app->page, &app->transition, &app->duration);
if (app->duration == 0)
@@ -1051,7 +1051,8 @@ void pdfapp_inverthit(pdfapp_t *app)
for (i = 0; i < app->hit_count; i++)
{
bbox = fz_rect_from_quad(app->hit_bbox[i]);
- pdfapp_invert(app, fz_transform_rect(&bbox, &ctm));
+ bbox = fz_transform_rect(bbox, ctm);
+ pdfapp_invert(app, &bbox);
}
}
@@ -1624,14 +1625,14 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
int processed = 0;
if (app->image)
- fz_pixmap_bbox(app->ctx, app->image, &irect);
+ irect = fz_pixmap_bbox(app->ctx, app->image);
p.x = x - app->panx + irect.x0;
p.y = y - app->pany + irect.y0;
pdfapp_viewctm(&ctm, app);
- fz_invert_matrix(&ctm, &ctm);
+ ctm = fz_invert_matrix(ctm);
- fz_transform_point(&p, &ctm);
+ p = fz_transform_point(p, ctm);
if (btn == 1 && (state == 1 || state == -1))
{
@@ -1767,8 +1768,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
fz_annot *annot;
for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
{
- fz_rect rect;
- fz_bound_annot(app->ctx, annot, &rect);
+ fz_rect rect = fz_bound_annot(app->ctx, annot);
if (x >= rect.x0 && x < rect.x1)
if (y >= rect.y0 && y < rect.y1)
break;
@@ -1921,9 +1921,8 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
fz_rect sel;
pdfapp_viewctm(&ctm, app);
- fz_invert_matrix(&ctm, &ctm);
- sel = app->selr;
- fz_transform_rect(&sel, &ctm);
+ ctm = fz_invert_matrix(ctm);
+ sel = fz_transform_rect(app->selr, ctm);
p = 0;
need_newline = 0;
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
index e133a3b5..ddf3c553 100644
--- a/source/cbz/mucbz.c
+++ b/source/cbz/mucbz.c
@@ -135,17 +135,18 @@ cbz_count_pages(fz_context *ctx, fz_document *doc_)
return doc->page_count;
}
-static fz_rect *
-cbz_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox)
+static fz_rect
+cbz_bound_page(fz_context *ctx, fz_page *page_)
{
cbz_page *page = (cbz_page*)page_;
fz_image *image = page->image;
int xres, yres;
+ fz_rect bbox;
fz_image_resolution(image, &xres, &yres);
- bbox->x0 = bbox->y0 = 0;
- bbox->x1 = image->w * DPI / xres;
- bbox->y1 = image->h * DPI / yres;
+ bbox.x0 = bbox.y0 = 0;
+ bbox.x1 = image->w * DPI / xres;
+ bbox.y1 = image->h * DPI / yres;
return bbox;
}
@@ -153,7 +154,7 @@ static void
cbz_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
cbz_page *page = (cbz_page*)page_;
- fz_matrix local_ctm = *ctm;
+ fz_matrix local_ctm;
fz_image *image = page->image;
int xres, yres;
float w, h;
@@ -161,7 +162,7 @@ cbz_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *c
fz_image_resolution(image, &xres, &yres);
w = image->w * DPI / xres;
h = image->h * DPI / yres;
- fz_pre_scale(&local_ctm, w, h);
+ local_ctm = fz_pre_scale(*ctm, w, h);
fz_fill_image(ctx, dev, image, &local_ctm, 1, NULL);
}
diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c
index 8ef4855b..bc7e6e92 100644
--- a/source/cbz/muimg.c
+++ b/source/cbz/muimg.c
@@ -36,17 +36,18 @@ img_count_pages(fz_context *ctx, fz_document *doc_)
return doc->page_count;
}
-static fz_rect *
-img_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox)
+static fz_rect
+img_bound_page(fz_context *ctx, fz_page *page_)
{
img_page *page = (img_page*)page_;
fz_image *image = page->image;
int xres, yres;
+ fz_rect bbox;
fz_image_resolution(image, &xres, &yres);
- bbox->x0 = bbox->y0 = 0;
- bbox->x1 = image->w * DPI / xres;
- bbox->y1 = image->h * DPI / yres;
+ bbox.x0 = bbox.y0 = 0;
+ bbox.x1 = image->w * DPI / xres;
+ bbox.y1 = image->h * DPI / yres;
return bbox;
}
@@ -54,7 +55,7 @@ static void
img_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
img_page *page = (img_page*)page_;
- fz_matrix local_ctm = *ctm;
+ fz_matrix local_ctm;
fz_image *image = page->image;
int xres, yres;
float w, h;
@@ -62,7 +63,7 @@ img_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *c
fz_image_resolution(image, &xres, &yres);
w = image->w * DPI / xres;
h = image->h * DPI / yres;
- fz_pre_scale(&local_ctm, w, h);
+ local_ctm = fz_pre_scale(*ctm, w, h);
fz_fill_image(ctx, dev, image, &local_ctm, 1, NULL);
}
diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c
index 37778741..7238936a 100644
--- a/source/fitz/bbox-device.c
+++ b/source/fitz/bbox-device.c
@@ -16,22 +16,21 @@ typedef struct fz_bbox_device_s
} fz_bbox_device;
static void
-fz_bbox_add_rect(fz_context *ctx, fz_device *dev, const fz_rect *rect, int clip)
+fz_bbox_add_rect(fz_context *ctx, fz_device *dev, fz_rect rect, int clip)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_rect r = *rect;
if (0 < bdev->top && bdev->top <= STACK_SIZE)
{
- fz_intersect_rect(&r, &bdev->stack[bdev->top-1]);
+ rect = fz_intersect_rect(rect, bdev->stack[bdev->top-1]);
}
if (!clip && bdev->top <= STACK_SIZE && !bdev->ignore)
{
- fz_union_rect(bdev->result, &r);
+ *bdev->result = fz_union_rect(*bdev->result, rect);
}
if (clip && ++bdev->top <= STACK_SIZE)
{
- bdev->stack[bdev->top-1] = r;
+ bdev->stack[bdev->top-1] = rect;
}
}
@@ -39,89 +38,77 @@ static void
fz_bbox_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, *ctm), 0);
}
static void
fz_bbox_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, *ctm), 0);
}
static void
fz_bbox_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, *ctm), 0);
}
static void
fz_bbox_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, *ctm), 0);
}
static void
fz_bbox_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_shade(ctx, shade, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_shade(ctx, shade, *ctm), 0);
}
static void
fz_bbox_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *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, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *ctm), 0);
}
static void
fz_bbox_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, *ctm), 1);
}
static void
fz_bbox_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, *ctm), 1);
}
static void
fz_bbox_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, *ctm), 1);
}
static void
fz_bbox_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, *ctm), 1);
}
static void
fz_bbox_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 1);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *ctm), 1);
}
static void
@@ -138,7 +125,7 @@ static void
fz_bbox_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, const float *color, const fz_color_params *color_params)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_bbox_add_rect(ctx, dev, rect, 1);
+ fz_bbox_add_rect(ctx, dev, *rect, 1);
bdev->ignore++;
}
@@ -153,7 +140,7 @@ fz_bbox_end_mask(fz_context *ctx, fz_device *dev)
static void
fz_bbox_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *rect, fz_colorspace *cs, int isolated, int knockout, int blendmode, float alpha)
{
- fz_bbox_add_rect(ctx, dev, rect, 1);
+ fz_bbox_add_rect(ctx, dev, *rect, 1);
}
static void
@@ -166,8 +153,7 @@ static int
fz_bbox_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_rect r = *area;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(*area, *ctm), 0);
bdev->ignore++;
return 0;
}
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 4cfeeb3e..54435743 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -2810,7 +2810,6 @@ icc_base_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorsp
int i, j;
unsigned char *inputpos, *outputpos;
fz_pixmap *base;
- fz_irect bbox;
int h, len;
float src_f[FZ_MAX_COLORS], des_f[FZ_MAX_COLORS];
int sn = src->n;
@@ -2819,7 +2818,7 @@ icc_base_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorsp
int stride_base;
int bn, bc;
- base = fz_new_pixmap_with_bbox(ctx, base_cs, fz_pixmap_bbox(ctx, src, &bbox), src->seps, src->alpha);
+ base = fz_new_pixmap_with_bbox(ctx, base_cs, fz_pixmap_bbox(ctx, src), src->seps, src->alpha);
bn = base->n;
bc = base->n - base->alpha - base->s;
stride_base = base->stride - base->w * bn;
@@ -3563,7 +3562,6 @@ fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha)
unsigned char *d;
int y, x, k, n, high;
unsigned char *lookup;
- fz_irect bbox;
int s_line_inc, d_line_inc;
assert(src->colorspace->to_ccs == indexed_to_rgb || src->colorspace->to_ccs == indexed_to_alt);
@@ -3574,7 +3572,7 @@ fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha)
lookup = idx->lookup;
n = idx->base->n;
- dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src, &bbox), src->seps, alpha);
+ dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src), src->seps, alpha);
s = src->samples;
d = dst->samples;
s_line_inc = src->stride - src->w * src->n;
diff --git a/source/fitz/device.c b/source/fitz/device.c
index 42377030..2cc4a2e7 100644
--- a/source/fitz/device.c
+++ b/source/fitz/device.c
@@ -99,8 +99,7 @@ push_clip_stack(fz_context *ctx, fz_device *dev, const fz_rect *rect, int flags)
dev->container[0].scissor = *rect;
else
{
- dev->container[dev->container_len].scissor = dev->container[dev->container_len-1].scissor;
- fz_intersect_rect(&dev->container[dev->container_len].scissor, rect);
+ dev->container[dev->container_len].scissor = fz_intersect_rect(dev->container[dev->container_len-1].scissor, *rect);
}
dev->container[dev->container_len].flags = flags;
dev->container[dev->container_len].user = 0;
@@ -149,8 +148,7 @@ fz_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd,
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_path(ctx, path, NULL, ctm, &bbox);
+ fz_rect bbox = fz_bound_path(ctx, path, NULL, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_path);
}
else
@@ -182,8 +180,7 @@ fz_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_path(ctx, path, stroke, ctm, &bbox);
+ fz_rect bbox = fz_bound_path(ctx, path, stroke, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_stroke_path);
}
else
@@ -235,8 +232,7 @@ fz_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matr
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_text(ctx, text, NULL, ctm, &bbox);
+ fz_rect bbox = fz_bound_text(ctx, text, NULL, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_text);
}
else
@@ -268,8 +264,7 @@ fz_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_text(ctx, text, stroke, ctm, &bbox);
+ fz_rect bbox = fz_bound_text(ctx, text, stroke, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_stroke_text);
}
else
@@ -354,8 +349,7 @@ fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
{
if (scissor == NULL)
{
- fz_rect bbox = fz_unit_rect;
- fz_transform_rect(&bbox, ctm);
+ fz_rect bbox = fz_transform_rect(fz_unit_rect, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_image_mask);
}
else
diff --git a/source/fitz/document.c b/source/fitz/document.c
index b74f7de5..3dc41a75 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -328,25 +328,23 @@ fz_load_page(fz_context *ctx, fz_document *doc, int number)
fz_link *
fz_load_links(fz_context *ctx, fz_page *page)
{
- if (page && page->load_links && page)
+ if (page && page->load_links)
return page->load_links(ctx, page);
return NULL;
}
-fz_rect *
-fz_bound_page(fz_context *ctx, fz_page *page, fz_rect *r)
+fz_rect
+fz_bound_page(fz_context *ctx, fz_page *page)
{
- if (page && page->bound_page && page && r)
- return page->bound_page(ctx, page, r);
- if (r)
- *r = fz_empty_rect;
- return r;
+ if (page && page->bound_page)
+ return page->bound_page(ctx, page);
+ return fz_empty_rect;
}
fz_annot *
fz_first_annot(fz_context *ctx, fz_page *page)
{
- if (page && page->first_annot && page)
+ if (page && page->first_annot)
return page->first_annot(ctx, page);
return NULL;
}
@@ -359,14 +357,12 @@ fz_next_annot(fz_context *ctx, fz_annot *annot)
return NULL;
}
-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)
{
- if (annot && annot->bound_annot && rect)
- return annot->bound_annot(ctx, annot, rect);
- if (rect)
- *rect = fz_empty_rect;
- return rect;
+ if (annot && annot->bound_annot)
+ return annot->bound_annot(ctx, annot);
+ return fz_empty_rect;
}
void
diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c
index 129dfeb4..9f626415 100644
--- a/source/fitz/draw-affine.c
+++ b/source/fitz/draw-affine.c
@@ -3693,175 +3693,176 @@ fz_paint_affine_color_near_spots(int da, int sa, int fa, int fb, int dn, int sn,
* would not be safe in the general case, but gives less distortion across
* neighbouring images when tiling is used. We use this for .gproof files.
*/
-void
-fz_gridfit_matrix(int as_tiled, fz_matrix *m)
+fz_matrix
+fz_gridfit_matrix(int as_tiled, fz_matrix m)
{
- if (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON)
+ if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
{
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->e + 0.5f);
- m->a += m->e - f; /* Adjust width for change */
- m->e = f;
+ f = (float)(int)(m.e + 0.5f);
+ m.a += m.e - f; /* Adjust width for change */
+ m.e = f;
/* Nearest boundary for right (width really) */
- m->a = (float)(int)(m->a + 0.5f);
+ m.a = (float)(int)(m.a + 0.5f);
}
- else if (m->a > 0)
+ else if (m.a > 0)
{
float f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->e);
- if (f - m->e > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (f - m.e > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->a += m->e - f; /* width gets wider as f <= m.e */
- m->e = f;
+ m.a += m.e - f; /* width gets wider as f <= m.e */
+ m.e = f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->a);
- if (m->a - f > MY_EPSILON)
+ f = (float)(int)(m.a);
+ if (m.a - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->a = f;
+ m.a = f;
}
- else if (m->a < 0)
+ else if (m.a < 0)
{
float f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->e);
- if (m->e - f > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (m.e - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->a += m->e - f; /* width gets wider (more -ve) */
- m->e = f;
+ m.a += m.e - f; /* width gets wider (more -ve) */
+ m.e = f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->a);
- if (f - m->a > MY_EPSILON)
+ f = (float)(int)(m.a);
+ if (f - m.a > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->a = f;
+ m.a = f;
}
if (as_tiled)
{
float f;
/* Nearest boundary for top */
- f = (float)(int)(m->f + 0.5f);
- m->d += m->f - f; /* Adjust width for change */
- m->f = f;
+ f = (float)(int)(m.f + 0.5f);
+ m.d += m.f - f; /* Adjust width for change */
+ m.f = f;
/* Nearest boundary for bottom (height really) */
- m->d = (float)(int)(m->d + 0.5f);
+ m.d = (float)(int)(m.d + 0.5f);
}
- else if (m->d > 0)
+ else if (m.d > 0)
{
float f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->f);
- if (f - m->f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (f - m.f > MY_EPSILON)
f -= 1.0f; /* Ensure it moves upwards */
- m->d += m->f - f; /* width gets wider as f <= m.f */
- m->f = f;
+ m.d += m.f - f; /* width gets wider as f <= m.f */
+ m.f = f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->d);
- if (m->d - f > MY_EPSILON)
+ f = (float)(int)(m.d);
+ if (m.d - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->d = f;
+ m.d = f;
}
- else if (m->d < 0)
+ else if (m.d < 0)
{
float f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->f);
- if (m->f - f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (m.f - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->d += m->f - f; /* width gets wider (more -ve) */
- m->f = f;
+ m.d += m.f - f; /* width gets wider (more -ve) */
+ m.f = f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->d);
- if (f - m->d > MY_EPSILON)
+ f = (float)(int)(m.d);
+ if (f - m.d > MY_EPSILON)
f -= 1.0f; /* Ensure it moves up */
- m->d = f;
+ m.d = f;
}
}
- else if (fabsf(m->a) < FLT_EPSILON && fabsf(m->d) < FLT_EPSILON)
+ else if (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON)
{
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->e + 0.5f);
- m->b += m->e - f; /* Adjust width for change */
- m->e = f;
+ f = (float)(int)(m.e + 0.5f);
+ m.b += m.e - f; /* Adjust width for change */
+ m.e = f;
/* Nearest boundary for right (width really) */
- m->b = (float)(int)(m->b + 0.5f);
+ m.b = (float)(int)(m.b + 0.5f);
}
- else if (m->b > 0)
+ else if (m.b > 0)
{
float f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->f);
- if (f - m->f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (f - m.f > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->b += m->f - f; /* width gets wider as f <= m.f */
- m->f = f;
+ m.b += m.f - f; /* width gets wider as f <= m.f */
+ m.f = f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->b);
- if (m->b - f > MY_EPSILON)
+ f = (float)(int)(m.b);
+ if (m.b - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->b = f;
+ m.b = f;
}
- else if (m->b < 0)
+ else if (m.b < 0)
{
float f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->f);
- if (m->f - f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (m.f - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->b += m->f - f; /* width gets wider (more -ve) */
- m->f = f;
+ m.b += m.f - f; /* width gets wider (more -ve) */
+ m.f = f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->b);
- if (f - m->b > MY_EPSILON)
+ f = (float)(int)(m.b);
+ if (f - m.b > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->b = f;
+ m.b = f;
}
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->f + 0.5f);
- m->c += m->f - f; /* Adjust width for change */
- m->f = f;
+ f = (float)(int)(m.f + 0.5f);
+ m.c += m.f - f; /* Adjust width for change */
+ m.f = f;
/* Nearest boundary for right (width really) */
- m->c = (float)(int)(m->c + 0.5f);
+ m.c = (float)(int)(m.c + 0.5f);
}
- else if (m->c > 0)
+ else if (m.c > 0)
{
float f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->e);
- if (f - m->e > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (f - m.e > MY_EPSILON)
f -= 1.0f; /* Ensure it moves upwards */
- m->c += m->e - f; /* width gets wider as f <= m.e */
- m->e = f;
+ m.c += m.e - f; /* width gets wider as f <= m.e */
+ m.e = f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->c);
- if (m->c - f > MY_EPSILON)
+ f = (float)(int)(m.c);
+ if (m.c - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->c = f;
+ m.c = f;
}
- else if (m->c < 0)
+ else if (m.c < 0)
{
float f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->e);
- if (m->e - f > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (m.e - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->c += m->e - f; /* width gets wider (more -ve) */
- m->e = f;
+ m.c += m.e - f; /* width gets wider (more -ve) */
+ m.e = f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->c);
- if (f - m->c > MY_EPSILON)
+ f = (float)(int)(m.c);
+ if (f - m.c > MY_EPSILON)
f -= 1.0f; /* Ensure it moves up */
- m->c = f;
+ m.c = f;
}
}
+ return m;
}
/* Draw an image with an affine transform on destination */
@@ -3876,19 +3877,18 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
fz_irect bbox;
int dolerp;
paintfn_t *paintfn;
- fz_matrix local_ctm = *ctm;
- fz_rect rect;
+ fz_matrix local_ctm;
int is_rectilinear;
if (alpha == 0)
return;
/* grid fit the image */
- fz_gridfit_matrix(as_tiled, &local_ctm);
+ local_ctm = fz_gridfit_matrix(as_tiled, *ctm);
/* turn on interpolation for upscaled and non-rectilinear transforms */
dolerp = 0;
- is_rectilinear = fz_is_rectilinear(&local_ctm);
+ is_rectilinear = fz_is_rectilinear(local_ctm);
if (!is_rectilinear)
dolerp = lerp_allowed;
if (sqrtf(local_ctm.a * local_ctm.a + local_ctm.b * local_ctm.b) > img->w)
@@ -3905,9 +3905,8 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
dolerp = 0;
}
- rect = fz_unit_rect;
- fz_irect_from_rect(&bbox, fz_transform_rect(&rect, &local_ctm));
- fz_intersect_irect(&bbox, scissor);
+ bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, local_ctm));
+ bbox = fz_intersect_irect(bbox, *scissor);
x = bbox.x0;
if (shape && shape->x > x)
@@ -3935,8 +3934,8 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
return;
/* map from screen space (x,y) to image space (u,v) */
- fz_pre_scale(&local_ctm, 1.0f / img->w, 1.0f / img->h);
- fz_invert_matrix(&local_ctm, &local_ctm);
+ local_ctm = fz_pre_scale(local_ctm, 1.0f / img->w, 1.0f / img->h);
+ local_ctm = fz_invert_matrix(local_ctm);
fa = (int)(local_ctm.a *= 65536.0f);
fb = (int)(local_ctm.b *= 65536.0f);
diff --git a/source/fitz/draw-blend.c b/source/fitz/draw-blend.c
index 79f82046..21705a90 100644
--- a/source/fitz/draw-blend.c
+++ b/source/fitz/draw-blend.c
@@ -1073,7 +1073,6 @@ fz_blend_pixmap(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap * FZ_RES
unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n;
int da, sa;
int complement;
@@ -1098,9 +1097,7 @@ fz_blend_pixmap(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap * FZ_RES
}
}
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, src), fz_pixmap_bbox(ctx, dst));
x = bbox.x0;
y = bbox.y0;
@@ -1298,15 +1295,14 @@ fz_blend_pixmap_knockout(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap
{
unsigned char *sp;
unsigned char *dp;
- fz_irect bbox;
- fz_irect bbox2;
+ fz_irect sbox, dbox, bbox;
int x, y, w, h, n;
int da, sa;
const unsigned char *hp;
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ dbox = fz_pixmap_bbox_no_ctx(dst);
+ sbox = fz_pixmap_bbox_no_ctx(src);
+ bbox = fz_intersect_irect(dbox, sbox);
x = bbox.x0;
y = bbox.y0;
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index f497949a..63b20f67 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -209,14 +209,14 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
state = push_stack(ctx, dev);
STACK_PUSHED("knockout");
- fz_pixmap_bbox(ctx, state->dest, &bbox);
- fz_intersect_irect(&bbox, &state->scissor);
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
+ bbox = fz_pixmap_bbox(ctx, state->dest);
+ bbox = fz_intersect_irect(bbox, state->scissor);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
if (state[0].group_alpha)
{
- fz_pixmap_bbox(ctx, state->group_alpha, &ga_bbox);
- fz_intersect_irect(&ga_bbox, &state->scissor);
- ga = fz_new_pixmap_with_bbox(ctx, state->group_alpha->colorspace, &ga_bbox, state->group_alpha->seps, state->group_alpha->alpha);
+ ga_bbox = fz_pixmap_bbox(ctx, state->group_alpha);
+ ga_bbox = fz_intersect_irect(ga_bbox, state->scissor);
+ ga = fz_new_pixmap_with_bbox(ctx, state->group_alpha->colorspace, ga_bbox, state->group_alpha->seps, state->group_alpha->alpha);
}
if (isolated)
@@ -238,11 +238,11 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
}
if (prev->dest)
{
- fz_copy_pixmap_rect(ctx, dest, prev->dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, prev->dest, bbox, dev->default_cs);
if (ga)
{
if (prev->group_alpha)
- fz_copy_pixmap_rect(ctx, ga, prev->group_alpha, &ga_bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, ga, prev->group_alpha, ga_bbox, dev->default_cs);
else
fz_clear_pixmap(ctx, ga);
}
@@ -256,7 +256,7 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
}
/* Knockout groups (and only knockout groups) rely on shape */
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "");
@@ -341,13 +341,6 @@ static void fz_knockout_end(fz_context *ctx, fz_draw_device *dev)
#endif
}
-static inline fz_matrix concat(const fz_matrix *one, const fz_matrix *two)
-{
- fz_matrix ctm;
- fz_concat(&ctm, one, two);
- return ctm;
-}
-
static int
colors_supported(fz_context *ctx, fz_colorspace *cs, fz_pixmap *dest)
{
@@ -612,10 +605,10 @@ fz_draw_fill_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
fz_colorspace *colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
unsigned char colorbv[FZ_MAX_COLORS + 1];
fz_irect bbox;
@@ -629,7 +622,7 @@ fz_draw_fill_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
if (flatness < 0.001f)
flatness = 0.001f;
- fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest, &bbox), &state->scissor);
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
if (fz_flatten_fill_path(ctx, rast, path, &ctm, flatness, &bbox, &bbox))
return;
@@ -665,10 +658,10 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
fz_colorspace *colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
float linewidth = stroke->linewidth;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -689,7 +682,7 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
if (flatness < 0.001f)
flatness = 0.001f;
- fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest, &bbox), &state->scissor);
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest), state->scissor);
if (fz_flatten_stroke_path(ctx, rast, path, stroke, &ctm, flatness, linewidth, &bbox, &bbox))
return;
@@ -742,12 +735,12 @@ static void
fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int even_odd, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
- fz_irect bbox, pixmap_bbox;
+ fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
@@ -763,16 +756,13 @@ fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
if (scissor)
{
- fz_rect rect = *scissor;
- fz_transform_rect(&rect, &dev->transform);
- fz_irect_from_rect(&bbox, &rect);
- fz_intersect_irect(&bbox, &state->scissor);
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_irect_from_rect(fz_transform_rect(*scissor, dev->transform));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox(ctx, state->dest));
+ bbox = fz_intersect_irect(bbox, state->scissor);
}
else
{
- bbox = state->scissor;
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
}
if (fz_flatten_fill_path(ctx, rast, path, &ctm, flatness, &bbox, &bbox) || fz_is_rect_rasterizer(ctx, rast))
@@ -787,18 +777,18 @@ fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state[1].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[1].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -819,13 +809,13 @@ static void
fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
float linewidth = stroke->linewidth;
- fz_irect bbox, pixmap_bbox;
+ fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
float aa_level = 2.0f/(fz_rasterizer_graphics_aa_level(rast)+2);
@@ -847,19 +837,15 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
if (scissor)
{
- fz_rect rect = *scissor;
- fz_transform_rect(&rect, &dev->transform);
- fz_irect_from_rect(&bbox, &rect);
- fz_intersect_irect(&bbox, &state->scissor);
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_irect_from_rect(fz_transform_rect(*scissor, dev->transform));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox(ctx, state->dest));
+ bbox = fz_intersect_irect(bbox, state->scissor);
}
else
{
- bbox = state->scissor;
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
}
-
if (fz_flatten_stroke_path(ctx, rast, path, stroke, &ctm, flatness, linewidth, &bbox, &bbox))
{
state[1].scissor = bbox;
@@ -872,25 +858,25 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, state[1].dest);
else
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state->group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -913,16 +899,17 @@ draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_glyph *glyph,
int xorig, int yorig, const fz_irect *scissor, fz_overprint *eop)
{
unsigned char *dp;
- fz_irect bbox, bbox2;
+ fz_irect bbox;
int x, y, w, h;
int skip_x, skip_y;
fz_pixmap *msk;
- fz_glyph_bbox_no_ctx(glyph, &bbox);
- fz_translate_irect(&bbox, xorig, yorig);
- fz_intersect_irect(&bbox, scissor); /* scissor < dst */
+ bbox = fz_glyph_bbox_no_ctx(glyph);
+ bbox = fz_translate_irect(bbox, xorig, yorig);
+ bbox = fz_intersect_irect(bbox, *scissor); /* scissor < dst */
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(dst));
- if (fz_is_empty_irect(fz_intersect_irect(&bbox, fz_pixmap_bbox_no_ctx(dst, &bbox2))))
+ if (fz_is_empty_irect(bbox))
return;
x = bbox.x0;
@@ -982,7 +969,7 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -1029,7 +1016,7 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_glyph(ctx, span->font, gid, &trm, model, &state->scissor, state->dest->alpha, fz_rasterizer_text_aa_level(rast));
if (glyph)
@@ -1079,7 +1066,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const
const fz_matrix *in_ctm, fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_draw_state *state = &dev->stack[dev->top];
unsigned char colorbv[FZ_MAX_COLORS + 1];
unsigned char solid = 255;
@@ -1118,7 +1105,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_stroked_glyph(ctx, span->font, gid, &trm, &ctm, stroke, &state->scissor, aa);
if (glyph)
@@ -1156,7 +1143,7 @@ static void
fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *mask, *dest, *shape, *group_alpha;
fz_matrix tm, trm;
@@ -1165,7 +1152,6 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
fz_draw_state *state;
fz_colorspace *model;
fz_text_span *span;
- fz_rect rect;
fz_rasterizer *rast = dev->rast;
if (dev->top == 0 && dev->resolve_spots)
@@ -1176,39 +1162,37 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
model = state->dest->colorspace;
/* make the mask the exact size needed */
- fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, NULL, &ctm, &rect));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_bound_text(ctx, text, NULL, ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
fz_try(ctx)
{
- mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, dest);
else
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
else
shape = NULL;
if (state->group_alpha)
{
- group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
else
@@ -1224,7 +1208,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
dump_spaces(dev->top-1, "Clip (text) begin\n");
#endif
- if (!fz_is_empty_irect(&bbox) && mask)
+ if (!fz_is_empty_irect(bbox) && mask)
{
for (span = text->head; span; span = span->next)
{
@@ -1238,7 +1222,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_glyph(ctx, span->font, gid, &trm, model, &state->scissor, state[1].dest->alpha, fz_rasterizer_text_aa_level(rast));
if (glyph)
@@ -1297,7 +1281,7 @@ static void
fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *mask, *dest, *shape, *group_alpha;
fz_matrix tm, trm;
@@ -1306,47 +1290,45 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
fz_draw_state *state = push_stack(ctx, dev);
fz_colorspace *model = state->dest->colorspace;
fz_text_span *span;
- fz_rect rect;
int aa = fz_rasterizer_text_aa_level(dev->rast);
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
STACK_PUSHED("clip stroke text");
+
/* make the mask the exact size needed */
- fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, stroke, &ctm, &rect));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_bound_text(ctx, text, stroke, ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
fz_try(ctx)
{
- state[1].mask = mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, state[1].dest);
else
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
else
shape = state->shape;
if (state->group_alpha)
{
- state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
else
@@ -1358,7 +1340,7 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
dump_spaces(dev->top-1, "Clip (stroke text) begin\n");
#endif
- if (!fz_is_empty_irect(&bbox))
+ if (!fz_is_empty_irect(bbox))
{
for (span = text->head; span; span = span->next)
{
@@ -1372,7 +1354,7 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_stroked_glyph(ctx, span->font, gid, &trm, &ctm, stroke, &state->scissor, aa);
if (glyph)
@@ -1437,8 +1419,7 @@ static void
fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_matrix *in_ctm, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
- fz_rect bounds;
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox, scissor;
fz_pixmap *dest, *shape, *group_alpha;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -1451,11 +1432,11 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, color_params, dev->default_cs);
- fz_bound_shade(ctx, shade, &ctm, &bounds);
scissor = state->scissor;
- fz_intersect_irect(fz_irect_from_rect(&bbox, &bounds), &scissor);
+ bbox = fz_irect_from_rect(fz_bound_shade(ctx, shade, ctm));
+ bbox = fz_intersect_irect(bbox, scissor);
- if (fz_is_empty_irect(&bbox))
+ if (fz_is_empty_irect(bbox))
return;
if (color_params == NULL)
@@ -1470,19 +1451,19 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (alpha < 1)
{
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
if (state->dest->alpha)
fz_clear_pixmap(ctx, dest);
else
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
if (shape)
{
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
if (group_alpha)
{
- group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
}
@@ -1563,9 +1544,9 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
fz_paint_shade(ctx, shade, colorspace, &ctm, dest, color_params, &bbox, eop);
if (shape)
- fz_clear_pixmap_rect_with_value(ctx, shape, 255, &bbox);
+ fz_clear_pixmap_rect_with_value(ctx, shape, 255, bbox);
if (group_alpha)
- fz_clear_pixmap_rect_with_value(ctx, group_alpha, 255, &bbox);
+ fz_clear_pixmap_rect_with_value(ctx, group_alpha, 255, bbox);
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top, "");
@@ -1609,7 +1590,7 @@ fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, const fz_pixmap *image
fz_matrix m = *ctm;
if (gridfit)
{
- fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, &m);
+ m = fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, m);
}
scaled = fz_scale_pixmap_cached(ctx, image, m.e, m.f, m.a, m.d, clip, dev->cache_x, dev->cache_y);
if (!scaled)
@@ -1627,7 +1608,7 @@ fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, const fz_pixmap *image
fz_matrix m = *ctm;
fz_irect rclip;
if (gridfit)
- fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, &m);
+ m = fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, m);
if (clip)
{
rclip.x0 = clip->y0;
@@ -1704,7 +1685,7 @@ static void
fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *in_ctm, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
fz_pixmap *pixmap;
int after;
int dx, dy;
@@ -1724,7 +1705,7 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
state = push_group_for_separations(ctx, dev, color_params, dev->default_cs);
model = state->dest->colorspace;
- fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest, &clip), &state->scissor);
+ clip = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
if (image->w == 0 || image->h == 0)
return;
@@ -1735,7 +1716,7 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
/* ctm maps the image (expressed as the unit square) onto the
* destination device. Reverse that to get a mapping from
* the destination device to the source pixels. */
- if (fz_try_invert_matrix(&inverse, &local_ctm))
+ if (fz_try_invert_matrix(&inverse, local_ctm))
{
/* Not invertible. Could just bail? Use the whole image
* for now. */
@@ -1750,20 +1731,20 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
fz_rect rect;
fz_irect sane;
/* We want to scale from image coords, not from unit square */
- fz_post_scale(&inverse, image->w, image->h);
+ inverse = fz_post_scale(inverse, image->w, image->h);
/* Are we scaling up or down? exp < 1 means scaling down. */
- exp = fz_matrix_max_expansion(&inverse);
- fz_rect_from_irect(&rect, &clip);
- fz_transform_rect(&rect, &inverse);
+ exp = fz_matrix_max_expansion(inverse);
+ rect = fz_rect_from_irect(clip);
+ rect = fz_transform_rect(rect, inverse);
/* Allow for support requirements for scalers. */
- fz_expand_rect(&rect, fz_max(exp, 1) * 4);
- fz_irect_from_rect(&src_area, &rect);
+ rect = fz_expand_rect(rect, fz_max(exp, 1) * 4);
+ src_area = fz_irect_from_rect(rect);
sane.x0 = 0;
sane.y0 = 0;
sane.x1 = image->w;
sane.y1 = image->h;
- fz_intersect_irect(&src_area, &sane);
- if (fz_is_empty_irect(&src_area))
+ src_area = fz_intersect_irect(src_area, sane);
+ if (fz_is_empty_irect(src_area))
return;
}
@@ -1852,7 +1833,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
unsigned char colorbv[FZ_MAX_COLORS + 1];
fz_pixmap *scaled = NULL;
fz_pixmap *pixmap;
@@ -1874,8 +1855,8 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
if (colorspace_in)
colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- fz_pixmap_bbox(ctx, state->dest, &clip);
- fz_intersect_irect(&clip, &state->scissor);
+ clip = fz_pixmap_bbox(ctx, state->dest);
+ clip = fz_intersect_irect(clip, state->scissor);
if (image->w == 0 || image->h == 0)
return;
@@ -1883,7 +1864,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
/* ctm maps the image (expressed as the unit square) onto the
* destination device. Reverse that to get a mapping from
* the destination device to the source pixels. */
- if (fz_try_invert_matrix(&inverse, &local_ctm))
+ if (fz_try_invert_matrix(&inverse, local_ctm))
{
/* Not invertible. Could just bail? Use the whole image
* for now. */
@@ -1898,20 +1879,20 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_rect rect;
fz_irect sane;
/* We want to scale from image coords, not from unit square */
- fz_post_scale(&inverse, image->w, image->h);
+ inverse = fz_post_scale(inverse, image->w, image->h);
/* Are we scaling up or down? exp < 1 means scaling down. */
- exp = fz_matrix_max_expansion(&inverse);
- fz_rect_from_irect(&rect, &clip);
- fz_transform_rect(&rect, &inverse);
+ exp = fz_matrix_max_expansion(inverse);
+ rect = fz_rect_from_irect(clip);
+ rect = fz_transform_rect(rect, inverse);
/* Allow for support requirements for scalers. */
- fz_expand_rect(&rect, fz_max(exp, 1) * 4);
- fz_irect_from_rect(&src_area, &rect);
+ rect = fz_expand_rect(rect, fz_max(exp, 1) * 4);
+ src_area = fz_irect_from_rect(rect);
sane.x0 = 0;
sane.y0 = 0;
sane.x1 = image->w;
sane.y1 = image->h;
- fz_intersect_irect(&src_area, &sane);
- if (fz_is_empty_irect(&src_area))
+ src_area = fz_intersect_irect(src_area, sane);
+ if (fz_is_empty_irect(src_area))
return;
}
@@ -1960,7 +1941,7 @@ static void
fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *scaled = NULL;
fz_pixmap *pixmap = NULL;
@@ -1968,14 +1949,13 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_draw_state *state = push_stack(ctx, dev);
fz_colorspace *model = state->dest->colorspace;
fz_irect clip;
- fz_rect urect;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
STACK_PUSHED("clip image mask");
- fz_pixmap_bbox(ctx, state->dest, &clip);
- fz_intersect_irect(&clip, &state->scissor);
+ clip = fz_pixmap_bbox(ctx, state->dest);
+ clip = fz_intersect_irect(clip, state->scissor);
if (image->w == 0 || image->h == 0)
{
@@ -1991,34 +1971,31 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
dump_spaces(dev->top-1, "Clip (image mask) begin\n");
#endif
- urect = fz_unit_rect;
- fz_irect_from_rect(&bbox, fz_transform_rect(&urect, &local_ctm));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, local_ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
pixmap = fz_get_pixmap_from_image(ctx, image, NULL, &local_ctm, &dx, &dy);
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state[0].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[0].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -2145,7 +2122,7 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
fz_draw_state *state = push_stack(ctx, dev);
fz_pixmap *shape = state->shape;
fz_pixmap *group_alpha = state->group_alpha;
- fz_rect trect = *rect;
+ fz_rect trect;
fz_colorspace *colorspace = NULL;
if (dev->top == 0 && dev->resolve_spots)
@@ -2158,8 +2135,8 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
color_params = fz_default_color_params(ctx);
STACK_PUSHED("mask");
- fz_transform_rect(&trect, &dev->transform);
- fz_intersect_irect(fz_irect_from_rect(&bbox, &trect), &state->scissor);
+ trect = fz_transform_rect(*rect, dev->transform);
+ bbox = fz_intersect_irect(fz_irect_from_rect(trect), state->scissor);
/* Reset the blendmode for the mask rendering. In particular,
* don't carry forward knockout or isolated. */
@@ -2171,9 +2148,9 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
* If !luminosity, then we generate a mask from the alpha value of the shapes.
*/
if (luminosity)
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), &bbox, NULL, 0);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), bbox, NULL, 0);
else
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
if (state->shape)
{
/* FIXME: If we ever want to support AIS true, then
@@ -2268,9 +2245,9 @@ fz_draw_end_mask(fz_context *ctx, fz_device *devp)
#endif
/* create new dest scratch buffer */
- fz_pixmap_bbox(ctx, temp, &bbox);
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
- fz_copy_pixmap_rect(ctx, dest, state->dest, &bbox, dev->default_cs);
+ bbox = fz_pixmap_bbox(ctx, temp);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
+ fz_copy_pixmap_rect(ctx, dest, state->dest, bbox, dev->default_cs);
/* push soft mask as clip mask */
state[1].dest = dest;
@@ -2279,12 +2256,12 @@ fz_draw_end_mask(fz_context *ctx, fz_device *devp)
* clip mask when we pop. So create a new shape now. */
if (state[0].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[0].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
state[1].scissor = bbox;
@@ -2303,7 +2280,7 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
fz_pixmap *dest;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_rect trect = *rect;
+ fz_rect trect;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
@@ -2316,8 +2293,8 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
state = push_stack(ctx, dev);
STACK_PUSHED("group");
- fz_transform_rect(&trect, &dev->transform);
- fz_intersect_irect(fz_irect_from_rect(&bbox, &trect), &state->scissor);
+ trect = fz_transform_rect(*rect, dev->transform);
+ bbox = fz_intersect_irect(fz_irect_from_rect(trect), state->scissor);
fz_try(ctx)
{
@@ -2326,7 +2303,7 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
isolated = 1;
#endif
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha || isolated);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha || isolated);
if (isolated)
{
@@ -2335,8 +2312,8 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
}
else
{
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -2607,13 +2584,13 @@ static int
fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *in_ctm, int id)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_pixmap *dest = NULL;
fz_pixmap *shape, *group_alpha;
fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_rect local_view = *view;
+ fz_rect local_view;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
@@ -2626,7 +2603,8 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state = push_stack(ctx, dev);
STACK_PUSHED("tile");
- fz_irect_from_rect(&bbox, fz_transform_rect(&local_view, &ctm));
+ local_view = fz_transform_rect(*view, ctm);
+ bbox = fz_irect_from_rect(local_view);
/* We should never have a bbox that entirely covers our destination.
* If we do, then the check for only 1 tile being visible above has
* failed. Actually, this *can* fail due to the round_rect, at extreme
@@ -2658,7 +2636,7 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state[1].ystep = ystep;
state[1].id = id;
state[1].encache = 0;
- fz_irect_from_rect(&state[1].area, area);
+ state[1].area = fz_irect_from_rect(*area);
state[1].ctm = ctm;
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "Tile begin (cached)\n");
@@ -2673,18 +2651,18 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
fz_try(ctx)
{
/* Patterns can be transparent, so we need to have an alpha here. */
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, 1);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, 1);
fz_clear_pixmap(ctx, dest);
shape = state[0].shape;
if (shape)
{
- state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
group_alpha = state[0].group_alpha;
if (group_alpha)
{
- state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
state[1].blendmode |= FZ_BLEND_ISOLATED;
@@ -2692,7 +2670,7 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state[1].ystep = ystep;
state[1].id = id;
state[1].encache = 1;
- fz_irect_from_rect(&state[1].area, area);
+ state[1].area = fz_irect_from_rect(*area);
state[1].ctm = ctm;
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "Tile begin\n");
@@ -2737,16 +2715,20 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
/* Fudge the scissor bbox a little to allow for inaccuracies in the
* matrix inversion. */
- fz_rect_from_irect(&scissor_tmp, &state[0].scissor);
- fz_transform_rect(fz_expand_rect(&scissor_tmp, 1), fz_invert_matrix(&ttm, &ctm));
- fz_intersect_irect(&area, fz_irect_from_rect(&scissor, &scissor_tmp));
+ ttm = fz_invert_matrix(ctm);
+ scissor_tmp = fz_rect_from_irect(state[0].scissor);
+ scissor_tmp = fz_expand_rect(scissor_tmp, 1);
+ scissor_tmp = fz_transform_rect(scissor_tmp, ttm);
+ scissor = fz_irect_from_rect(scissor_tmp);
+ area = fz_intersect_irect(area, scissor);
tile_bbox.x0 = state[1].dest->x;
tile_bbox.y0 = state[1].dest->y;
tile_bbox.x1 = state[1].dest->w + tile_bbox.x0;
tile_bbox.y1 = state[1].dest->h + tile_bbox.y0;
- fz_rect_from_irect(&tile_tmp, &tile_bbox);
- fz_transform_rect(fz_expand_rect(&tile_tmp, 1), &ttm);
+ tile_tmp = fz_rect_from_irect(tile_bbox);
+ tile_tmp = fz_expand_rect(tile_tmp, 1);
+ tile_tmp = fz_transform_rect(tile_tmp, ttm);
/* FIXME: area is a bbox, so FP not appropriate here */
/* In PDF files xstep/ystep can be smaller than view (the area of a
@@ -2807,8 +2789,7 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
{
for (x = x0; x < x1; x++)
{
- ttm = ctm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(ctm, x * xstep, y * ystep);
dest->x = ttm.e;
dest->y = ttm.f;
/* Check for overflow due to float -> int conversions */
@@ -2819,16 +2800,14 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
fz_paint_pixmap_with_bbox(state[0].dest, dest, 255, state[0].scissor);
if (shape)
{
- ttm = shapectm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(shapectm, x * xstep, y * ystep);
shape->x = ttm.e;
shape->y = ttm.f;
fz_paint_pixmap_with_bbox(state[0].shape, shape, 255, state[0].scissor);
}
if (group_alpha)
{
- ttm = gactm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(gactm, x * xstep, y * ystep);
group_alpha->x = ttm.e;
group_alpha->y = ttm.f;
fz_paint_pixmap_with_bbox(state[0].group_alpha, group_alpha, 255, state[0].scissor);
@@ -3251,9 +3230,9 @@ fz_new_draw_device_with_options(fz_context *ctx, const fz_draw_options *opts, co
fz_set_rasterizer_graphics_aa_level(ctx, &aa, opts->graphics);
fz_set_rasterizer_text_aa_level(ctx, &aa, opts->text);
- fz_pre_rotate(fz_scale(&transform, x_zoom, y_zoom), opts->rotate);
+ transform = fz_pre_rotate(fz_scale(x_zoom, y_zoom), opts->rotate);
bounds = *mediabox;
- fz_round_rect(&ibounds, fz_transform_rect(&bounds, &transform));
+ ibounds = fz_round_rect(fz_transform_rect(bounds, transform));
/* If width or height are set, we may need to adjust the transform */
if (w || h)
@@ -3277,13 +3256,13 @@ fz_new_draw_device_with_options(fz_context *ctx, const fz_draw_options *opts, co
}
if (scalex != 1 || scaley != 1)
{
- fz_pre_scale(&transform, scalex, scaley);
+ transform = fz_pre_scale(transform, scalex, scaley);
bounds = *mediabox;
- fz_round_rect(&ibounds, fz_transform_rect(&bounds, &transform));
+ ibounds = fz_round_rect(fz_transform_rect(bounds, transform));
}
}
- *pixmap = fz_new_pixmap_with_bbox(ctx, opts->colorspace, &ibounds, NULL/* FIXME */, opts->alpha);
+ *pixmap = fz_new_pixmap_with_bbox(ctx, opts->colorspace, ibounds, NULL/* FIXME */, opts->alpha);
fz_try(ctx)
{
fz_set_pixmap_resolution(ctx, *pixmap, opts->x_resolution, opts->y_resolution);
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c
index 75bfd616..7696a59c 100644
--- a/source/fitz/draw-glyph.c
+++ b/source/fitz/draw-glyph.c
@@ -138,7 +138,7 @@ fz_keep_glyph_cache(fz_context *ctx)
float
fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsigned char *qe, unsigned char *qf)
{
- float size = fz_matrix_expansion(ctm);
+ float size = fz_matrix_expansion(*ctm);
int q;
float pix_e, pix_f, r;
diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h
index 9c160e6e..eb3e36d2 100644
--- a/source/fitz/draw-imp.h
+++ b/source/fitz/draw-imp.h
@@ -267,7 +267,7 @@ static inline void fz_drop_rasterizer(fz_context *ctx, fz_rasterizer *r)
After this, the edges should be 'inserted' into the rasterizer.
*/
-int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *r, const fz_irect *clip);
+int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *r, fz_irect clip);
/*
fz_insert_rasterizer: Insert an edge into a rasterizer.
@@ -342,13 +342,13 @@ static inline void fz_postindex_rasterizer(fz_context *ctx, fz_rasterizer *r)
fz_bound_rasterizer: Once a set of edges has been fed into a
rasterizer, the (device space) bounding box can be retrieved.
*/
-fz_irect *fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *bbox);
+fz_irect fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast);
/*
fz_scissor_rasterizer: Retrieve the clipping box with which the
rasterizer was reset.
*/
-fz_rect *fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_rect *r);
+fz_rect fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast);
/*
fz_convert_rasterizer: Convert the set of edges that have
diff --git a/source/fitz/draw-mesh.c b/source/fitz/draw-mesh.c
index a248170e..5a3bef40 100644
--- a/source/fitz/draw-mesh.c
+++ b/source/fitz/draw-mesh.c
@@ -230,13 +230,13 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
fz_try(ctx)
{
- fz_concat(&local_ctm, &shade->matrix, ctm);
+ local_ctm = fz_concat(shade->matrix, *ctm);
if (shade->use_function)
{
/* We need to use alpha = 1 here, because the shade might not fill
* the bbox. */
- temp = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), bbox, NULL, 1);
+ temp = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), *bbox, NULL, 1);
fz_clear_pixmap(ctx, temp);
}
else
@@ -249,7 +249,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
ptd.bbox = bbox;
fz_init_cached_color_converter(ctx, &ptd.cc, NULL, temp->colorspace, colorspace, color_params);
- fz_process_shade(ctx, shade, &local_ctm, prepare_mesh_vertex, &do_paint_tri, &ptd);
+ fz_process_shade(ctx, shade, local_ctm, prepare_mesh_vertex, &do_paint_tri, &ptd);
if (shade->use_function)
{
@@ -275,7 +275,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
int n = fz_colorspace_n(ctx, colorspace);
/* alpha = 1 here for the same reason as earlier */
- conv = fz_new_pixmap_with_bbox(ctx, colorspace, bbox, NULL, 1);
+ conv = fz_new_pixmap_with_bbox(ctx, colorspace, *bbox, NULL, 1);
d = conv->samples;
while (hh--)
{
@@ -322,7 +322,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
}
fz_drop_color_converter(ctx, &cc);
- conv = fz_new_pixmap_with_bbox(ctx, dest->colorspace, bbox, dest->seps, 1);
+ conv = fz_new_pixmap_with_bbox(ctx, dest->colorspace, *bbox, dest->seps, 1);
d = conv->samples;
da = conv->alpha;
while (hh--)
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c
index 9485565d..027fe538 100644
--- a/source/fitz/draw-paint.c
+++ b/source/fitz/draw-paint.c
@@ -2171,7 +2171,6 @@ fz_paint_pixmap_with_bbox(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
const unsigned char *sp;
unsigned char *dp;
int x, y, w, h, n, da, sa;
- fz_irect bbox2;
fz_span_painter_t *fn;
assert(dst->n - dst->alpha == src->n - src->alpha);
@@ -2179,10 +2178,8 @@ fz_paint_pixmap_with_bbox(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
if (alpha == 0)
return;
- fz_pixmap_bbox_no_ctx(dst, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(dst));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(src));
x = bbox.x0;
y = bbox.y0;
@@ -2217,7 +2214,6 @@ fz_paint_pixmap(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT src,
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n, da, sa;
fz_span_painter_t *fn;
@@ -2231,10 +2227,7 @@ fz_paint_pixmap(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT src,
}
assert(dst->n - dst->alpha == src->n - src->alpha);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2300,7 +2293,6 @@ fz_paint_pixmap_alpha(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n;
if (alpha == 0)
@@ -2308,10 +2300,7 @@ fz_paint_pixmap_alpha(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT
assert(dst->n == 1 && dst->alpha == 1 && src->n >= 1 && src->alpha == 1);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2349,7 +2338,6 @@ fz_paint_pixmap_with_overprint(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n, da, sa;
fz_span_painter_t *fn;
@@ -2360,10 +2348,7 @@ fz_paint_pixmap_with_overprint(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ
}
assert(dst->n - dst->alpha == src->n - src->alpha);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2396,18 +2381,16 @@ fz_paint_pixmap_with_mask(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
{
const unsigned char *sp, *mp;
unsigned char *dp;
- fz_irect bbox, bbox2;
+ fz_irect bbox;
int x, y, w, h, n, sa, da;
fz_span_mask_painter_t *fn;
assert(dst->n == src->n);
assert(msk->n == 1);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
- fz_pixmap_bbox_no_ctx(msk, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_pixmap_bbox_no_ctx(dst);
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(msk));
x = bbox.x0;
y = bbox.y0;
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c
index 52c4af2f..74456df5 100644
--- a/source/fitz/draw-path.c
+++ b/source/fitz/draw-path.c
@@ -268,9 +268,8 @@ int
fz_flatten_fill_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, const fz_matrix *ctm, float flatness, const fz_irect *scissor, fz_irect *bbox)
{
flatten_arg arg;
- fz_irect local_bbox;
- if (fz_reset_rasterizer(ctx, rast, scissor))
+ if (fz_reset_rasterizer(ctx, rast, *scissor))
{
arg.rast = rast;
arg.ctm = ctm;
@@ -300,9 +299,8 @@ fz_flatten_fill_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path,
if (!bbox)
return 0;
- local_bbox = *scissor;
- fz_bound_rasterizer(ctx, rast, bbox);
- return fz_is_empty_irect(fz_intersect_irect(bbox, &local_bbox));
+ *bbox = fz_bound_rasterizer(ctx, rast);
+ return fz_is_empty_irect(fz_intersect_irect(*bbox, *scissor));
}
enum {
@@ -1456,16 +1454,16 @@ do_flatten_stroke(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, con
if (s.dash_total == 0)
return 1;
- fz_scissor_rasterizer(ctx, rast, &s.rect);
- if (fz_try_invert_matrix(&inv, ctm))
+ s.rect = fz_scissor_rasterizer(ctx, rast);
+ if (fz_try_invert_matrix(&inv, *ctm))
return 1;
- fz_transform_rect(&s.rect, &inv);
+ s.rect = fz_transform_rect(s.rect, inv);
s.rect.x0 -= linewidth;
s.rect.x1 += linewidth;
s.rect.y0 -= linewidth;
s.rect.y1 += linewidth;
- max_expand = fz_matrix_max_expansion(ctm);
+ max_expand = fz_matrix_max_expansion(*ctm);
if (s.dash_total >= 0.01f && s.dash_total * max_expand >= 0.5f)
{
proc = &dash_proc;
@@ -1481,14 +1479,14 @@ do_flatten_stroke(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, con
if (!bbox)
return 0;
- return fz_is_empty_irect(fz_bound_rasterizer(ctx, rast, bbox));
+ *bbox = fz_bound_rasterizer(ctx, rast);
+ return fz_is_empty_irect(*bbox);
}
int
fz_flatten_stroke_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth, const fz_irect *scissor, fz_irect *bbox)
{
-
- if (fz_reset_rasterizer(ctx, rast, scissor))
+ if (fz_reset_rasterizer(ctx, rast, *scissor))
{
if (do_flatten_stroke(ctx, rast, path, stroke, ctm, flatness, linewidth, scissor, bbox))
return 1;
diff --git a/source/fitz/draw-rasterize.c b/source/fitz/draw-rasterize.c
index 8a094c80..793d813a 100644
--- a/source/fitz/draw-rasterize.c
+++ b/source/fitz/draw-rasterize.c
@@ -188,53 +188,56 @@ fz_rasterizer_graphics_min_line_width(fz_rasterizer *ras)
return ras->aa.min_line_width;
}
-fz_irect *
-fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *bbox)
+fz_irect
+fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_irect bbox;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
if (rast->bbox.x1 < rast->bbox.x0 || rast->bbox.y1 < rast->bbox.y0)
{
- *bbox = fz_empty_irect;
+ bbox = fz_empty_irect;
}
else
{
- bbox->x0 = fz_idiv(rast->bbox.x0, hscale);
- bbox->y0 = fz_idiv(rast->bbox.y0, vscale);
- bbox->x1 = fz_idiv_up(rast->bbox.x1, hscale);
- bbox->y1 = fz_idiv_up(rast->bbox.y1, vscale);
+ bbox.x0 = fz_idiv(rast->bbox.x0, hscale);
+ bbox.y0 = fz_idiv(rast->bbox.y0, vscale);
+ bbox.x1 = fz_idiv_up(rast->bbox.x1, hscale);
+ bbox.y1 = fz_idiv_up(rast->bbox.y1, vscale);
}
return bbox;
}
-fz_rect *fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_rect *r)
+fz_rect fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_rect r;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
- r->x0 = ((float)rast->clip.x0) / hscale;
- r->y0 = ((float)rast->clip.y0) / vscale;
- r->x1 = ((float)rast->clip.x1) / hscale;
- r->y1 = ((float)rast->clip.y1) / vscale;
+ r.x0 = ((float)rast->clip.x0) / hscale;
+ r.y0 = ((float)rast->clip.y0) / vscale;
+ r.x1 = ((float)rast->clip.x1) / hscale;
+ r.y1 = ((float)rast->clip.y1) / vscale;
return r;
}
-static fz_irect *fz_clip_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *r)
+static fz_irect fz_clip_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_irect r;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
- r->x0 = fz_idiv(rast->clip.x0, hscale);
- r->y0 = fz_idiv(rast->clip.y0, vscale);
- r->x1 = fz_idiv_up(rast->clip.x1, hscale);
- r->y1 = fz_idiv_up(rast->clip.y1, vscale);
+ r.x0 = fz_idiv(rast->clip.x0, hscale);
+ r.y0 = fz_idiv(rast->clip.y0, vscale);
+ r.x1 = fz_idiv_up(rast->clip.x1, hscale);
+ r.y1 = fz_idiv_up(rast->clip.y1, vscale);
return r;
}
-int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, const fz_irect *clip)
+int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, fz_irect clip)
{
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
@@ -245,10 +248,10 @@ int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, const fz_irect *cl
rast->clip.x1 = rast->clip.y1 = BBOX_MAX;
}
else {
- rast->clip.x0 = clip->x0 * hscale;
- rast->clip.x1 = clip->x1 * hscale;
- rast->clip.y0 = clip->y0 * vscale;
- rast->clip.y1 = clip->y1 * vscale;
+ rast->clip.x0 = clip.x0 * hscale;
+ rast->clip.x1 = clip.x1 * hscale;
+ rast->clip.y0 = clip.y0 * vscale;
+ rast->clip.y1 = clip.y1 * vscale;
}
rast->bbox.x0 = rast->bbox.y0 = BBOX_MAX;
@@ -299,12 +302,9 @@ fz_rasterizer *fz_new_rasterizer(fz_context *ctx, const fz_aa_context *aa)
void fz_convert_rasterizer(fz_context *ctx, fz_rasterizer *r, int eofill, fz_pixmap *pix, unsigned char *colorbv, fz_overprint *eop)
{
- fz_irect clip, scissor;
- fz_irect pixmap_clip;
-
- if (fz_is_empty_irect(fz_intersect_irect(fz_bound_rasterizer(ctx, r, &clip), fz_pixmap_bbox_no_ctx(pix, &pixmap_clip))))
- return;
- if (fz_is_empty_irect(fz_intersect_irect(&clip, fz_clip_rasterizer(ctx, r, &scissor))))
- return;
- r->fns.convert(ctx, r, eofill, &clip, pix, colorbv, eop);
+ fz_irect clip = fz_bound_rasterizer(ctx, r);
+ clip = fz_intersect_irect(clip, fz_pixmap_bbox_no_ctx(pix));
+ clip = fz_intersect_irect(clip, fz_clip_rasterizer(ctx, r));
+ if (!fz_is_empty_irect(clip))
+ r->fns.convert(ctx, r, eofill, &clip, pix, colorbv, eop);
}
diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c
index fdc79817..54c0114d 100644
--- a/source/fitz/draw-scale-simple.c
+++ b/source/fitz/draw-scale-simple.c
@@ -1526,7 +1526,7 @@ adjust_alpha_edges(fz_pixmap * FZ_RESTRICT pix, const fz_weights * FZ_RESTRICT r
}
fz_pixmap *
-fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_irect *clip)
+fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip)
{
return fz_scale_pixmap_cached(ctx, src, x, y, w, h, clip, NULL, NULL);
}
diff --git a/source/fitz/font.c b/source/fitz/font.c
index c39174ee..d7c58d0d 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -752,7 +752,7 @@ fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm
/* Sanity check scaling in case of broken metrics. */
if (realw > 0 && subw > 0)
- fz_pre_scale(trm, subw / realw, 1);
+ *trm = fz_pre_scale(*trm, subw / realw, 1);
}
return trm;
@@ -786,12 +786,12 @@ do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
FT_Error fterr;
fz_matrix local_trm = *trm;
- float strength = fz_matrix_expansion(trm) * 0.02f;
+ float strength = fz_matrix_expansion(*trm) * 0.02f;
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
/*
Freetype mutilates complex glyphs if they are loaded
@@ -817,7 +817,7 @@ do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
if (aa == 0)
{
/* enable grid fitting for non-antialiased rendering */
- float scale = fz_matrix_expansion(&local_trm);
+ float scale = fz_matrix_expansion(local_trm);
m.xx = local_trm.a * 65536 / scale;
m.yx = local_trm.b * 65536 / scale;
m.xy = local_trm.c * 65536 / scale;
@@ -923,7 +923,7 @@ static FT_Glyph
do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state, int aa)
{
FT_Face face = font->ft_face;
- float expansion = fz_matrix_expansion(ctm);
+ float expansion = fz_matrix_expansion(*ctm);
int linewidth = state->linewidth * expansion * 64 / 2;
FT_Matrix m;
FT_Vector v;
@@ -937,7 +937,7 @@ do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_mat
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
m.xx = local_trm.a * 64; /* should be 65536 */
m.yx = local_trm.b * 64;
@@ -1094,7 +1094,7 @@ fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid)
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
m.xx = local_trm.a * 65536;
m.yx = local_trm.b * 65536;
@@ -1135,7 +1135,7 @@ fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid)
bounds->x1 = cbox.xMax * recip;
bounds->y1 = cbox.yMax * recip;
- if (fz_is_empty_rect(bounds))
+ if (fz_is_empty_rect(*bounds))
{
bounds->x0 = bounds->x1 = local_trm.e;
bounds->y0 = bounds->y1 = local_trm.f;
@@ -1159,7 +1159,7 @@ static int move_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_moveto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -1171,7 +1171,7 @@ static int line_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_lineto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -1183,8 +1183,8 @@ static int conic_to(const FT_Vector *c, const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point ct, pt;
- fz_transform_point_xy(&ct, &cc->trm, c->x, c->y);
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ ct = fz_transform_point_xy(c->x, c->y, cc->trm);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_quadto(ctx, path, ct.x, ct.y, pt.x, pt.y);
return 0;
@@ -1197,9 +1197,9 @@ static int cubic_to(const FT_Vector *c1, const FT_Vector *c2, const FT_Vector *p
fz_path *path = cc->path;
fz_point c1t, c2t, pt;
- fz_transform_point_xy(&c1t, &cc->trm, c1->x, c1->y);
- fz_transform_point_xy(&c2t, &cc->trm, c2->x, c2->y);
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ c1t = fz_transform_point_xy(c1->x, c1->y, cc->trm);
+ c2t = fz_transform_point_xy(c2->x, c2->y, cc->trm);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_curveto(ctx, path, c1t.x, c1t.y, c2t.x, c2t.y, pt.x, pt.y);
return 0;
@@ -1224,7 +1224,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
fz_lock(ctx, FZ_LOCK_FREETYPE);
@@ -1247,7 +1247,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
{
cc.ctx = ctx;
cc.path = fz_new_path(ctx);
- fz_concat(&cc.trm, fz_scale(&cc.trm, recip, recip), &local_trm);
+ cc.trm = fz_concat(fz_scale(recip, recip), local_trm);
fz_moveto(ctx, cc.path, cc.trm.e, cc.trm.f);
FT_Outline_Decompose(&face->glyph->outline, &outline_funcs, &cc);
fz_closepath(ctx, cc.path);
@@ -1271,7 +1271,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
*/
fz_font *
-fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix)
+fz_new_type3_font(fz_context *ctx, const char *name, fz_matrix matrix)
{
fz_font *font;
@@ -1289,7 +1289,7 @@ fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix)
fz_rethrow(ctx);
}
- font->t3matrix = *matrix;
+ font->t3matrix = matrix;
return font;
}
@@ -1324,7 +1324,7 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid)
/* Update font bbox with glyph's computed bbox if the font bbox is invalid */
if (font->flags.invalid_bbox)
- fz_union_rect(&font->bbox, &font->bbox_table[gid]);
+ font->bbox = fz_union_rect(font->bbox, font->bbox_table[gid]);
}
void
@@ -1341,7 +1341,7 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
/* We've not already loaded this one! */
assert(font->t3lists[gid] == NULL);
- font->t3lists[gid] = fz_new_display_list(ctx, &font->bbox);
+ font->t3lists[gid] = fz_new_display_list(ctx, font->bbox);
dev = fz_new_list_device(ctx, font->t3lists[gid]);
dev->flags = FZ_DEVFLAG_FILLCOLOR_UNDEFINED |
@@ -1376,10 +1376,9 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
{
assert(font->bbox_table != NULL);
assert(font->glyph_count > gid);
- font->bbox_table[gid] = d1_rect;
- fz_transform_rect(&font->bbox_table[gid], &font->t3matrix);
+ font->bbox_table[gid] = fz_transform_rect(d1_rect, font->t3matrix);
- if (font->flags.invalid_bbox || !fz_contains_rect(&font->bbox, &d1_rect))
+ if (font->flags.invalid_bbox || !fz_contains_rect(font->bbox, d1_rect))
{
/* Either the font bbox is invalid, or the d1_rect returned is
* incompatible with it. Either way, don't trust the d1 rect
@@ -1404,7 +1403,7 @@ fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, f
if (!list)
return;
- fz_concat(&ctm, &font->t3matrix, trm);
+ ctm = fz_concat(font->t3matrix, *trm);
fz_run_display_list(ctx, list, dev, &ctm, &fz_infinite_rect, NULL);
}
@@ -1442,12 +1441,12 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr
model = NULL; /* Treat as masked */
}
- fz_expand_rect(fz_bound_glyph(ctx, font, gid, trm, &bounds), 1);
- fz_irect_from_rect(&bbox, &bounds);
- fz_intersect_irect(&bbox, scissor);
+ bounds = fz_expand_rect(fz_bound_glyph(ctx, font, gid, *trm), 1);
+ bbox = fz_irect_from_rect(bounds);
+ bbox = fz_intersect_irect(bbox, *scissor);
/* Glyphs must always have alpha */
- glyph = fz_new_pixmap_with_bbox(ctx, model, &bbox, NULL/* FIXME */, 1);
+ glyph = fz_new_pixmap_with_bbox(ctx, model, bbox, NULL/* FIXME */, 1);
fz_var(dev);
fz_try(ctx)
@@ -1521,16 +1520,17 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi
fz_warn(ctx, "type3 glyph doesn't specify masked or colored");
}
- fz_concat(&ctm, &font->t3matrix, trm);
+ ctm = fz_concat(font->t3matrix, *trm);
font->t3run(ctx, font->t3doc, font->t3resources, contents, dev, &ctm, gstate, nested_depth, def_cs);
}
-fz_rect *
-fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect)
+fz_rect
+fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
{
+ fz_rect rect;
if (font->bbox_table && gid < font->glyph_count)
{
- if (fz_is_infinite_rect(&font->bbox_table[gid]))
+ if (fz_is_infinite_rect(font->bbox_table[gid]))
{
if (font->ft_face)
fz_bound_ft_glyph(ctx, font, gid);
@@ -1539,16 +1539,15 @@ fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz
else
font->bbox_table[gid] = fz_empty_rect;
}
- *rect = font->bbox_table[gid];
+ rect = font->bbox_table[gid];
if (fz_is_empty_rect(rect))
- *rect = font->bbox;
+ rect = font->bbox;
}
else
{
/* fall back to font bbox */
- *rect = font->bbox;
+ rect = font->bbox;
}
-
return fz_transform_rect(rect, trm);
}
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c
index 7cced024..e31a9435 100644
--- a/source/fitz/geometry.c
+++ b/source/fitz/geometry.c
@@ -29,75 +29,77 @@
const fz_matrix fz_identity = { 1, 0, 0, 1, 0, 0 };
-fz_matrix *
-fz_concat(fz_matrix *dst, const fz_matrix *one, const fz_matrix *two)
-{
- fz_matrix dst2;
- dst2.a = one->a * two->a + one->b * two->c;
- dst2.b = one->a * two->b + one->b * two->d;
- dst2.c = one->c * two->a + one->d * two->c;
- dst2.d = one->c * two->b + one->d * two->d;
- dst2.e = one->e * two->a + one->f * two->c + two->e;
- dst2.f = one->e * two->b + one->f * two->d + two->f;
- *dst = dst2;
+fz_matrix
+fz_concat(fz_matrix one, fz_matrix two)
+{
+ fz_matrix dst;
+ dst.a = one.a * two.a + one.b * two.c;
+ dst.b = one.a * two.b + one.b * two.d;
+ dst.c = one.c * two.a + one.d * two.c;
+ dst.d = one.c * two.b + one.d * two.d;
+ dst.e = one.e * two.a + one.f * two.c + two.e;
+ dst.f = one.e * two.b + one.f * two.d + two.f;
return dst;
}
-fz_matrix *
-fz_scale(fz_matrix *m, float sx, float sy)
+fz_matrix
+fz_scale(float sx, float sy)
{
- m->a = sx; m->b = 0;
- m->c = 0; m->d = sy;
- m->e = 0; m->f = 0;
+ fz_matrix m;
+ m.a = sx; m.b = 0;
+ m.c = 0; m.d = sy;
+ m.e = 0; m.f = 0;
return m;
}
-fz_matrix *
-fz_pre_scale(fz_matrix *mat, float sx, float sy)
+fz_matrix
+fz_pre_scale(fz_matrix m, float sx, float sy)
{
- mat->a *= sx;
- mat->b *= sx;
- mat->c *= sy;
- mat->d *= sy;
- return mat;
+ m.a *= sx;
+ m.b *= sx;
+ m.c *= sy;
+ m.d *= sy;
+ return m;
}
-fz_matrix *
-fz_post_scale(fz_matrix *mat, float sx, float sy)
+fz_matrix
+fz_post_scale(fz_matrix m, float sx, float sy)
{
- mat->a *= sx;
- mat->b *= sy;
- mat->c *= sx;
- mat->d *= sy;
- mat->e *= sx;
- mat->f *= sy;
- return mat;
+ m.a *= sx;
+ m.b *= sy;
+ m.c *= sx;
+ m.d *= sy;
+ m.e *= sx;
+ m.f *= sy;
+ return m;
}
-fz_matrix *
-fz_shear(fz_matrix *mat, float h, float v)
+fz_matrix
+fz_shear(float h, float v)
{
- mat->a = 1; mat->b = v;
- mat->c = h; mat->d = 1;
- mat->e = 0; mat->f = 0;
- return mat;
+ fz_matrix m;
+ m.a = 1; m.b = v;
+ m.c = h; m.d = 1;
+ m.e = 0; m.f = 0;
+ return m;
}
-fz_matrix *
-fz_pre_shear(fz_matrix *mat, float h, float v)
+fz_matrix
+fz_pre_shear(fz_matrix m, float h, float v)
{
- float a = mat->a;
- float b = mat->b;
- mat->a += v * mat->c;
- mat->b += v * mat->d;
- mat->c += h * a;
- mat->d += h * b;
- return mat;
+ float a = m.a;
+ float b = m.b;
+ m.a += v * m.c;
+ m.b += v * m.d;
+ m.c += h * a;
+ m.d += h * b;
+ return m;
}
-fz_matrix *
-fz_rotate(fz_matrix *m, float theta)
+fz_matrix
+fz_rotate(float theta)
{
+ fz_matrix m;
float s;
float c;
@@ -132,14 +134,14 @@ fz_rotate(fz_matrix *m, float theta)
c = cosf(theta * FZ_PI / 180);
}
- m->a = c; m->b = s;
- m->c = -s; m->d = c;
- m->e = 0; m->f = 0;
+ m.a = c; m.b = s;
+ m.c = -s; m.d = c;
+ m.e = 0; m.f = 0;
return m;
}
-fz_matrix *
-fz_pre_rotate(fz_matrix *m, float theta)
+fz_matrix
+fz_pre_rotate(fz_matrix m, float theta)
{
while (theta < 0)
theta += 360;
@@ -152,90 +154,90 @@ fz_pre_rotate(fz_matrix *m, float theta)
}
else if (fabsf(90.0f - theta) < FLT_EPSILON)
{
- float a = m->a;
- float b = m->b;
- m->a = m->c;
- m->b = m->d;
- m->c = -a;
- m->d = -b;
+ float a = m.a;
+ float b = m.b;
+ m.a = m.c;
+ m.b = m.d;
+ m.c = -a;
+ m.d = -b;
}
else if (fabsf(180.0f - theta) < FLT_EPSILON)
{
- m->a = -m->a;
- m->b = -m->b;
- m->c = -m->c;
- m->d = -m->d;
+ m.a = -m.a;
+ m.b = -m.b;
+ m.c = -m.c;
+ m.d = -m.d;
}
else if (fabsf(270.0f - theta) < FLT_EPSILON)
{
- float a = m->a;
- float b = m->b;
- m->a = -m->c;
- m->b = -m->d;
- m->c = a;
- m->d = b;
+ float a = m.a;
+ float b = m.b;
+ m.a = -m.c;
+ m.b = -m.d;
+ m.c = a;
+ m.d = b;
}
else
{
float s = sinf(theta * FZ_PI / 180);
float c = cosf(theta * FZ_PI / 180);
- float a = m->a;
- float b = m->b;
- m->a = c * a + s * m->c;
- m->b = c * b + s * m->d;
- m->c =-s * a + c * m->c;
- m->d =-s * b + c * m->d;
+ float a = m.a;
+ float b = m.b;
+ m.a = c * a + s * m.c;
+ m.b = c * b + s * m.d;
+ m.c =-s * a + c * m.c;
+ m.d =-s * b + c * m.d;
}
return m;
}
-fz_matrix *
-fz_translate(fz_matrix *m, float tx, float ty)
+fz_matrix
+fz_translate(float tx, float ty)
{
- m->a = 1; m->b = 0;
- m->c = 0; m->d = 1;
- m->e = tx; m->f = ty;
+ fz_matrix m;
+ m.a = 1; m.b = 0;
+ m.c = 0; m.d = 1;
+ m.e = tx; m.f = ty;
return m;
}
-fz_matrix *
-fz_pre_translate(fz_matrix *mat, float tx, float ty)
+fz_matrix
+fz_pre_translate(fz_matrix m, float tx, float ty)
{
- mat->e += tx * mat->a + ty * mat->c;
- mat->f += tx * mat->b + ty * mat->d;
- return mat;
+ m.e += tx * m.a + ty * m.c;
+ m.f += tx * m.b + ty * m.d;
+ return m;
}
-fz_matrix *
-fz_invert_matrix(fz_matrix *dst, const fz_matrix *src)
+fz_matrix
+fz_invert_matrix(fz_matrix src)
{
- /* Be careful to cope with dst == src */
- float a = src->a;
- float det = a * src->d - src->b * src->c;
+ float a = src.a;
+ float det = a * src.d - src.b * src.c;
if (det < -FLT_EPSILON || det > FLT_EPSILON)
{
+ fz_matrix dst;
float rdet = 1 / det;
- dst->a = src->d * rdet;
- dst->b = -src->b * rdet;
- dst->c = -src->c * rdet;
- dst->d = a * rdet;
- a = -src->e * dst->a - src->f * dst->c;
- dst->f = -src->e * dst->b - src->f * dst->d;
- dst->e = a;
+ dst.a = src.d * rdet;
+ dst.b = -src.b * rdet;
+ dst.c = -src.c * rdet;
+ dst.d = a * rdet;
+ a = -src.e * dst.a - src.f * dst.c;
+ dst.f = -src.e * dst.b - src.f * dst.d;
+ dst.e = a;
+ return dst;
}
- else
- *dst = *src;
- return dst;
+ return src;
}
int
-fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
+fz_try_invert_matrix(fz_matrix *dst, fz_matrix src)
{
- double sa = (double)src->a;
- double sb = (double)src->b;
- double sc = (double)src->c;
- double sd = (double)src->d;
+ double sa = (double)src.a;
+ double sb = (double)src.b;
+ double sc = (double)src.c;
+ double sd = (double)src.d;
double da, db, dc, dd;
double det = sa * sd - sb * sc;
if (det >= -DBL_EPSILON && det <= DBL_EPSILON)
@@ -249,77 +251,79 @@ fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
dst->c = (float)dc;
dd = sa * det;
dst->d = (float)dd;
- da = -src->e * da - src->f * dc;
- dst->f = (float)(-src->e * db - src->f * dd);
+ da = -src.e * da - src.f * dc;
+ dst->f = (float)(-src.e * db - src.f * dd);
dst->e = (float)da;
return 0;
}
int
-fz_is_rectilinear(const fz_matrix *m)
+fz_is_rectilinear(fz_matrix m)
{
- return (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON) ||
- (fabsf(m->a) < FLT_EPSILON && fabsf(m->d) < FLT_EPSILON);
+ return (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON) ||
+ (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON);
}
float
-fz_matrix_expansion(const fz_matrix *m)
+fz_matrix_expansion(fz_matrix m)
{
- return sqrtf(fabsf(m->a * m->d - m->b * m->c));
+ return sqrtf(fabsf(m.a * m.d - m.b * m.c));
}
float
-fz_matrix_max_expansion(const fz_matrix *m)
+fz_matrix_max_expansion(fz_matrix m)
{
- float max = fabsf(m->a);
- float x = fabsf(m->b);
+ float max = fabsf(m.a);
+ float x = fabsf(m.b);
if (max < x)
max = x;
- x = fabsf(m->c);
+ x = fabsf(m.c);
if (max < x)
max = x;
- x = fabsf(m->d);
+ x = fabsf(m.d);
if (max < x)
max = x;
return max;
}
-fz_point *
-fz_transform_point(fz_point *p, const fz_matrix *m)
+fz_point
+fz_transform_point(fz_point p, fz_matrix m)
{
- float x = p->x;
- p->x = x * m->a + p->y * m->c + m->e;
- p->y = x * m->b + p->y * m->d + m->f;
+ float x = p.x;
+ p.x = x * m.a + p.y * m.c + m.e;
+ p.y = x * m.b + p.y * m.d + m.f;
return p;
}
-fz_point *
-fz_transform_point_xy(fz_point *p, const fz_matrix *m, float x, float y)
+fz_point
+fz_transform_point_xy(float x, float y, fz_matrix m)
{
- p->x = x * m->a + y * m->c + m->e;
- p->y = x * m->b + y * m->d + m->f;
+ fz_point p;
+ p.x = x * m.a + y * m.c + m.e;
+ p.y = x * m.b + y * m.d + m.f;
return p;
}
-fz_point *
-fz_transform_vector(fz_point *p, const fz_matrix *m)
+fz_point
+fz_transform_vector(fz_point p, fz_matrix m)
{
- float x = p->x;
- p->x = x * m->a + p->y * m->c;
- p->y = x * m->b + p->y * m->d;
+ float x = p.x;
+ p.x = x * m.a + p.y * m.c;
+ p.y = x * m.b + p.y * m.d;
return p;
}
-void
-fz_normalize_vector(fz_point *p)
+fz_point
+fz_normalize_vector(fz_point p)
{
- float len = p->x * p->x + p->y * p->y;
+ float len = p.x * p.x + p.y * p.y;
if (len != 0)
{
len = sqrtf(len);
- p->x /= len;
- p->y /= len;
+ p.x /= len;
+ p.y /= len;
}
+ return p;
}
/* Rectangles and bounding boxes */
@@ -336,246 +340,229 @@ const fz_irect fz_infinite_irect = { 1, 1, -1, -1 };
const fz_irect fz_empty_irect = { 0, 0, 0, 0 };
const fz_irect fz_unit_bbox = { 0, 0, 1, 1 };
-fz_irect *
-fz_irect_from_rect(fz_irect *b, const fz_rect *r)
+fz_irect
+fz_irect_from_rect(fz_rect r)
{
+ fz_irect b;
if (fz_is_empty_rect(r))
{
- b->x0 = 0;
- b->y0 = 0;
- b->x1 = 0;
- b->y1 = 0;
+ b.x0 = 0;
+ b.y0 = 0;
+ b.x1 = 0;
+ b.y1 = 0;
}
else
{
- b->x0 = fz_clamp(floorf(r->x0), MIN_SAFE_INT, MAX_SAFE_INT);
- b->y0 = fz_clamp(floorf(r->y0), MIN_SAFE_INT, MAX_SAFE_INT);
- b->x1 = fz_clamp(ceilf(r->x1), MIN_SAFE_INT, MAX_SAFE_INT);
- b->y1 = fz_clamp(ceilf(r->y1), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.x0 = fz_clamp(floorf(r.x0), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.y0 = fz_clamp(floorf(r.y0), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.x1 = fz_clamp(ceilf(r.x1), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.y1 = fz_clamp(ceilf(r.y1), MIN_SAFE_INT, MAX_SAFE_INT);
}
return b;
}
-fz_rect *
-fz_rect_from_irect(fz_rect *r, const fz_irect *a)
+fz_rect
+fz_rect_from_irect(fz_irect a)
{
- r->x0 = a->x0;
- r->y0 = a->y0;
- r->x1 = a->x1;
- r->y1 = a->y1;
+ fz_rect r;
+ r.x0 = a.x0;
+ r.y0 = a.y0;
+ r.x1 = a.x1;
+ r.y1 = a.y1;
return r;
}
-fz_irect *
-fz_round_rect(fz_irect * b, const fz_rect *r)
+fz_irect
+fz_round_rect(fz_rect r)
{
+ fz_irect b;
int i;
- i = floorf(r->x0 + 0.001f);
- b->x0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = floorf(r->y0 + 0.001f);
- b->y0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = ceilf(r->x1 - 0.001f);
- b->x1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = ceilf(r->y1 - 0.001f);
- b->y1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = floorf(r.x0 + 0.001f);
+ b.x0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = floorf(r.y0 + 0.001f);
+ b.y0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = ceilf(r.x1 - 0.001f);
+ b.x1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = ceilf(r.y1 - 0.001f);
+ b.y1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
return b;
}
-fz_rect *
-fz_intersect_rect(fz_rect *a, const fz_rect *b)
+fz_rect
+fz_intersect_rect(fz_rect a, fz_rect b)
{
/* Check for empty box before infinite box */
- if (fz_is_empty_rect(a)) return a;
- if (fz_is_empty_rect(b)) {
- *a = fz_empty_rect;
- return a;
- }
+ if (fz_is_empty_rect(a)) return fz_empty_rect;
+ if (fz_is_empty_rect(b)) return fz_empty_rect;
if (fz_is_infinite_rect(b)) return a;
- if (fz_is_infinite_rect(a)) {
- *a = *b;
- return a;
- }
- if (a->x0 < b->x0)
- a->x0 = b->x0;
- if (a->y0 < b->y0)
- a->y0 = b->y0;
- if (a->x1 > b->x1)
- a->x1 = b->x1;
- if (a->y1 > b->y1)
- a->y1 = b->y1;
- if (a->x1 < a->x0 || a->y1 < a->y0)
- *a = fz_empty_rect;
+ if (fz_is_infinite_rect(a)) return b;
+ if (a.x0 < b.x0)
+ a.x0 = b.x0;
+ if (a.y0 < b.y0)
+ a.y0 = b.y0;
+ if (a.x1 > b.x1)
+ a.x1 = b.x1;
+ if (a.y1 > b.y1)
+ a.y1 = b.y1;
+ if (a.x1 < a.x0 || a.y1 < a.y0)
+ return fz_empty_rect;
return a;
}
-fz_irect *
-fz_intersect_irect(fz_irect *a, const fz_irect *b)
+fz_irect
+fz_intersect_irect(fz_irect a, fz_irect b)
{
/* Check for empty box before infinite box */
- if (fz_is_empty_irect(a)) return a;
- if (fz_is_empty_irect(b))
- {
- *a = fz_empty_irect;
- return a;
- }
+ if (fz_is_empty_irect(a)) return fz_empty_irect;
+ if (fz_is_empty_irect(b)) return fz_empty_irect;
if (fz_is_infinite_irect(b)) return a;
- if (fz_is_infinite_irect(a))
- {
- *a = *b;
- return a;
- }
- if (a->x0 < b->x0)
- a->x0 = b->x0;
- if (a->y0 < b->y0)
- a->y0 = b->y0;
- if (a->x1 > b->x1)
- a->x1 = b->x1;
- if (a->y1 > b->y1)
- a->y1 = b->y1;
- if (a->x1 < a->x0 || a->y1 < a->y0)
- *a = fz_empty_irect;
+ if (fz_is_infinite_irect(a)) return b;
+ if (a.x0 < b.x0)
+ a.x0 = b.x0;
+ if (a.y0 < b.y0)
+ a.y0 = b.y0;
+ if (a.x1 > b.x1)
+ a.x1 = b.x1;
+ if (a.y1 > b.y1)
+ a.y1 = b.y1;
+ if (a.x1 < a.x0 || a.y1 < a.y0)
+ return fz_empty_irect;
return a;
}
-fz_rect *
-fz_union_rect(fz_rect *a, const fz_rect *b)
+fz_rect
+fz_union_rect(fz_rect a, fz_rect b)
{
/* Check for empty box before infinite box */
if (fz_is_empty_rect(b)) return a;
- if (fz_is_empty_rect(a)) {
- *a = *b;
- return a;
- }
+ if (fz_is_empty_rect(a)) return b;
if (fz_is_infinite_rect(a)) return a;
- if (fz_is_infinite_rect(b)) {
- *a = *b;
- return a;
- }
- if (a->x0 > b->x0)
- a->x0 = b->x0;
- if (a->y0 > b->y0)
- a->y0 = b->y0;
- if (a->x1 < b->x1)
- a->x1 = b->x1;
- if (a->y1 < b->y1)
- a->y1 = b->y1;
+ if (fz_is_infinite_rect(b)) return b;
+ if (a.x0 > b.x0)
+ a.x0 = b.x0;
+ if (a.y0 > b.y0)
+ a.y0 = b.y0;
+ if (a.x1 < b.x1)
+ a.x1 = b.x1;
+ if (a.y1 < b.y1)
+ a.y1 = b.y1;
return a;
}
-fz_rect *
-fz_translate_rect(fz_rect *a, float xoff, float yoff)
+fz_rect
+fz_translate_rect(fz_rect a, float xoff, float yoff)
{
if (fz_is_empty_rect(a)) return a;
if (fz_is_infinite_rect(a)) return a;
- a->x0 += xoff;
- a->y0 += yoff;
- a->x1 += xoff;
- a->y1 += yoff;
+ a.x0 += xoff;
+ a.y0 += yoff;
+ a.x1 += xoff;
+ a.y1 += yoff;
return a;
}
-fz_irect *
-fz_translate_irect(fz_irect *a, int xoff, int yoff)
+fz_irect
+fz_translate_irect(fz_irect a, int xoff, int yoff)
{
int t;
if (fz_is_empty_irect(a)) return a;
if (fz_is_infinite_irect(a)) return a;
- a->x0 = ADD_WITH_SAT(t, a->x0, xoff);
- a->y0 = ADD_WITH_SAT(t, a->y0, yoff);
- a->x1 = ADD_WITH_SAT(t, a->x1, xoff);
- a->y1 = ADD_WITH_SAT(t, a->y1, yoff);
+ a.x0 = ADD_WITH_SAT(t, a.x0, xoff);
+ a.y0 = ADD_WITH_SAT(t, a.y0, yoff);
+ a.x1 = ADD_WITH_SAT(t, a.x1, xoff);
+ a.y1 = ADD_WITH_SAT(t, a.y1, yoff);
return a;
}
-fz_rect *
-fz_transform_rect(fz_rect *r, const fz_matrix *m)
+fz_rect
+fz_transform_rect(fz_rect r, fz_matrix m)
{
fz_point s, t, u, v;
if (fz_is_infinite_rect(r))
return r;
- if (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON)
+ if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
{
- if (m->a < 0)
+ if (m.a < 0)
{
- float f = r->x0;
- r->x0 = r->x1;
- r->x1 = f;
+ float f = r.x0;
+ r.x0 = r.x1;
+ r.x1 = f;
}
- if (m->d < 0)
+ if (m.d < 0)
{
- float f = r->y0;
- r->y0 = r->y1;
- r->y1 = f;
+ float f = r.y0;
+ r.y0 = r.y1;
+ r.y1 = f;
}
- fz_transform_point(fz_rect_min(r), m);
- fz_transform_point(fz_rect_max(r), m);
+ s = fz_transform_point_xy(r.x0, r.y0, m);
+ t = fz_transform_point_xy(r.x1, r.y1, m);
+ r.x0 = s.x; r.y0 = s.y;
+ r.x1 = t.x; r.y1 = t.y;
return r;
}
- s.x = r->x0; s.y = r->y0;
- t.x = r->x0; t.y = r->y1;
- u.x = r->x1; u.y = r->y1;
- v.x = r->x1; v.y = r->y0;
- fz_transform_point(&s, m);
- fz_transform_point(&t, m);
- fz_transform_point(&u, m);
- fz_transform_point(&v, m);
- r->x0 = MIN4(s.x, t.x, u.x, v.x);
- r->y0 = MIN4(s.y, t.y, u.y, v.y);
- r->x1 = MAX4(s.x, t.x, u.x, v.x);
- r->y1 = MAX4(s.y, t.y, u.y, v.y);
+ s.x = r.x0; s.y = r.y0;
+ t.x = r.x0; t.y = r.y1;
+ u.x = r.x1; u.y = r.y1;
+ v.x = r.x1; v.y = r.y0;
+ s = fz_transform_point(s, m);
+ t = fz_transform_point(t, m);
+ u = fz_transform_point(u, m);
+ v = fz_transform_point(v, m);
+ r.x0 = MIN4(s.x, t.x, u.x, v.x);
+ r.y0 = MIN4(s.y, t.y, u.y, v.y);
+ r.x1 = MAX4(s.x, t.x, u.x, v.x);
+ r.y1 = MAX4(s.y, t.y, u.y, v.y);
return r;
}
-fz_irect *
-fz_expand_irect(fz_irect *a, int expand)
+fz_irect
+fz_expand_irect(fz_irect a, int expand)
{
if (fz_is_infinite_irect(a)) return a;
- a->x0 -= expand;
- a->y0 -= expand;
- a->x1 += expand;
- a->y1 += expand;
+ a.x0 -= expand;
+ a.y0 -= expand;
+ a.x1 += expand;
+ a.y1 += expand;
return a;
}
-fz_rect *
-fz_expand_rect(fz_rect *a, float expand)
+fz_rect
+fz_expand_rect(fz_rect a, float expand)
{
if (fz_is_infinite_rect(a)) return a;
- a->x0 -= expand;
- a->y0 -= expand;
- a->x1 += expand;
- a->y1 += expand;
+ a.x0 -= expand;
+ a.y0 -= expand;
+ a.x1 += expand;
+ a.y1 += expand;
return a;
}
-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)
{
if (fz_is_infinite_rect(r)) return r;
- if (p->x < r->x0) r->x0 = p->x;
- if (p->x > r->x1) r->x1 = p->x;
- if (p->y < r->y0) r->y0 = p->y;
- if (p->y > r->y1) r->y1 = p->y;
+ if (p.x < r.x0) r.x0 = p.x;
+ if (p.x > r.x1) r.x1 = p.x;
+ if (p.y < r.y0) r.y0 = p.y;
+ if (p.y > r.y1) r.y1 = p.y;
return r;
}
-int fz_contains_rect(const fz_rect *a, const fz_rect *b)
+int fz_contains_rect(fz_rect a, fz_rect b)
{
- if (a == NULL || b == NULL)
- return 0;
if (fz_is_empty_rect(b))
return 1;
if (fz_is_empty_rect(a))
return 0;
- return ((a->x0 <= b->x0) &&
- (a->y0 <= b->y0) &&
- (a->x1 >= b->x1) &&
- (a->y1 >= b->y1));
+ return ((a.x0 <= b.x0) &&
+ (a.y0 <= b.y0) &&
+ (a.x1 >= b.x1) &&
+ (a.y1 >= b.y1));
}
fz_rect
@@ -589,13 +576,13 @@ fz_rect_from_quad(fz_quad q)
return r;
}
-fz_quad *
-fz_transform_quad(fz_quad *q, const fz_matrix *m)
+fz_quad
+fz_transform_quad(fz_quad q, const fz_matrix m)
{
- fz_transform_point(&q->ul, m);
- fz_transform_point(&q->ur, m);
- fz_transform_point(&q->ll, m);
- fz_transform_point(&q->lr, m);
+ q.ul = fz_transform_point(q.ul, m);
+ q.ur = fz_transform_point(q.ur, m);
+ q.ll = fz_transform_point(q.ll, m);
+ q.lr = fz_transform_point(q.lr, m);
return q;
}
diff --git a/source/fitz/glyph.c b/source/fitz/glyph.c
index 4c22b94b..f3634df1 100644
--- a/source/fitz/glyph.c
+++ b/source/fitz/glyph.c
@@ -24,23 +24,25 @@ fz_drop_glyph_imp(fz_context *ctx, fz_storable *glyph_)
fz_free(ctx, 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)
{
- bbox->x0 = glyph->x;
- bbox->y0 = glyph->y;
- bbox->x1 = glyph->x + glyph->w;
- bbox->y1 = glyph->y + glyph->h;
+ fz_irect bbox;
+ bbox.x0 = glyph->x;
+ bbox.y0 = glyph->y;
+ bbox.x1 = glyph->x + glyph->w;
+ bbox.y1 = glyph->y + glyph->h;
return bbox;
}
-fz_irect *
-fz_glyph_bbox_no_ctx(fz_glyph *glyph, fz_irect *bbox)
+fz_irect
+fz_glyph_bbox_no_ctx(fz_glyph *glyph)
{
- bbox->x0 = glyph->x;
- bbox->y0 = glyph->y;
- bbox->x1 = glyph->x + glyph->w;
- bbox->y1 = glyph->y + glyph->h;
+ fz_irect bbox;
+ bbox.x0 = glyph->x;
+ bbox.y0 = glyph->y;
+ bbox.x1 = glyph->x + glyph->w;
+ bbox.y1 = glyph->y + glyph->h;
return bbox;
}
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 51699772..8cda9687 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -590,7 +590,7 @@ update_ctm_for_subarea(fz_matrix *ctm, const fz_irect *subarea, int w, int h)
m.d = (float) (subarea->y1 - subarea->y0) / h;
m.e = (float) subarea->x0 / w;
m.f = (float) subarea->y0 / h;
- fz_concat(ctm, &m, ctm);
+ *ctm = fz_concat(m, *ctm);
}
void fz_default_image_decode(void *arg, int w, int h, int l2factor, fz_irect *subarea)
@@ -1139,8 +1139,7 @@ display_list_image_get_pixmap(fz_context *ctx, fz_image *image_, fz_irect *subar
/* If we render the display list into pix with the image matrix, we'll get a unit
* square result. Therefore scale by w, h. */
- ctm = image->transform;
- fz_pre_scale(&ctm, w, h);
+ ctm = fz_pre_scale(image->transform, w, h);
fz_clear_pixmap(ctx, pix); /* clear to transparent */
dev = fz_new_draw_device(ctx, &ctm, pix);
@@ -1196,7 +1195,7 @@ fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_d
display_list_image_get_size,
drop_display_list_image);
image->super.scalable = 1;
- fz_scale(&image->transform, 1 / w, 1 / h);
+ image->transform = fz_scale(1 / w, 1 / h);
image->list = fz_keep_display_list(ctx, list);
return &image->super;
diff --git a/source/fitz/link.c b/source/fitz/link.c
index b47fa9ee..0d655371 100644
--- a/source/fitz/link.c
+++ b/source/fitz/link.c
@@ -2,13 +2,13 @@
#include "fitz-imp.h"
fz_link *
-fz_new_link(fz_context *ctx, const fz_rect *bbox, void *doc, const char *uri)
+fz_new_link(fz_context *ctx, fz_rect bbox, void *doc, const char *uri)
{
fz_link *link;
link = fz_malloc_struct(ctx, fz_link);
link->refs = 1;
- link->rect = *bbox;
+ link->rect = bbox;
link->next = NULL;
link->doc = doc; /* don't take reference */
link->uri = NULL;
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c
index ca3425ab..883d6383 100644
--- a/source/fitz/list-device.c
+++ b/source/fitz/list-device.c
@@ -238,7 +238,7 @@ fz_append_display_node(
{
if (update)
{
- fz_intersect_rect(update, &writer->stack[writer->top].rect);
+ *update = fz_intersect_rect(*update, writer->stack[writer->top].rect);
local_rect = *update;
rect = &local_rect;
}
@@ -251,7 +251,7 @@ fz_append_display_node(
/* fallthrough */
default:
if (writer->top > 0 && writer->tiled == 0 && writer->top <= STACK_SIZE && rect)
- fz_union_rect(&writer->stack[writer->top-1].rect, rect);
+ writer->stack[writer->top-1].rect = fz_union_rect(writer->stack[writer->top-1].rect, *rect);
break;
}
@@ -664,9 +664,7 @@ static void
fz_list_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
-
- fz_bound_path(ctx, path, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_path(ctx, path, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -687,9 +685,7 @@ static void
fz_list_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
-
- fz_bound_path(ctx, path, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_path(ctx, path, stroke, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -709,17 +705,15 @@ fz_list_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
static void
fz_list_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect2;
-
- fz_bound_path(ctx, path, NULL, ctm, &rect2);
+ fz_rect rect = fz_bound_path(ctx, path, NULL, *ctm);
if (scissor)
- fz_intersect_rect(&rect2, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_PATH,
even_odd, /* flags */
- &rect2,
+ &rect,
path, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -733,17 +727,15 @@ fz_list_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
static void
fz_list_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect2;
-
- fz_bound_path(ctx, path, stroke, ctm, &rect2);
+ fz_rect rect = fz_bound_path(ctx, path, stroke, *ctm);
if (scissor)
- fz_intersect_rect(&rect2, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_STROKE_PATH,
0, /* flags */
- &rect2,
+ &rect,
path, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -758,12 +750,10 @@ static void
fz_list_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -790,12 +780,10 @@ static void
fz_list_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, stroke, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -821,14 +809,12 @@ fz_list_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
static void
fz_list_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
if (scissor)
- fz_intersect_rect(&rect, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
@@ -854,14 +840,12 @@ fz_list_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
static void
fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, stroke, *ctm);
if (scissor)
- fz_intersect_rect(&rect, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
@@ -887,12 +871,10 @@ fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
static void
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);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -938,11 +920,9 @@ static void
fz_list_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_shade *shade2 = fz_keep_shade(ctx, shade);
- fz_rect rect;
-
fz_try(ctx)
{
- fz_bound_shade(ctx, shade, ctm, &rect);
+ fz_rect rect = fz_bound_shade(ctx, shade, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -969,11 +949,9 @@ static void
fz_list_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect = fz_unit_rect;
-
fz_try(ctx)
{
- fz_transform_rect(&rect, ctm);
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -1001,11 +979,10 @@ fz_list_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect = fz_unit_rect;
fz_try(ctx)
{
- fz_transform_rect(&rect, ctm);
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -1032,19 +1009,17 @@ static void
fz_list_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect2 = fz_unit_rect;
-
- fz_transform_rect(&rect2, ctm);
- if (scissor)
- fz_intersect_rect(&rect2, scissor);
fz_try(ctx)
{
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
+ if (scissor)
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_IMAGE_MASK,
0, /* flags */
- &rect2,
+ &rect,
NULL, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -1464,12 +1439,12 @@ fz_drop_display_list_imp(fz_context *ctx, fz_storable *list_)
}
fz_display_list *
-fz_new_display_list(fz_context *ctx, const fz_rect *mediabox)
+fz_new_display_list(fz_context *ctx, fz_rect mediabox)
{
fz_display_list *list = fz_malloc_struct(ctx, fz_display_list);
FZ_INIT_STORABLE(list, 1, fz_drop_display_list_imp);
list->list = NULL;
- list->mediabox = mediabox ? *mediabox : fz_empty_rect;
+ list->mediabox = mediabox;
list->max = 0;
list->len = 0;
return list;
@@ -1489,11 +1464,10 @@ fz_drop_display_list(fz_context *ctx, fz_display_list *list)
fz_defer_reap_end(ctx);
}
-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)
{
- *bounds = list->mediabox;
- return bounds;
+ return list->mediabox;
}
int fz_display_list_is_empty(fz_context *ctx, const fz_display_list *list)
@@ -1682,8 +1656,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
continue;
}
- trans_rect = rect;
- fz_transform_rect(&trans_rect, top_ctm);
+ trans_rect = fz_transform_rect(rect, *top_ctm);
/* cull objects to draw using a quick visibility test */
@@ -1696,9 +1669,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
}
else
{
- fz_rect irect = trans_rect;
- fz_intersect_rect(&irect, scissor);
- empty = fz_is_empty_rect(&irect);
+ empty = fz_is_empty_rect(fz_intersect_rect(trans_rect, *scissor));
}
if (clipped || empty)
@@ -1730,7 +1701,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
}
visible:
- fz_concat(&trans_ctm, &ctm, top_ctm);
+ trans_ctm = fz_concat(ctm, *top_ctm);
fz_try(ctx)
{
diff --git a/source/fitz/path.c b/source/fitz/path.c
index 92af16f7..56510329 100644
--- a/source/fitz/path.c
+++ b/source/fitz/path.c
@@ -576,13 +576,12 @@ fz_rectto(fz_context *ctx, fz_path *path, float x1, float y1, float x2, float y2
path->current = path->begin;
}
-static inline fz_rect *bound_expand(fz_rect *r, const fz_point *p)
+static inline void bound_expand(fz_rect *r, fz_point p)
{
- if (p->x < r->x0) r->x0 = p->x;
- if (p->y < r->y0) r->y0 = p->y;
- if (p->x > r->x1) r->x1 = p->x;
- if (p->y > r->y1) r->y1 = p->y;
- return r;
+ if (p.x < r->x0) r->x0 = p.x;
+ if (p.y < r->y0) r->y0 = p.y;
+ if (p.x > r->x1) r->x1 = p.x;
+ if (p.y > r->y1) r->y1 = p.y;
}
void fz_walk_path(fz_context *ctx, const fz_path *path, const fz_path_walker *proc, void *arg)
@@ -834,7 +833,7 @@ void fz_walk_path(fz_context *ctx, const fz_path *path, const fz_path_walker *pr
typedef struct
{
- const fz_matrix *ctm;
+ fz_matrix ctm;
fz_rect rect;
fz_point move;
int trailing_move;
@@ -845,10 +844,7 @@ static void
bound_moveto(fz_context *ctx, void *arg_, float x, float y)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
-
- arg->move.x = x;
- arg->move.y = y;
- fz_transform_point(&arg->move, arg->ctm);
+ arg->move = fz_transform_point_xy(x, y, arg->ctm);
arg->trailing_move = 1;
}
@@ -856,11 +852,7 @@ static void
bound_lineto(fz_context *ctx, void *arg_, float x, float y)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
- fz_point p;
-
- p.x = x;
- p.y = y;
- fz_transform_point(&p, arg->ctm);
+ fz_point p = fz_transform_point_xy(x, y, arg->ctm);
if (arg->first)
{
arg->rect.x0 = arg->rect.x1 = p.x;
@@ -868,12 +860,11 @@ bound_lineto(fz_context *ctx, void *arg_, float x, float y)
arg->first = 0;
}
else
- bound_expand(&arg->rect, &p);
-
+ bound_expand(&arg->rect, p);
if (arg->trailing_move)
{
arg->trailing_move = 0;
- bound_expand(&arg->rect, &arg->move);
+ bound_expand(&arg->rect, arg->move);
}
}
@@ -881,11 +872,7 @@ static void
bound_curveto(fz_context *ctx, void *arg_, float x1, float y1, float x2, float y2, float x3, float y3)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
- fz_point p;
-
- p.x = x1;
- p.y = y1;
- fz_transform_point(&p, arg->ctm);
+ fz_point p = fz_transform_point_xy(x1, y1, arg->ctm);
if (arg->first)
{
arg->rect.x0 = arg->rect.x1 = p.x;
@@ -893,17 +880,13 @@ bound_curveto(fz_context *ctx, void *arg_, float x1, float y1, float x2, float y
arg->first = 0;
}
else
- bound_expand(&arg->rect, &p);
- p.x = x2;
- p.y = y2;
- bound_expand(&arg->rect, fz_transform_point(&p, arg->ctm));
- p.x = x3;
- p.y = y3;
- bound_expand(&arg->rect, fz_transform_point(&p, arg->ctm));
+ bound_expand(&arg->rect, p);
+ bound_expand(&arg->rect, fz_transform_point_xy(x2, y2, arg->ctm));
+ bound_expand(&arg->rect, fz_transform_point_xy(x3, y3, arg->ctm));
if (arg->trailing_move)
{
arg->trailing_move = 0;
- bound_expand(&arg->rect, &arg->move);
+ bound_expand(&arg->rect, arg->move);
}
}
@@ -915,8 +898,8 @@ static const fz_path_walker bound_path_walker =
NULL
};
-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_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, fz_matrix ctm)
{
bound_path_arg arg;
@@ -929,15 +912,14 @@ fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *strok
if (!arg.first && stroke)
{
- fz_adjust_rect_for_stroke(ctx, &arg.rect, stroke, ctm);
+ arg.rect = fz_adjust_rect_for_stroke(ctx, arg.rect, stroke, ctm);
}
- *r = arg.rect;
- return r;
+ return arg.rect;
}
-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_adjust_rect_for_stroke(fz_context *ctx, fz_rect r, const fz_stroke_state *stroke, fz_matrix ctm)
{
float expand;
@@ -951,15 +933,15 @@ fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect *r, const fz_stroke_state *st
if ((stroke->linejoin == FZ_LINEJOIN_MITER || stroke->linejoin == FZ_LINEJOIN_MITER_XPS) && stroke->miterlimit > 1)
expand *= stroke->miterlimit;
- r->x0 -= expand;
- r->y0 -= expand;
- r->x1 += expand;
- r->y1 += expand;
+ r.x0 -= expand;
+ r.y0 -= expand;
+ r.x1 += expand;
+ r.y1 += expand;
return r;
}
void
-fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
+fz_transform_path(fz_context *ctx, fz_path *path, fz_matrix ctm)
{
int i, k, n;
fz_point p, p1, p2, p3, q, s;
@@ -967,7 +949,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
if (path->packed)
fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot transform a packed path");
- if (ctm->b == 0 && ctm->c == 0)
+ if (ctm.b == 0 && ctm.c == 0)
{
/* Simple, in place transform */
i = 0;
@@ -1008,16 +990,14 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_HORIZTO:
case FZ_HORIZTOCLOSE:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
n = 0;
break;
case FZ_VERTTO:
case FZ_VERTTOCLOSE:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
n = 0;
break;
@@ -1028,8 +1008,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
{
q.x = path->coords[k];
q.y = path->coords[k+1];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->coords[k++] = p.y;
n--;
@@ -1055,7 +1034,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
i++;
}
}
- else if (ctm->a == 0 && ctm->d == 0)
+ else if (ctm.a == 0 && ctm.d == 0)
{
/* In place transform with command rewriting */
i = 0;
@@ -1095,32 +1074,28 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_HORIZTO:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
path->cmds[i] = FZ_VERTTO;
n = 0;
break;
case FZ_HORIZTOCLOSE:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
path->cmds[i] = FZ_VERTTOCLOSE;
n = 0;
break;
case FZ_VERTTO:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->cmds[i] = FZ_HORIZTO;
n = 0;
break;
case FZ_VERTTOCLOSE:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->cmds[i] = FZ_HORIZTOCLOSE;
n = 0;
@@ -1130,10 +1105,9 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
}
while (n > 0)
{
- p.x = path->coords[k];
- p.y = path->coords[k+1];
- q = p;
- fz_transform_point(&p, ctm);
+ q.x = path->coords[k];
+ q.y = path->coords[k+1];
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->coords[k++] = p.y;
n--;
@@ -1240,10 +1214,10 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
p3.x = p.x;
p3.y = p2.y;
s = p;
- fz_transform_point(&p, ctm);
- fz_transform_point(&p1, ctm);
- fz_transform_point(&p2, ctm);
- fz_transform_point(&p3, ctm);
+ p = fz_transform_point(p, ctm);
+ p1 = fz_transform_point(p1, ctm);
+ p2 = fz_transform_point(p2, ctm);
+ p3 = fz_transform_point(p3, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->coords[coord_write++] = p1.x;
@@ -1260,8 +1234,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_HORIZTO:
q.x = path->coords[coord_read++];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETO;
@@ -1270,7 +1243,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_HORIZTOCLOSE:
p.x = path->coords[coord_read++];
p.y = q.y;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(p, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETOCLOSE;
@@ -1279,8 +1252,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_VERTTO:
q.y = path->coords[coord_read++];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETO;
@@ -1289,7 +1261,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_VERTTOCLOSE:
p.x = q.x;
p.y = path->coords[coord_read++];
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(p, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETOCLOSE;
@@ -1301,10 +1273,9 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
}
while (n > 0)
{
- p.x = path->coords[coord_read++];
- p.y = path->coords[coord_read++];
- q = p;
- fz_transform_point(&p, ctm);
+ q.x = path->coords[coord_read++];
+ q.y = path->coords[coord_read++];
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
n--;
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 9159fea0..a001b968 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -103,27 +103,27 @@ fz_new_pixmap(fz_context *ctx, fz_colorspace *colorspace, int w, int h, fz_separ
}
fz_pixmap *
-fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *r, fz_separations *seps, int alpha)
+fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha)
{
fz_pixmap *pixmap;
- pixmap = fz_new_pixmap(ctx, colorspace, r->x1 - r->x0, r->y1 - r->y0, seps, alpha);
- pixmap->x = r->x0;
- pixmap->y = r->y0;
+ pixmap = fz_new_pixmap(ctx, colorspace, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, seps, alpha);
+ pixmap->x = bbox.x0;
+ pixmap->y = bbox.y0;
return pixmap;
}
fz_pixmap *
-fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *r, fz_separations *seps, int alpha, unsigned char *samples)
+fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha, unsigned char *samples)
{
- int w = r->x1 - r->x0;
+ int w = bbox.x1 - bbox.x0;
int stride;
int s = fz_count_active_separations(ctx, seps);
fz_pixmap *pixmap;
if (!colorspace && s == 0) alpha = 1;
stride = (fz_colorspace_n(ctx, colorspace) + s + alpha) * w;
- pixmap = fz_new_pixmap_with_data(ctx, colorspace, w, r->y1 - r->y0, seps, alpha, stride, samples);
- pixmap->x = r->x0;
- pixmap->y = r->y0;
+ pixmap = fz_new_pixmap_with_data(ctx, colorspace, w, bbox.y1 - bbox.y0, seps, alpha, stride, samples);
+ pixmap->x = bbox.x0;
+ pixmap->y = bbox.y0;
return pixmap;
}
@@ -162,23 +162,25 @@ fz_pixmap *fz_new_pixmap_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, const f
return subpix;
}
-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)
{
- bbox->x0 = pix->x;
- bbox->y0 = pix->y;
- bbox->x1 = pix->x + pix->w;
- bbox->y1 = pix->y + pix->h;
+ fz_irect bbox;
+ bbox.x0 = pix->x;
+ bbox.y0 = pix->y;
+ bbox.x1 = pix->x + pix->w;
+ bbox.y1 = pix->y + pix->h;
return bbox;
}
-fz_irect *
-fz_pixmap_bbox_no_ctx(const fz_pixmap *pix, fz_irect *bbox)
+fz_irect
+fz_pixmap_bbox_no_ctx(const fz_pixmap *pix)
{
- bbox->x0 = pix->x;
- bbox->y0 = pix->y;
- bbox->x1 = pix->x + pix->w;
- bbox->y1 = pix->y + pix->h;
+ fz_irect bbox;
+ bbox.x0 = pix->x;
+ bbox.y0 = pix->y;
+ bbox.x1 = pix->x + pix->w;
+ bbox.y1 = pix->y + pix->h;
return bbox;
}
@@ -593,25 +595,23 @@ fz_fill_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, fz_colorspace *colors
}
void
-fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_irect *b, const fz_default_colorspaces *default_cs)
+fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect b, const fz_default_colorspaces *default_cs)
{
unsigned char *srcp;
unsigned char *destp;
int y, w, destspan, srcspan;
- fz_irect local_b, bb;
- local_b = *b;
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, dest, &bb));
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, src, &bb));
- w = local_b.x1 - local_b.x0;
- y = local_b.y1 - local_b.y0;
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, dest));
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, src));
+ w = b.x1 - b.x0;
+ y = b.y1 - b.y0;
if (w <= 0 || y <= 0)
return;
srcspan = src->stride;
- srcp = src->samples + (unsigned int)(srcspan * (local_b.y0 - src->y) + src->n * (local_b.x0 - src->x));
+ srcp = src->samples + (unsigned int)(srcspan * (b.y0 - src->y) + src->n * (b.x0 - src->x));
destspan = dest->stride;
- destp = dest->samples + (unsigned int)(destspan * (local_b.y0 - dest->y) + dest->n * (local_b.x0 - dest->x));
+ destp = dest->samples + (unsigned int)(destspan * (b.y0 - dest->y) + dest->n * (b.x0 - dest->x));
if (src->n == dest->n)
{
@@ -629,8 +629,8 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_i
fz_pixmap_converter *pc = fz_lookup_pixmap_converter(ctx, dest->colorspace, src->colorspace);
fz_pixmap fake_src = *src;
- fake_src.x = local_b.x0;
- fake_src.y = local_b.y0;
+ fake_src.x = b.x0;
+ fake_src.y = b.y0;
fake_src.w = w;
fake_src.h = y;
fake_src.samples = srcp;
@@ -640,21 +640,19 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_i
}
void
-fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, const fz_irect *b)
+fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_irect b)
{
unsigned char *destp;
int x, y, w, k, destspan;
- fz_irect bb;
- fz_irect local_b = *b;
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, dest, &bb));
- w = local_b.x1 - local_b.x0;
- y = local_b.y1 - local_b.y0;
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, dest));
+ w = b.x1 - b.x0;
+ y = b.y1 - b.y0;
if (w <= 0 || y <= 0)
return;
destspan = dest->stride;
- destp = dest->samples + (unsigned int)(destspan * (local_b.y0 - dest->y) + dest->n * (local_b.x0 - dest->x));
+ destp = dest->samples + (unsigned int)(destspan * (b.y0 - dest->y) + dest->n * (b.x0 - dest->x));
/* CMYK needs special handling (and potentially any other subtractive colorspaces) */
if (fz_colorspace_n(ctx, dest->colorspace) == 4)
@@ -733,11 +731,10 @@ fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray)
fz_pixmap *alpha;
unsigned char *sp, *dp;
int w, h, sstride, dstride;
- fz_irect bbox;
assert(gray->n == 1);
- alpha = fz_new_pixmap_with_bbox(ctx, NULL, fz_pixmap_bbox(ctx, gray, &bbox), 0, 1);
+ alpha = fz_new_pixmap_with_bbox(ctx, NULL, fz_pixmap_bbox(ctx, gray), 0, 1);
dp = alpha->samples;
dstride = alpha->stride;
sp = gray->samples;
@@ -822,15 +819,15 @@ fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix)
}
}
-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)
{
unsigned char *p;
int x, y, n;
- int x0 = fz_clampi(rect->x0 - image->x, 0, image->w);
- int x1 = fz_clampi(rect->x1 - image->x, 0, image->w);
- int y0 = fz_clampi(rect->y0 - image->y, 0, image->h);
- int y1 = fz_clampi(rect->y1 - image->y, 0, image->h);
+ int x0 = fz_clampi(rect.x0 - image->x, 0, image->w);
+ int x1 = fz_clampi(rect.x1 - image->x, 0, image->w);
+ int y0 = fz_clampi(rect.y0 - image->y, 0, image->h);
+ int y1 = fz_clampi(rect.y1 - image->y, 0, image->h);
for (y = y0; y < y1; y++)
{
diff --git a/source/fitz/separation.c b/source/fitz/separation.c
index c0f01f28..97822f80 100644
--- a/source/fitz/separation.c
+++ b/source/fitz/separation.c
@@ -241,7 +241,7 @@ fz_clone_pixmap_area_with_different_seps(fz_context *ctx, fz_pixmap *src, const
bbox = &local_bbox;
}
- dst = fz_new_pixmap_with_bbox(ctx, dcs, bbox, dseps, src->alpha);
+ dst = fz_new_pixmap_with_bbox(ctx, dcs, *bbox, dseps, src->alpha);
if (src->flags & FZ_PIXMAP_FLAG_INTERPOLATE)
dst->flags |= FZ_PIXMAP_FLAG_INTERPOLATE;
else
diff --git a/source/fitz/shade.c b/source/fitz/shade.c
index 13788472..faf8b67c 100644
--- a/source/fitz/shade.c
+++ b/source/fitz/shade.c
@@ -63,9 +63,9 @@ fz_prepare_color(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, floa
}
static inline void
-fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, const fz_matrix *ctm, float x, float y, float *c)
+fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, fz_matrix ctm, float x, float y, float *c)
{
- fz_transform_point_xy(&v->p, ctm, x, y);
+ v->p = fz_transform_point_xy(x, y, ctm);
if (painter->prepare)
{
painter->prepare(ctx, painter->process_arg, v, c);
@@ -73,7 +73,7 @@ fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, con
}
static void
-fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type1(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
float *p = shade->u.f.fn_vals;
int xdivs = shade->u.f.xdivs;
@@ -88,9 +88,8 @@ fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
fz_vertex *v = vs[0];
fz_vertex *vn = vs[1];
int n = fz_colorspace_n(ctx, shade->colorspace);
- fz_matrix local_ctm;
- fz_concat(&local_ctm, &shade->u.f.matrix, ctm);
+ ctm = fz_concat(shade->u.f.matrix, ctm);
y = y0;
for (yy = 0; yy < ydivs; yy++)
@@ -99,17 +98,17 @@ fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
x = x0;
- fz_prepare_vertex(ctx, painter, &v[0], &local_ctm, x, y, p);
+ fz_prepare_vertex(ctx, painter, &v[0], ctm, x, y, p);
p += n;
- fz_prepare_vertex(ctx, painter, &v[1], &local_ctm, x, yn, p + xdivs * n);
+ fz_prepare_vertex(ctx, painter, &v[1], ctm, x, yn, p + xdivs * n);
for (xx = 0; xx < xdivs; xx++)
{
x = x0 + (x1 - x0) * (xx + 1) / xdivs;
- fz_prepare_vertex(ctx, painter, &vn[0], &local_ctm, x, y, p);
+ fz_prepare_vertex(ctx, painter, &vn[0], ctm, x, y, p);
p += n;
- fz_prepare_vertex(ctx, painter, &vn[1], &local_ctm, x, yn, p + xdivs * n);
+ fz_prepare_vertex(ctx, painter, &vn[1], ctm, x, yn, p + xdivs * n);
paint_quad(ctx, painter, &v[0], &vn[0], &vn[1], &v[1]);
SWAP(v,vn);
@@ -130,7 +129,7 @@ fz_point_on_circle(fz_point p, float r, float theta)
}
static void
-fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type2(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_point p0, p1, dir;
fz_vertex v0, v1, v2, v3;
@@ -145,9 +144,9 @@ fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
p1.y = shade->u.l_or_r.coords[1][1];
dir.x = p0.y - p1.y;
dir.y = p1.x - p0.x;
- fz_transform_point(&p0, ctm);
- fz_transform_point(&p1, ctm);
- fz_transform_vector(&dir, ctm);
+ p0 = fz_transform_point(p0, ctm);
+ p1 = fz_transform_point(p1, ctm);
+ dir = fz_transform_vector(dir, ctm);
theta = atan2f(dir.y, dir.x);
v0.p = fz_point_on_circle(p0, HUGENUM, theta);
@@ -190,7 +189,7 @@ fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
+fz_paint_annulus(fz_context *ctx, fz_matrix ctm,
fz_point p0, float r0, float c0,
fz_point p1, float r1, float c1,
int count,
@@ -208,23 +207,14 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
{
b = i * step;
- t0.p = fz_point_on_circle(p0, r0, theta + a);
- t1.p = fz_point_on_circle(p0, r0, theta + b);
- t2.p = fz_point_on_circle(p1, r1, theta + a);
- t3.p = fz_point_on_circle(p1, r1, theta + b);
- b0.p = fz_point_on_circle(p0, r0, theta - a);
- b1.p = fz_point_on_circle(p0, r0, theta - b);
- b2.p = fz_point_on_circle(p1, r1, theta - a);
- b3.p = fz_point_on_circle(p1, r1, theta - b);
-
- fz_transform_point(&t0.p, ctm);
- fz_transform_point(&t1.p, ctm);
- fz_transform_point(&t2.p, ctm);
- fz_transform_point(&t3.p, ctm);
- fz_transform_point(&b0.p, ctm);
- fz_transform_point(&b1.p, ctm);
- fz_transform_point(&b2.p, ctm);
- fz_transform_point(&b3.p, ctm);
+ t0.p = fz_transform_point(fz_point_on_circle(p0, r0, theta + a), ctm);
+ t1.p = fz_transform_point(fz_point_on_circle(p0, r0, theta + b), ctm);
+ t2.p = fz_transform_point(fz_point_on_circle(p1, r1, theta + a), ctm);
+ t3.p = fz_transform_point(fz_point_on_circle(p1, r1, theta + b), ctm);
+ b0.p = fz_transform_point(fz_point_on_circle(p0, r0, theta - a), ctm);
+ b1.p = fz_transform_point(fz_point_on_circle(p0, r0, theta - b), ctm);
+ b2.p = fz_transform_point(fz_point_on_circle(p1, r1, theta - a), ctm);
+ b3.p = fz_transform_point(fz_point_on_circle(p1, r1, theta - b), ctm);
fz_prepare_color(ctx, painter, &t0, &c0);
fz_prepare_color(ctx, painter, &t1, &c0);
@@ -243,7 +233,7 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
}
static void
-fz_process_shade_type3(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type3(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_point p0, p1;
float r0, r1;
@@ -305,7 +295,7 @@ static inline float read_sample(fz_context *ctx, fz_stream *stream, int bits, fl
}
static void
-fz_process_shade_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type4(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex v[4];
@@ -384,7 +374,7 @@ fz_process_shade_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_process_shade_type5(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type5(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex *buf = NULL;
@@ -699,7 +689,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_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type6(fz_context *ctx, fz_shade *shade, 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];
@@ -747,7 +737,7 @@ fz_process_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
{
v[i].x = read_sample(ctx, stream, bpcoord, x0, x1);
v[i].y = read_sample(ctx, stream, bpcoord, y0, y1);
- fz_transform_point(&v[i], ctm);
+ v[i] = fz_transform_point(v[i], ctm);
}
for (i = startcolor; i < 4; i++)
@@ -812,7 +802,7 @@ fz_process_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type7(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
int bpflag = shade->u.m.bpflag;
@@ -860,7 +850,7 @@ fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
{
v[i].x = read_sample(ctx, stream, bpcoord, x0, x1);
v[i].y = read_sample(ctx, stream, bpcoord, y0, y1);
- fz_transform_point(&v[i], ctm);
+ v[i] = fz_transform_point(v[i], ctm);
}
for (i = startcolor; i < 4; i++)
@@ -925,7 +915,7 @@ fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
void
-fz_process_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
+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)
{
fz_mesh_processor painter;
@@ -954,28 +944,29 @@ fz_process_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type);
}
-static fz_rect *
-fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade)
{
- bbox->x0 = shade->u.f.domain[0][0];
- bbox->y0 = shade->u.f.domain[0][1];
- bbox->x1 = shade->u.f.domain[1][0];
- bbox->y1 = shade->u.f.domain[1][1];
- return fz_transform_rect(bbox, &shade->u.f.matrix);
+ fz_rect bbox;
+ bbox.x0 = shade->u.f.domain[0][0];
+ bbox.y0 = shade->u.f.domain[0][1];
+ bbox.x1 = shade->u.f.domain[1][0];
+ bbox.y1 = shade->u.f.domain[1][1];
+ return fz_transform_rect(bbox, shade->u.f.matrix);
}
-static fz_rect *
-fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade)
{
/* FIXME: If axis aligned and not extended, the bbox may only be
* infinite in one direction */
- *bbox = fz_infinite_rect;
- return bbox;
+ return fz_infinite_rect;
}
-static fz_rect *
-fz_bound_mesh_type3(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_point p0, p1;
float r0, r1;
@@ -985,19 +976,13 @@ fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
if (shade->u.l_or_r.extend[0])
{
if (r0 >= r1)
- {
- *bbox = fz_infinite_rect;
- return bbox;
- }
+ return fz_infinite_rect;
}
if (shade->u.l_or_r.extend[1])
{
if (r0 <= r1)
- {
- *bbox = fz_infinite_rect;
- return bbox;
- }
+ return fz_infinite_rect;
}
p0.x = shade->u.l_or_r.coords[0][0];
@@ -1005,47 +990,46 @@ fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
p1.x = shade->u.l_or_r.coords[1][0];
p1.y = shade->u.l_or_r.coords[1][1];
- bbox->x0 = p0.x - r0; bbox->y0 = p0.y - r0;
- bbox->x1 = p0.x + r0; bbox->y1 = p0.x + r0;
- if (bbox->x0 > p1.x - r1)
- bbox->x0 = p1.x - r1;
- if (bbox->x1 < p1.x + r1)
- bbox->x1 = p1.x + r1;
- if (bbox->y0 > p1.y - r1)
- bbox->y0 = p1.y - r1;
- if (bbox->y1 < p1.y + r1)
- bbox->y1 = p1.y + r1;
+ bbox.x0 = p0.x - r0; bbox.y0 = p0.y - r0;
+ bbox.x1 = p0.x + r0; bbox.y1 = p0.x + r0;
+ if (bbox.x0 > p1.x - r1)
+ bbox.x0 = p1.x - r1;
+ if (bbox.x1 < p1.x + r1)
+ bbox.x1 = p1.x + r1;
+ if (bbox.y0 > p1.y - r1)
+ bbox.y0 = p1.y - r1;
+ if (bbox.y1 < p1.y + r1)
+ bbox.y1 = p1.y + r1;
return bbox;
}
-static fz_rect *
-fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade)
{
- bbox->x0 = shade->u.m.x0;
- bbox->y0 = shade->u.m.y0;
- bbox->x1 = shade->u.m.x1;
- bbox->y1 = shade->u.m.y1;
+ fz_rect bbox;
+ bbox.x0 = shade->u.m.x0;
+ bbox.y0 = shade->u.m.y0;
+ bbox.x1 = shade->u.m.x1;
+ bbox.y1 = shade->u.m.y1;
return bbox;
}
-static fz_rect *
-fz_bound_mesh(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh(fz_context *ctx, fz_shade *shade)
{
if (shade->type == FZ_FUNCTION_BASED)
- fz_bound_mesh_type1(ctx, shade, bbox);
+ return fz_bound_mesh_type1(ctx, shade);
else if (shade->type == FZ_LINEAR)
- fz_bound_mesh_type2(ctx, shade, bbox);
+ return fz_bound_mesh_type2(ctx, shade);
else if (shade->type == FZ_RADIAL)
- fz_bound_mesh_type3(ctx, shade, bbox);
+ return fz_bound_mesh_type3(ctx, shade);
else if (shade->type == FZ_MESH_TYPE4 ||
shade->type == FZ_MESH_TYPE5 ||
shade->type == FZ_MESH_TYPE6 ||
shade->type == FZ_MESH_TYPE7)
- fz_bound_mesh_type4567(ctx, shade, bbox);
+ return fz_bound_mesh_type4567(ctx, shade);
else
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type);
-
- return bbox;
}
fz_shade *
@@ -1072,18 +1056,15 @@ fz_drop_shade(fz_context *ctx, fz_shade *shade)
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_rect
+fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm)
{
- fz_matrix local_ctm;
- fz_rect rect;
-
- fz_concat(&local_ctm, &shade->matrix, ctm);
- *s = shade->bbox;
+ ctm = fz_concat(shade->matrix, ctm);
if (shade->type != FZ_LINEAR && shade->type != FZ_RADIAL)
{
- fz_bound_mesh(ctx, shade, &rect);
- fz_intersect_rect(s, &rect);
+ fz_rect rect = fz_bound_mesh(ctx, shade);
+ rect = fz_intersect_rect(rect, shade->bbox);
+ return fz_transform_rect(rect, ctm);
}
- return fz_transform_rect(s, &local_ctm);
+ return fz_transform_rect(shade->bbox, ctm);
}
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index ffff886a..a4a8d002 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -34,7 +34,7 @@ const char *fz_stext_options_usage =
"\n";
fz_stext_page *
-fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox)
+fz_new_stext_page(fz_context *ctx, fz_rect mediabox)
{
fz_pool *pool = fz_new_pool(ctx);
fz_stext_page *page = NULL;
@@ -42,7 +42,7 @@ fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox)
{
page = fz_pool_alloc(ctx, pool, sizeof(*page));
page->pool = pool;
- page->mediabox = *mediabox;
+ page->mediabox = mediabox;
page->first_block = NULL;
page->last_block = NULL;
}
@@ -97,11 +97,7 @@ add_image_block_to_page(fz_context *ctx, fz_stext_page *page, const fz_matrix *c
block->type = FZ_STEXT_BLOCK_IMAGE;
block->u.i.transform = *ctm;
block->u.i.image = fz_keep_image(ctx, image);
- block->bbox.x0 = 0;
- block->bbox.y0 = 0;
- block->bbox.x1 = 1;
- block->bbox.y1 = 1;
- fz_transform_rect(&block->bbox, ctm);
+ block->bbox = fz_transform_rect(fz_unit_rect, *ctm);
return block;
}
@@ -125,7 +121,7 @@ add_line_to_block(fz_context *ctx, fz_stext_page *page, fz_stext_block *block, c
}
static fz_stext_char *
-add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, const fz_matrix *trm, fz_font *font, float size, int c, fz_point *p, fz_point *q)
+add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, fz_matrix trm, fz_font *font, float size, int c, fz_point *p, fz_point *q)
{
fz_stext_char *ch = fz_pool_alloc(ctx, page->pool, sizeof *line->first_char);
fz_point a, d;
@@ -158,8 +154,8 @@ add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, cons
a.y = 0;
d.y = 0;
}
- fz_transform_vector(&a, trm);
- fz_transform_vector(&d, trm);
+ a = fz_transform_vector(a, trm);
+ d = fz_transform_vector(d, trm);
ch->quad.ll = fz_make_point(p->x + d.x, p->y + d.y);
ch->quad.ul = fz_make_point(p->x + a.x, p->y + a.y);
@@ -209,7 +205,7 @@ vec_dot(const fz_point *a, const fz_point *b)
}
static void
-fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix *trm, float adv, int wmode)
+fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix trm, float adv, int wmode)
{
fz_stext_page *page = dev->page;
fz_stext_block *cur_block;
@@ -238,9 +234,8 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
dir.x = 0;
dir.y = -1;
}
- fz_transform_vector(&dir, trm);
- ndir = dir;
- fz_normalize_vector(&ndir);
+ dir = fz_transform_vector(dir, trm);
+ ndir = fz_normalize_vector(dir);
size = fz_matrix_expansion(trm);
@@ -261,17 +256,17 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
*/
if (wmode == 0)
{
- p.x = trm->e;
- p.y = trm->f;
- q.x = trm->e + adv * dir.x;
- q.y = trm->f + adv * dir.y;
+ p.x = trm.e;
+ p.y = trm.f;
+ q.x = trm.e + adv * dir.x;
+ q.y = trm.f + adv * dir.y;
}
else
{
- p.x = trm->e - adv * dir.x;
- p.y = trm->f - adv * dir.y;
- q.x = trm->e;
- q.y = trm->f;
+ p.x = trm.e - adv * dir.x;
+ p.y = trm.f - adv * dir.y;
+ q.x = trm.e;
+ q.y = trm.f;
}
/* Find current position to enter new text. */
@@ -391,11 +386,11 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
dev->pen = q;
dev->new_obj = 0;
- dev->trm = *trm;
+ dev->trm = trm;
}
static void
-fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix *trm, float adv, int wmode)
+fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix trm, float adv, int wmode)
{
/* ignore when one unicode character maps to multiple glyphs */
if (c == -1)
@@ -466,7 +461,7 @@ fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, i
}
static void
-fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, const fz_matrix *ctm)
+fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, fz_matrix ctm)
{
fz_font *font = span->font;
fz_matrix tm = span->trm;
@@ -479,14 +474,14 @@ fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, cons
tm.e = 0;
tm.f = 0;
- fz_concat(&trm, &tm, ctm);
+ trm = fz_concat(tm, ctm);
for (i = 0; i < span->len; i++)
{
/* Calculate new pen location and delta */
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, ctm);
+ trm = fz_concat(tm, ctm);
/* Calculate bounding box and new pen position based on font metrics */
if (span->items[i].gid >= 0)
@@ -494,7 +489,7 @@ fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, cons
else
adv = 0;
- fz_add_stext_char(ctx, dev, font, span->items[i].ucs, span->items[i].gid, &trm, adv, span->wmode);
+ fz_add_stext_char(ctx, dev, font, span->items[i].ucs, span->items[i].gid, trm, adv, span->wmode);
}
}
@@ -506,7 +501,7 @@ fz_stext_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -517,7 +512,7 @@ fz_stext_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -527,7 +522,7 @@ fz_stext_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -537,7 +532,7 @@ fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text,
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -547,7 +542,7 @@ fz_stext_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
/* Images and shadings */
@@ -580,11 +575,11 @@ fz_new_image_from_shade(fz_context *ctx, fz_shade *shade, fz_matrix *in_out_ctm,
fz_rect bounds;
fz_irect bbox;
- fz_bound_shade(ctx, shade, &ctm, &bounds);
- fz_intersect_rect(&bounds, scissor);
- fz_irect_from_rect(&bbox, &bounds);
+ bounds = fz_bound_shade(ctx, shade, ctm);
+ bounds = fz_intersect_rect(bounds, *scissor);
+ bbox = fz_irect_from_rect(bounds);
- pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox, NULL, !shade->use_background);
+ pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), bbox, NULL, !shade->use_background);
fz_try(ctx)
{
if (shade->use_background)
@@ -638,11 +633,8 @@ fz_stext_close_device(fz_context *ctx, fz_device *dev)
for (line = block->u.t.first_line; line; line = line->next)
{
for (ch = line->first_char; ch; ch = ch->next)
- {
- fz_rect bbox = fz_rect_from_quad(ch->quad);
- fz_union_rect(&line->bbox, &bbox);
- }
- fz_union_rect(&block->bbox, &line->bbox);
+ line->bbox = fz_union_rect(line->bbox, fz_rect_from_quad(ch->quad));
+ block->bbox = fz_union_rect(block->bbox, line->bbox);
}
}
diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c
index 66433489..d949f2d8 100644
--- a/source/fitz/stext-output.c
+++ b/source/fitz/stext-output.c
@@ -465,7 +465,7 @@ text_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediab
wri->page = NULL;
}
- wri->page = fz_new_stext_page(ctx, mediabox);
+ wri->page = fz_new_stext_page(ctx, *mediabox);
return fz_new_stext_device(ctx, wri->page, &wri->opts);
}
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index c5905938..28f3a4d6 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -173,7 +173,7 @@ svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, const fz_stroke_state *s
fz_output *out = sdev->out;
float exp;
- exp = fz_matrix_expansion(ctm);
+ exp = fz_matrix_expansion(*ctm);
if (exp == 0)
exp = 1;
exp = stroke_state->linewidth/exp;
@@ -269,13 +269,13 @@ find_first_char(fz_context *ctx, const fz_text_span *span, int i)
}
static int
-find_next_line_break(fz_context *ctx, const fz_text_span *span, const fz_matrix *inv_tm, int i)
+find_next_line_break(fz_context *ctx, const fz_text_span *span, fz_matrix inv_tm, int i)
{
fz_point p, old_p;
old_p.x = span->items[i].x;
old_p.y = span->items[i].y;
- fz_transform_point(&old_p, inv_tm);
+ old_p = fz_transform_point(old_p, inv_tm);
for (++i; i < span->len; ++i)
{
@@ -283,7 +283,7 @@ find_next_line_break(fz_context *ctx, const fz_text_span *span, const fz_matrix
{
p.x = span->items[i].x;
p.y = span->items[i].y;
- fz_transform_point(&p, inv_tm);
+ p = fz_transform_point(p, inv_tm);
if (span->wmode == 0)
{
if (p.y != old_p.y)
@@ -332,15 +332,15 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
}
tm = span->trm;
- font_size = fz_matrix_expansion(&tm);
+ font_size = fz_matrix_expansion(tm);
final_tm.a = tm.a / font_size;
final_tm.b = tm.b / font_size;
final_tm.c = -tm.c / font_size;
final_tm.d = -tm.d / font_size;
final_tm.e = 0;
final_tm.f = 0;
- fz_invert_matrix(&inv_tm, &final_tm);
- fz_concat(&final_tm, &final_tm, ctm);
+ inv_tm = fz_invert_matrix(final_tm);
+ final_tm = fz_concat(final_tm, *ctm);
tm.e = span->items[0].x;
tm.f = span->items[0].y;
@@ -362,11 +362,11 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
start = find_first_char(ctx, span, 0);
while (start < span->len)
{
- end = find_next_line_break(ctx, span, &inv_tm, start);
+ end = find_next_line_break(ctx, span, inv_tm, start);
p.x = span->items[start].x;
p.y = span->items[start].y;
- fz_transform_point(&p, &inv_tm);
+ p = fz_transform_point(p, inv_tm);
if (span->items[start].gid >= 0)
cluster_advance = svg_cluster_advance(ctx, span, start, end);
if (span->wmode == 0)
@@ -384,7 +384,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
{
p.x = it->x;
p.y = it->y;
- fz_transform_point(&p, &inv_tm);
+ p = fz_transform_point(p, inv_tm);
}
else
{
@@ -476,10 +476,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
path = fz_outline_glyph(ctx, span->font, gid, &fz_identity);
if (path)
{
- fz_bound_path(ctx, path, NULL, &fz_identity, &rect);
+ rect = fz_bound_path(ctx, path, NULL, fz_identity);
shift.e = -rect.x0;
shift.f = -rect.y0;
- fz_transform_path(ctx, path, &shift);
+ fz_transform_path(ctx, path, shift);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
fz_write_printf(ctx, out, "<path");
@@ -489,7 +489,7 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
}
else
{
- fz_bound_glyph(ctx, span->font, gid, &fz_identity, &rect);
+ rect = fz_bound_glyph(ctx, span->font, gid, fz_identity);
shift.e = -rect.x0;
shift.f = -rect.y0;
out = start_def(ctx, sdev);
@@ -536,8 +536,8 @@ svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, const fz_text_s
shift.f = fnt->sentlist[gid].y_off;
local_trm.e = it->x;
local_trm.f = it->y;
- fz_concat(&local_trm2, &local_trm, ctm);
- fz_concat(&local_trm2, &shift, &local_trm2);
+ local_trm2 = fz_concat(local_trm, *ctm);
+ local_trm2 = fz_concat(shift, local_trm2);
fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_ctm(ctx, sdev, &local_trm2);
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha, color_params);
@@ -576,8 +576,8 @@ svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, const fz_text
shift.f = fnt->sentlist[gid].y_off;
local_trm.e = it->x;
local_trm.f = it->y;
- fz_concat(&local_trm2, &local_trm, ctm);
- fz_concat(&local_trm2, &shift, &local_trm2);
+ local_trm2 = fz_concat(local_trm, *ctm);
+ local_trm2 = fz_concat(shift, local_trm2);
fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_stroke_state(ctx, sdev, stroke, &local_trm2);
svg_dev_ctm(ctx, sdev, &local_trm2);
@@ -649,7 +649,7 @@ svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, c
int num = sdev->id++;
float white[3] = { 1, 1, 1 };
- fz_bound_path(ctx, path, stroke, ctm, &bounds);
+ bounds = fz_bound_path(ctx, path, stroke, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n",
@@ -732,7 +732,7 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
font *fnt;
fz_text_span *span;
- fz_bound_text(ctx, text, NULL, ctm, &bounds);
+ bounds = fz_bound_text(ctx, text, NULL, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
@@ -772,7 +772,7 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
font *fnt;
fz_text_span *span;
- fz_bound_text(ctx, text, NULL, ctm, &bounds);
+ bounds = fz_bound_text(ctx, text, NULL, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
@@ -890,7 +890,7 @@ svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
fz_write_printf(ctx, out, "<g");
if (alpha != 1.0f)
fz_write_printf(ctx, out, " opacity=\"%g\"", alpha);
@@ -905,7 +905,6 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_rect rect;
fz_irect bbox;
fz_pixmap *pix;
fz_buffer *buf = NULL;
@@ -915,10 +914,10 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
if (dev->container_len == 0)
return;
- fz_round_rect(&bbox, fz_intersect_rect(fz_bound_shade(ctx, shade, ctm, &rect), &dev->container[dev->container_len-1].scissor));
- if (fz_is_empty_irect(&bbox))
+ bbox = fz_round_rect(fz_intersect_rect(fz_bound_shade(ctx, shade, *ctm), dev->container[dev->container_len-1].scissor));
+ if (fz_is_empty_irect(bbox))
return;
- pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox, NULL, 1);
+ pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), bbox, NULL, 1);
fz_clear_pixmap(ctx, pix);
fz_try(ctx)
@@ -957,7 +956,7 @@ svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
svg_send_image(ctx, sdev, image, color_params);
@@ -981,7 +980,7 @@ svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask);
svg_dev_ctm(ctx, sdev, &local_ctm);
@@ -1139,7 +1138,7 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev)
/* All the pattern contents will have their own ctm applied. Let's
* undo the current one to allow for this */
- fz_invert_matrix(&inverse, &t->ctm);
+ inverse = fz_invert_matrix(t->ctm);
fz_write_printf(ctx, out, "<g");
svg_dev_ctm(ctx, sdev, &inverse);
fz_write_printf(ctx, out, ">\n");
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c
index 8b2a7639..6eb1709e 100644
--- a/source/fitz/test-device.c
+++ b/source/fitz/test-device.c
@@ -177,7 +177,7 @@ fz_test_fill_shade(fz_context *ctx, fz_device *dev_, fz_shade *shade, const fz_m
arg.dev = dev;
arg.shade = shade;
arg.color_params = color_params;
- fz_process_shade(ctx, shade, ctm, prepare_vertex, NULL, &arg);
+ fz_process_shade(ctx, shade, *ctm, prepare_vertex, NULL, &arg);
}
}
}
diff --git a/source/fitz/text.c b/source/fitz/text.c
index 90698125..7fb46ae5 100644
--- a/source/fitz/text.c
+++ b/source/fitz/text.c
@@ -40,7 +40,7 @@ fz_drop_text(fz_context *ctx, const fz_text *textc)
}
static fz_text_span *
-fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, fz_matrix trm)
{
fz_text_span *span = fz_malloc_struct(ctx, fz_text_span);
span->font = fz_keep_font(ctx, font);
@@ -48,14 +48,14 @@ fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_b
span->bidi_level = bidi_level;
span->markup_dir = markup_dir;
span->language = language;
- span->trm = *trm;
+ span->trm = trm;
span->trm.e = 0;
span->trm.f = 0;
return span;
}
static fz_text_span *
-fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, fz_matrix trm)
{
if (!text->tail)
{
@@ -66,10 +66,10 @@ fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int b
text->tail->bidi_level != bidi_level ||
text->tail->markup_dir != markup_dir ||
text->tail->language != language ||
- text->tail->trm.a != trm->a ||
- text->tail->trm.b != trm->b ||
- text->tail->trm.c != trm->c ||
- text->tail->trm.d != trm->d)
+ text->tail->trm.a != trm.a ||
+ text->tail->trm.b != trm.b ||
+ text->tail->trm.c != trm.c ||
+ text->tail->trm.d != trm.d)
{
text->tail = text->tail->next = fz_new_text_span(ctx, font, wmode, bidi_level, markup_dir, language, trm);
}
@@ -89,7 +89,7 @@ fz_grow_text_span(fz_context *ctx, fz_text_span *span, int n)
}
void
-fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int gid, int ucs, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language lang)
+fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix trm, int gid, int ucs, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language lang)
{
fz_text_span *span;
@@ -102,8 +102,8 @@ fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *tr
span->items[span->len].ucs = ucs;
span->items[span->len].gid = gid;
- span->items[span->len].x = trm->e;
- span->items[span->len].y = trm->f;
+ span->items[span->len].x = trm.e;
+ span->items[span->len].y = trm.f;
span->len++;
}
@@ -118,24 +118,25 @@ fz_show_string(fz_context *ctx, fz_text *text, fz_font *user_font, fz_matrix *tr
{
s += fz_chartorune(&ucs, s);
gid = fz_encode_character_with_fallback(ctx, user_font, ucs, 0, language, &font);
- fz_show_glyph(ctx, text, font, trm, gid, ucs, wmode, bidi_level, markup_dir, language);
+ fz_show_glyph(ctx, text, font, *trm, gid, ucs, wmode, bidi_level, markup_dir, language);
adv = fz_advance_glyph(ctx, font, gid, wmode);
if (wmode == 0)
- fz_pre_translate(trm, adv, 0);
+ *trm = fz_pre_translate(*trm, adv, 0);
else
- fz_pre_translate(trm, 0, -adv);
+ *trm = fz_pre_translate(*trm, 0, -adv);
}
}
-fz_rect *
-fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *bbox)
+fz_rect
+fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm)
{
fz_text_span *span;
fz_matrix tm, trm;
fz_rect gbox;
+ fz_rect bbox;
int i;
- *bbox = fz_empty_rect;
+ bbox = fz_empty_rect;
for (span = text->head; span; span = span->next)
{
@@ -148,9 +149,9 @@ fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *strok
{
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, ctm);
- fz_bound_glyph(ctx, span->font, span->items[i].gid, &trm, &gbox);
- fz_union_rect(bbox, &gbox);
+ trm = fz_concat(tm, ctm);
+ gbox = fz_bound_glyph(ctx, span->font, span->items[i].gid, trm);
+ bbox = fz_union_rect(bbox, gbox);
}
}
}
@@ -159,13 +160,13 @@ fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *strok
if (!fz_is_empty_rect(bbox))
{
if (stroke)
- fz_adjust_rect_for_stroke(ctx, bbox, stroke, ctm);
+ bbox = fz_adjust_rect_for_stroke(ctx, bbox, stroke, ctm);
/* Compensate for the glyph cache limited positioning precision */
- bbox->x0 -= 1;
- bbox->y0 -= 1;
- bbox->x1 += 1;
- bbox->y1 += 1;
+ bbox.x0 -= 1;
+ bbox.y0 -= 1;
+ bbox.x1 += 1;
+ bbox.y1 += 1;
}
return bbox;
diff --git a/source/fitz/util.c b/source/fitz/util.c
index 0f935e53..ddbb36b8 100644
--- a/source/fitz/util.c
+++ b/source/fitz/util.c
@@ -6,11 +6,9 @@ fz_display_list *
fz_new_display_list_from_page(fz_context *ctx, fz_page *page)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_page(ctx, page, &bounds));
-
+ list = fz_new_display_list(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
dev = fz_new_list_device(ctx, list);
@@ -50,10 +48,9 @@ fz_display_list *
fz_new_display_list_from_page_contents(fz_context *ctx, fz_page *page)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_page(ctx, page, &bounds));
+ list = fz_new_display_list(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
@@ -78,10 +75,9 @@ fz_display_list *
fz_new_display_list_from_annot(fz_context *ctx, fz_annot *annot)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_annot(ctx, annot, &bounds));
+ list = fz_new_display_list(ctx, fz_bound_annot(ctx, annot));
fz_try(ctx)
{
@@ -106,15 +102,15 @@ fz_pixmap *
fz_new_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_display_list(ctx, list, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_display_list(ctx, list);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -143,15 +139,15 @@ fz_pixmap *
fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_page(ctx, page, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_page(ctx, page);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -180,15 +176,15 @@ fz_pixmap *
fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_annot(ctx, annot, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_annot(ctx, annot);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -217,15 +213,15 @@ fz_pixmap *
fz_new_pixmap_from_page(fz_context *ctx, fz_page *page, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_page(ctx, page, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_page(ctx, page);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -271,12 +267,11 @@ fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, cons
{
fz_stext_page *text;
fz_device *dev = NULL;
- fz_rect mediabox;
if (list == NULL)
return NULL;
- text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list, &mediabox));
+ text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list));
fz_try(ctx)
{
dev = fz_new_stext_device(ctx, text, options);
@@ -301,12 +296,11 @@ fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, const fz_stext_optio
{
fz_stext_page *text;
fz_device *dev = NULL;
- fz_rect mediabox;
if (page == NULL)
return NULL;
- text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
+ text = fz_new_stext_page(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
dev = fz_new_stext_device(ctx, text, options);
diff --git a/source/gprf/gprf-skeleton.c b/source/gprf/gprf-skeleton.c
index f70e82a5..1901c171 100644
--- a/source/gprf/gprf-skeleton.c
+++ b/source/gprf/gprf-skeleton.c
@@ -38,7 +38,7 @@ fz_save_gproof(fz_context *ctx, const char *pdf_file, fz_document *doc, const ch
int w, h;
page = fz_load_page(ctx, doc, i);
- fz_bound_page(ctx, page, &rect);
+ rect = fz_bound_page(ctx, page);
fz_drop_page(ctx, page);
page = NULL;
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c
index deb45f92..5325c316 100644
--- a/source/html/epub-doc.c
+++ b/source/html/epub-doc.c
@@ -121,31 +121,31 @@ epub_drop_page(fz_context *ctx, fz_page *page_)
{
}
-static fz_rect *
-epub_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox)
+static fz_rect
+epub_bound_page(fz_context *ctx, fz_page *page_)
{
epub_page *page = (epub_page*)page_;
epub_document *doc = page->doc;
epub_chapter *ch;
int n = page->number;
int count = 0;
+ fz_rect bbox;
for (ch = doc->spine; ch; ch = ch->next)
{
int cn = count_chapter_pages(ch);
if (n < count + cn)
{
- bbox->x0 = 0;
- bbox->y0 = 0;
- bbox->x1 = ch->html->page_w + ch->html->page_margin[L] + ch->html->page_margin[R];
- bbox->y1 = ch->html->page_h + ch->html->page_margin[T] + ch->html->page_margin[B];
+ bbox.x0 = 0;
+ bbox.y0 = 0;
+ bbox.x1 = ch->html->page_w + ch->html->page_margin[L] + ch->html->page_margin[R];
+ bbox.y1 = ch->html->page_h + ch->html->page_margin[T] + ch->html->page_margin[B];
return bbox;
}
count += cn;
}
- *bbox = fz_unit_rect;
- return bbox;
+ return fz_unit_rect;
}
static void
@@ -162,7 +162,7 @@ epub_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *
int cn = count_chapter_pages(ch);
if (n < count + cn)
{
- fz_draw_html(ctx, dev, ctm, ch->html, n-count);
+ fz_draw_html(ctx, dev, *ctm, ch->html, n-count);
break;
}
count += cn;
diff --git a/source/html/html-doc.c b/source/html/html-doc.c
index 98bb082a..45fbd8f9 100644
--- a/source/html/html-doc.c
+++ b/source/html/html-doc.c
@@ -74,15 +74,16 @@ htdoc_drop_page(fz_context *ctx, fz_page *page_)
{
}
-static fz_rect *
-htdoc_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bbox)
+static fz_rect
+htdoc_bound_page(fz_context *ctx, fz_page *page_)
{
html_page *page = (html_page*)page_;
html_document *doc = page->doc;
- bbox->x0 = 0;
- bbox->y0 = 0;
- bbox->x1 = doc->html->page_w + doc->html->page_margin[L] + doc->html->page_margin[R];
- bbox->y1 = doc->html->page_h + doc->html->page_margin[T] + doc->html->page_margin[B];
+ fz_rect bbox;
+ bbox.x0 = 0;
+ bbox.y0 = 0;
+ bbox.x1 = doc->html->page_w + doc->html->page_margin[L] + doc->html->page_margin[R];
+ bbox.y1 = doc->html->page_h + doc->html->page_margin[T] + doc->html->page_margin[B];
return bbox;
}
@@ -91,7 +92,7 @@ htdoc_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix
{
html_page *page = (html_page*)page_;
html_document *doc = page->doc;
- fz_draw_html(ctx, dev, ctm, doc->html, page->number);
+ fz_draw_html(ctx, dev, *ctm, doc->html, page->number);
}
static fz_link *
diff --git a/source/html/html-imp.h b/source/html/html-imp.h
index baab7c42..822074bd 100644
--- a/source/html/html-imp.h
+++ b/source/html/html-imp.h
@@ -280,7 +280,7 @@ void fz_add_css_font_faces(fz_context *ctx, fz_html_font_set *set, fz_archive *z
fz_html *fz_parse_html(fz_context *ctx, fz_html_font_set *htx, fz_archive *zip, const char *base_uri, fz_buffer *buf, const char *user_css);
void fz_layout_html(fz_context *ctx, fz_html *html, float w, float h, float em);
-void fz_draw_html(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, fz_html *html, int page);
+void fz_draw_html(fz_context *ctx, fz_device *dev, fz_matrix ctm, fz_html *html, int page);
float fz_find_html_target(fz_context *ctx, fz_html *html, const char *id);
fz_link *fz_load_html_links(fz_context *ctx, fz_html *html, int page, const char *base_uri, void *doc);
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 3d49b8dd..5f67c4e7 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -1599,7 +1599,7 @@ static float layout_block(fz_context *ctx, fz_html_box *box, float em, float top
return vertical;
}
-static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm, hb_buffer_t *hb_buf)
+static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, hb_buffer_t *hb_buf)
{
fz_html_flow *node;
fz_text *text;
@@ -1652,7 +1652,7 @@ static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, flo
{
if (text)
{
- fz_fill_text(ctx, dev, text, ctm, fz_device_rgb(ctx), prev_color, 1, NULL);
+ fz_fill_text(ctx, dev, text, &ctm, fz_device_rgb(ctx), prev_color, 1, NULL);
fz_drop_text(ctx, text);
text = NULL;
}
@@ -1711,7 +1711,7 @@ static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, flo
{
trm.e = x + walker.glyph_pos[i].x_offset * node_scale;
trm.f = y - walker.glyph_pos[i].y_offset * node_scale - page_top;
- fz_show_glyph(ctx, text, walker.font, &trm,
+ fz_show_glyph(ctx, text, walker.font, trm,
walker.glyph_info[i].codepoint, c,
0, node->bidi_level, box->markup_dir, node->markup_lang);
c = -1; /* for subsequent glyphs in x-to-many mappings */
@@ -1721,7 +1721,7 @@ static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, flo
/* no glyph found (many-to-many or many-to-one mapping) */
if (c != -1)
{
- fz_show_glyph(ctx, text, walker.font, &trm,
+ fz_show_glyph(ctx, text, walker.font, trm,
-1, c,
0, node->bidi_level, box->markup_dir, node->markup_lang);
}
@@ -1739,29 +1739,28 @@ static void draw_flow_box(fz_context *ctx, fz_html_box *box, float page_top, flo
{
if (text)
{
- fz_fill_text(ctx, dev, text, ctm, fz_device_rgb(ctx), color, 1, NULL);
+ fz_fill_text(ctx, dev, text, &ctm, fz_device_rgb(ctx), color, 1, NULL);
fz_drop_text(ctx, text);
text = NULL;
}
if (style->visibility == V_VISIBLE)
{
- fz_matrix local_ctm = *ctm;
- fz_pre_translate(&local_ctm, node->x, node->y - page_top);
- fz_pre_scale(&local_ctm, node->w, node->h);
- fz_fill_image(ctx, dev, node->content.image, &local_ctm, 1, NULL);
+ fz_matrix itm = fz_pre_translate(ctm, node->x, node->y - page_top);
+ itm = fz_pre_scale(itm, node->w, node->h);
+ fz_fill_image(ctx, dev, node->content.image, &itm, 1, NULL);
}
}
}
if (text)
{
- fz_fill_text(ctx, dev, text, ctm, fz_device_rgb(ctx), color, 1, NULL);
+ fz_fill_text(ctx, dev, text, &ctm, fz_device_rgb(ctx), color, 1, NULL);
fz_drop_text(ctx, text);
text = NULL;
}
}
-static void draw_rect(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, float page_top, fz_css_color color, float x0, float y0, float x1, float y1)
+static void draw_rect(fz_context *ctx, fz_device *dev, fz_matrix ctm, float page_top, fz_css_color color, float x0, float y0, float x1, float y1)
{
if (color.a > 0)
{
@@ -1779,7 +1778,7 @@ static void draw_rect(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, flo
rgb[1] = color.g / 255.0f;
rgb[2] = color.b / 255.0f;
- fz_fill_path(ctx, dev, path, 0, ctm, fz_device_rgb(ctx), rgb, color.a / 255.0f, NULL);
+ fz_fill_path(ctx, dev, path, 0, &ctm, fz_device_rgb(ctx), rgb, color.a / 255.0f, NULL);
fz_drop_path(ctx, path);
}
@@ -1875,7 +1874,7 @@ static fz_html_flow *find_list_mark_anchor(fz_context *ctx, fz_html_box *box)
return NULL;
}
-static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm, int n)
+static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, int n)
{
fz_font *font;
fz_text *text;
@@ -1887,7 +1886,7 @@ static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, fl
char buf[40];
int c, g;
- fz_scale(&trm, box->em, -box->em);
+ trm = fz_scale(box->em, -box->em);
line = find_list_mark_anchor(ctx, box);
if (line)
@@ -1929,7 +1928,7 @@ static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, fl
{
s += fz_chartorune(&c, s);
g = fz_encode_character_with_fallback(ctx, box->style.font, c, UCDN_SCRIPT_LATIN, FZ_LANG_UNSET, &font);
- fz_show_glyph(ctx, text, font, &trm, g, c, 0, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, trm, g, c, 0, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
trm.e += fz_advance_glyph(ctx, font, g, 0) * box->em;
}
@@ -1937,7 +1936,7 @@ static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, fl
color[1] = box->style.color.g / 255.0f;
color[2] = box->style.color.b / 255.0f;
- fz_fill_text(ctx, dev, text, ctm, fz_device_rgb(ctx), color, 1, NULL);
+ fz_fill_text(ctx, dev, text, &ctm, fz_device_rgb(ctx), color, 1, NULL);
}
fz_always(ctx)
fz_drop_text(ctx, text);
@@ -1945,7 +1944,7 @@ static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, fl
fz_rethrow(ctx);
}
-static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm, hb_buffer_t *hb_buf)
+static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, hb_buffer_t *hb_buf)
{
float x0, y0, x1, y1;
@@ -1991,9 +1990,8 @@ static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, fl
}
void
-fz_draw_html(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, fz_html *html, int page)
+fz_draw_html(fz_context *ctx, fz_device *dev, fz_matrix ctm, fz_html *html, int page)
{
- fz_matrix local_ctm = *ctm;
hb_buffer_t *hb_buf = NULL;
fz_html_box *box;
int unlocked = 0;
@@ -2008,7 +2006,7 @@ fz_draw_html(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, fz_html *htm
html->page_w + html->page_margin[L] + html->page_margin[R],
html->page_h + html->page_margin[T] + html->page_margin[B]);
- fz_pre_translate(&local_ctm, html->page_margin[L], html->page_margin[T]);
+ ctm = fz_pre_translate(ctm, html->page_margin[L], html->page_margin[T]);
fz_hb_lock(ctx);
fz_try(ctx)
@@ -2018,7 +2016,7 @@ fz_draw_html(fz_context *ctx, fz_device *dev, const fz_matrix *ctm, fz_html *htm
unlocked = 1;
for (box = html->root->down; box; box = box->next)
- draw_block_box(ctx, box, page_top, page_bot, dev, &local_ctm, hb_buf);
+ draw_block_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf);
}
fz_always(ctx)
{
@@ -2127,7 +2125,7 @@ static fz_link *load_link_flow(fz_context *ctx, fz_html_flow *flow, fz_link *hea
dest = href;
}
- link = fz_new_link(ctx, &bbox, NULL, dest);
+ link = fz_new_link(ctx, bbox, NULL, dest);
link->next = head;
head = link;
}
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 7dd4784e..e2e2392f 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -31,18 +31,18 @@ pdf_drop_annots(fz_context *ctx, pdf_annot *annot)
}
/* Create transform to fit appearance stream to annotation Rect */
-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)
{
fz_rect bbox, rect;
fz_matrix matrix;
float w, h, x, y;
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &rect);
- pdf_xobject_bbox(ctx, annot->ap, &bbox);
- pdf_xobject_matrix(ctx, annot->ap, &matrix);
+ rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
+ bbox = pdf_xobject_bbox(ctx, annot->ap);
+ matrix = pdf_xobject_matrix(ctx, annot->ap);
- fz_transform_rect(&bbox, &matrix);
+ bbox = fz_transform_rect(bbox, matrix);
if (bbox.x1 == bbox.x0)
w = 0;
else
@@ -54,7 +54,7 @@ pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm)
x = rect.x0 - bbox.x0;
y = rect.y0 - bbox.y0;
- fz_pre_scale(fz_translate(annot_ctm, x, y), w, h);
+ return fz_pre_scale(fz_translate(x, y), w, h);
}
pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page, pdf_obj *obj)
@@ -124,16 +124,13 @@ pdf_next_annot(fz_context *ctx, pdf_annot *annot)
return annot ? annot->next : NULL;
}
-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_obj *obj = pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect));
- fz_rect mediabox;
+ fz_rect annot_rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
fz_matrix page_ctm;
- pdf_to_rect(ctx, obj, rect);
- pdf_page_transform(ctx, annot->page, &mediabox, &page_ctm);
- fz_transform_rect(rect, &page_ctm);
- return rect;
+ pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
+ return fz_transform_rect(annot_rect, page_ctm);
}
void
@@ -369,26 +366,27 @@ pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags)
pdf_dirty_annot(ctx, 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)
{
fz_matrix page_ctm;
+ fz_rect rect;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), rect);
- fz_transform_rect(rect, &page_ctm);
+ rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
+ fz_transform_rect(rect, page_ctm);
+ return rect;
}
void
-pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect)
+pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect rect)
{
- fz_rect trect = *rect;
fz_matrix page_ctm, inv_page_ctm;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
- fz_transform_rect(&trect, &inv_page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
+ rect = fz_transform_rect(rect, inv_page_ctm);
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &trect);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), rect);
pdf_dirty_annot(ctx, annot);
}
@@ -832,8 +830,8 @@ pdf_annot_line(fz_context *ctx, pdf_annot *annot, fz_point *a, fz_point *b)
a->y = pdf_array_get_real(ctx, line, 1);
b->x = pdf_array_get_real(ctx, line, 2);
b->y = pdf_array_get_real(ctx, line, 3);
- fz_transform_point(a, &page_ctm);
- fz_transform_point(b, &page_ctm);
+ *a = fz_transform_point(*a, page_ctm);
+ *b = fz_transform_point(*b, page_ctm);
}
void
@@ -845,10 +843,10 @@ pdf_set_annot_line(fz_context *ctx, pdf_annot *annot, fz_point a, fz_point b)
check_allowed_subtypes(ctx, annot, PDF_NAME(L), line_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
- fz_transform_point(&a, &inv_page_ctm);
- fz_transform_point(&b, &inv_page_ctm);
+ a = fz_transform_point(a, inv_page_ctm);
+ b = fz_transform_point(b, inv_page_ctm);
line = pdf_new_array(ctx, annot->page->doc, 4);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(L), line);
@@ -896,9 +894,7 @@ pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i)
point.x = pdf_array_get_real(ctx, vertices, i * 2);
point.y = pdf_array_get_real(ctx, vertices, i * 2 + 1);
- fz_transform_point(&point, &page_ctm);
-
- return point;
+ return fz_transform_point(point, page_ctm);
}
void
@@ -915,13 +911,12 @@ pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const fz_point
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid number of vertices");
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
vertices = pdf_new_array(ctx, doc, n * 2);
for (i = 0; i < n; ++i)
{
- point = v[i];
- fz_transform_point(&point, &inv_page_ctm);
+ point = fz_transform_point(v[i], inv_page_ctm);
pdf_array_push_real(ctx, vertices, point.x);
pdf_array_push_real(ctx, vertices, point.y);
}
@@ -945,7 +940,7 @@ void pdf_add_annot_vertex(fz_context *ctx, pdf_annot *annot, fz_point p)
check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
if (!pdf_is_array(ctx, vertices))
@@ -954,7 +949,7 @@ void pdf_add_annot_vertex(fz_context *ctx, pdf_annot *annot, fz_point p)
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(Vertices), vertices);
}
- fz_transform_point(&p, &inv_page_ctm);
+ p = fz_transform_point(p, inv_page_ctm);
pdf_array_push_real(ctx, vertices, p.x);
pdf_array_push_real(ctx, vertices, p.y);
@@ -969,9 +964,9 @@ void pdf_set_annot_vertex(fz_context *ctx, pdf_annot *annot, int i, fz_point p)
check_allowed_subtypes(ctx, annot, PDF_NAME(Vertices), vertices_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
- fz_transform_point(&p, &inv_page_ctm);
+ p = fz_transform_point(p, inv_page_ctm);
vertices = pdf_dict_get(ctx, annot->obj, PDF_NAME(Vertices));
pdf_array_put_drop(ctx, vertices, i * 2 + 0, pdf_new_real(ctx, p.x));
@@ -1018,7 +1013,7 @@ pdf_annot_quad_point(fz_context *ctx, pdf_annot *annot, int idx, float v[8])
fz_point point;
point.x = pdf_array_get_real(ctx, quad_points, idx * 8 + i + 0);
point.y = pdf_array_get_real(ctx, quad_points, idx * 8 + i + 1);
- fz_transform_point(&point, &page_ctm);
+ point = fz_transform_point(point, page_ctm);
v[i+0] = point.x;
v[i+1] = point.y;
}
@@ -1038,7 +1033,7 @@ pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid number of quadrilaterals");
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
quad_points = pdf_new_array(ctx, doc, n * 8);
for (i = 0; i < n; ++i)
@@ -1047,7 +1042,7 @@ pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float
{
point.x = v[i * 8 + k * 2 + 0];
point.y = v[i * 8 + k * 2 + 1];
- fz_transform_point(&point, &inv_page_ctm);
+ point = fz_transform_point(point, inv_page_ctm);
pdf_array_push_real(ctx, quad_points, point.x);
pdf_array_push_real(ctx, quad_points, point.y);
}
@@ -1074,7 +1069,7 @@ pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_quad quad)
check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME(QuadPoints));
if (!pdf_is_array(ctx, quad_points))
@@ -1087,7 +1082,7 @@ pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_quad quad)
* in a counterclockwise fashion. Experiments with Adobe's implementation
* indicates a cross-wise ordering is intended: ul, ur, ll, lr.
*/
- fz_transform_quad(&quad, &inv_page_ctm);
+ quad = fz_transform_quad(quad, inv_page_ctm);
pdf_array_push_real(ctx, quad_points, quad.ul.x);
pdf_array_push_real(ctx, quad_points, quad.ul.y);
pdf_array_push_real(ctx, quad_points, quad.ur.x);
@@ -1148,9 +1143,7 @@ pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k
point.x = pdf_array_get_real(ctx, stroke, k * 2 + 0);
point.y = pdf_array_get_real(ctx, stroke, k * 2 + 1);
- fz_transform_point(&point, &page_ctm);
-
- return point;
+ return fz_transform_point(point, page_ctm);
}
void
@@ -1165,7 +1158,7 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun
check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
// TODO: update Rect (in update appearance perhaps?)
@@ -1175,8 +1168,7 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun
stroke = pdf_new_array(ctx, doc, count[i] * 2);
for (k = 0; k < count[i]; ++k)
{
- point = *v++;
- fz_transform_point(&point, &inv_page_ctm);
+ point = fz_transform_point(*v++, inv_page_ctm);
pdf_array_push_real(ctx, stroke, point.x);
pdf_array_push_real(ctx, stroke, point.y);
}
@@ -1205,7 +1197,7 @@ pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point p[])
check_allowed_subtypes(ctx, annot, PDF_NAME(InkList), ink_list_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME(InkList));
if (!pdf_is_array(ctx, ink_list))
@@ -1219,8 +1211,7 @@ pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point p[])
{
for (i = 0; i < n; ++i)
{
- fz_point tp = p[i];
- fz_transform_point(&tp, &inv_page_ctm);
+ fz_point tp = fz_transform_point(p[i], inv_page_ctm);
pdf_array_push_real(ctx, stroke, tp.x);
pdf_array_push_real(ctx, stroke, tp.y);
}
@@ -1244,15 +1235,15 @@ pdf_set_text_annot_position(fz_context *ctx, pdf_annot *annot, fz_point pt)
int flags;
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- fz_invert_matrix(&inv_page_ctm, &page_ctm);
+ inv_page_ctm = fz_invert_matrix(page_ctm);
rect.x0 = pt.x;
rect.x1 = pt.x + TEXT_ANNOT_SIZE;
rect.y0 = pt.y;
rect.y1 = pt.y + TEXT_ANNOT_SIZE;
- fz_transform_rect(&rect, &inv_page_ctm);
+ rect = fz_transform_rect(rect, inv_page_ctm);
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &rect);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), rect);
flags = pdf_dict_get_int(ctx, annot->obj, PDF_NAME(F));
flags |= (PDF_ANNOT_IS_NO_ZOOM|PDF_ANNOT_IS_NO_ROTATE);
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index 2c18a813..0e2e2847 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -113,9 +113,9 @@ static void pdf_write_arrow_appearance(fz_context *ctx, fz_buffer *buf, fz_rect
v = rotate_vector(angle, 8.8f*r, -4.5f*r);
b = fz_make_point(x + v.x, y + v.y);
- fz_include_point_in_rect(rect, &a);
- fz_include_point_in_rect(rect, &b);
- fz_expand_rect(rect, w);
+ *rect = fz_include_point_in_rect(*rect, a);
+ *rect = fz_include_point_in_rect(*rect, b);
+ *rect = fz_expand_rect(*rect, w);
fz_append_printf(ctx, buf, "%g %g m\n", a.x, a.y);
fz_append_printf(ctx, buf, "%g %g l\n", x, y);
@@ -182,8 +182,8 @@ pdf_write_line_cap_appearance(fz_context *ctx, fz_buffer *buf, fz_rect *rect,
fz_append_printf(ctx, buf, "%g %g m\n", a.x, a.y);
fz_append_printf(ctx, buf, "%g %g l\n", b.x, b.y);
fz_append_string(ctx, buf, "S\n");
- fz_include_point_in_rect(rect, &a);
- fz_include_point_in_rect(rect, &b);
+ *rect = fz_include_point_in_rect(*rect, a);
+ *rect = fz_include_point_in_rect(*rect, b);
}
/* PDF 1.6 */
else if (cap == PDF_NAME(ROpenArrow))
@@ -208,8 +208,8 @@ pdf_write_line_cap_appearance(fz_context *ctx, fz_buffer *buf, fz_rect *rect,
fz_append_printf(ctx, buf, "%g %g m\n", a.x, a.y);
fz_append_printf(ctx, buf, "%g %g l\n", b.x, b.y);
fz_append_string(ctx, buf, "S\n");
- fz_include_point_in_rect(rect, &a);
- fz_include_point_in_rect(rect, &b);
+ *rect = fz_include_point_in_rect(*rect, a);
+ *rect = fz_include_point_in_rect(*rect, b);
}
}
@@ -247,7 +247,7 @@ pdf_write_line_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf, fz_
pdf_write_line_cap_appearance(ctx, buf, rect, a.x, a.y, dx/l, dy/l, w, ic, pdf_array_get(ctx, le, 0));
pdf_write_line_cap_appearance(ctx, buf, rect, b.x, b.y, -dx/l, -dy/l, w, ic, pdf_array_get(ctx, le, 1));
}
- fz_expand_rect(rect, fz_max(1, w));
+ *rect = fz_expand_rect(*rect, fz_max(1, w));
}
static void
@@ -323,14 +323,14 @@ pdf_write_polygon_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf,
rect->y0 = rect->y1 = p.y;
}
else
- fz_include_point_in_rect(rect, &p);
+ *rect = fz_include_point_in_rect(*rect, p);
if (i == 0)
fz_append_printf(ctx, buf, "%g %g m\n", p.x, p.y);
else
fz_append_printf(ctx, buf, "%g %g l\n", p.x, p.y);
}
fz_append_string(ctx, buf, close ? "s" : "S");
- fz_expand_rect(rect, lw);
+ *rect = fz_expand_rect(*rect, lw);
}
}
@@ -363,12 +363,12 @@ pdf_write_ink_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf, fz_r
rect->y0 = rect->y1 = p.y;
}
else
- fz_include_point_in_rect(rect, &p);
+ *rect = fz_include_point_in_rect(*rect, p);
fz_append_printf(ctx, buf, "%g %g %c\n", p.x, p.y, k == 0 ? 'm' : 'l');
}
}
fz_append_printf(ctx, buf, "S");
- fz_expand_rect(rect, lw);
+ *rect = fz_expand_rect(*rect, lw);
}
/* Contrary to the specification, the points within a QuadPoint are NOT
@@ -398,13 +398,12 @@ extract_quad(fz_context *ctx, fz_point *quad, pdf_obj *obj, int i)
static void
union_quad(fz_rect *rect, const fz_point quad[4], float lw)
{
- fz_rect tmp;
- tmp.x0 = fz_min(fz_min(quad[0].x, quad[1].x), fz_min(quad[2].x, quad[3].x));
- tmp.y0 = fz_min(fz_min(quad[0].y, quad[1].y), fz_min(quad[2].y, quad[3].y));
- tmp.x1 = fz_max(fz_max(quad[0].x, quad[1].x), fz_max(quad[2].x, quad[3].x));
- tmp.y1 = fz_max(fz_max(quad[0].y, quad[1].y), fz_max(quad[2].y, quad[3].y));
- fz_expand_rect(&tmp, lw);
- fz_union_rect(rect, &tmp);
+ fz_rect qbox;
+ qbox.x0 = fz_min(fz_min(quad[0].x, quad[1].x), fz_min(quad[2].x, quad[3].x));
+ qbox.y0 = fz_min(fz_min(quad[0].y, quad[1].y), fz_min(quad[2].y, quad[3].y));
+ qbox.x1 = fz_max(fz_max(quad[0].x, quad[1].x), fz_max(quad[2].x, quad[3].x));
+ qbox.y1 = fz_max(fz_max(quad[0].y, quad[1].y), fz_max(quad[2].y, quad[3].y));
+ *rect = fz_union_rect(*rect, fz_expand_rect(qbox, lw));
}
static fz_point
@@ -745,7 +744,7 @@ pdf_write_stamp_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf, fz
pdf_write_fill_color_appearance(ctx, annot, buf);
pdf_write_stroke_color_appearance(ctx, annot, buf);
- fz_rotate(&rotate, 0.6f);
+ rotate = fz_rotate(0.6f);
fz_append_printf(ctx, buf, "%M cm\n", &rotate);
fz_append_string(ctx, buf, "2 w\n2 2 186 44 re\nS\n");
@@ -995,7 +994,7 @@ pdf_write_free_text_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf
if (r == 90 || r == 270)
t = h, h = w, w = t;
- fz_rotate(matrix, r);
+ *matrix = fz_rotate(r);
*bbox = fz_make_rect(0, 0, w, h);
if (pdf_write_fill_color_appearance(ctx, annot, buf))
@@ -1029,7 +1028,7 @@ pdf_write_tx_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf
h = rect->y1 - rect->y0;
if (r == 90 || r == 270)
t = h, h = w, w = t;
- fz_rotate(matrix, r);
+ *matrix = fz_rotate(r);
*bbox = fz_make_rect(0, 0, w, h);
fz_append_string(ctx, buf, "/Tx BMC\nq\n");
@@ -1253,9 +1252,9 @@ void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
fz_try(ctx)
{
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)), &rect);
+ rect = pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Rect)));
pdf_write_appearance(ctx, annot, buf, &rect, &bbox, &matrix, &res);
- pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &rect);
+ pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), rect);
if (!ap_n)
{
@@ -1264,13 +1263,13 @@ void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
ap = pdf_new_dict(ctx, annot->page->doc, 1);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(AP), ap);
}
- new_ap_n = pdf_new_xobject(ctx, annot->page->doc, &bbox, &matrix, res, buf);
+ new_ap_n = pdf_new_xobject(ctx, annot->page->doc, bbox, matrix, res, buf);
pdf_dict_put(ctx, ap, PDF_NAME(N), new_ap_n);
}
else
{
new_ap_n = pdf_keep_obj(ctx, ap_n);
- pdf_update_xobject(ctx, annot->page->doc, ap_n, &bbox, &matrix, res, buf);
+ pdf_update_xobject(ctx, annot->page->doc, ap_n, bbox, matrix, res, buf);
}
pdf_drop_obj(ctx, annot->ap);
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c
index 9b33e5c9..4358508e 100644
--- a/source/pdf/pdf-device.c
+++ b/source/pdf/pdf-device.c
@@ -207,8 +207,8 @@ pdf_dev_ctm(fz_context *ctx, pdf_device *pdev, const fz_matrix *ctm)
if (memcmp(&gs->ctm, ctm, sizeof(*ctm)) == 0)
return;
- fz_invert_matrix(&inverse, &gs->ctm);
- fz_concat(&inverse, ctm, &inverse);
+ inverse = fz_invert_matrix(gs->ctm);
+ inverse = fz_concat(*ctm, inverse);
gs->ctm = *ctm;
fz_append_printf(ctx, gs->buf, "%M cm\n", &inverse);
}
@@ -446,7 +446,7 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
tm.e = span->items[0].x;
tm.f = span->items[0].y;
- fz_invert_matrix(&inv_tm, &tm);
+ inv_tm = fz_invert_matrix(tm);
fz_append_printf(ctx, gs->buf, "%M Tm\n[<", &tm);
@@ -459,7 +459,7 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
/* transform difference from expected pen position into font units. */
d.x = it->x - tm.e;
d.y = it->y - tm.f;
- fz_transform_vector(&d, &inv_tm);
+ d = fz_transform_vector(d, inv_tm);
dx = (int)(d.x * 1000 + (d.x < 0 ? -0.5f : 0.5f));
dy = (int)(d.y * 1000 + (d.y < 0 ? -0.5f : 0.5f));
@@ -483,9 +483,9 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
adv = fz_advance_glyph(ctx, span->font, it->gid, span->wmode);
if (span->wmode == 0)
- fz_pre_translate(&tm, adv, 0);
+ tm = fz_pre_translate(tm, adv, 0);
else
- fz_pre_translate(&tm, 0, adv);
+ tm = fz_pre_translate(tm, 0, adv);
}
fz_append_string(ctx, gs->buf, ">]TJ\n");
@@ -605,7 +605,7 @@ pdf_dev_new_form(fz_context *ctx, pdf_obj **form_ref, pdf_device *pdev, const fz
pdf_dict_put(ctx, form, PDF_NAME(Subtype), PDF_NAME(Form));
pdf_dict_put(ctx, form, PDF_NAME(Group), group_ref);
pdf_dict_put_int(ctx, form, PDF_NAME(FormType), 1);
- pdf_dict_put_rect(ctx, form, PDF_NAME(BBox), bbox);
+ pdf_dict_put_rect(ctx, form, PDF_NAME(BBox), *bbox);
*form_ref = pdf_add_object(ctx, doc, form);
}
fz_always(ctx)
@@ -822,8 +822,8 @@ pdf_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
pdf_dev_alpha(ctx, pdev, alpha, 0);
/* PDF images are upside down, so fiddle the ctm */
- fz_pre_scale(&local_ctm, 1, -1);
- fz_pre_translate(&local_ctm, 0, -1);
+ local_ctm = fz_pre_scale(local_ctm, 1, -1);
+ local_ctm = fz_pre_translate(local_ctm, 0, -1);
pdf_dev_ctm(ctx, pdev, &local_ctm);
fz_append_printf(ctx, gs->buf, "/Img%d Do\n", pdf_to_num(ctx, im_res));
@@ -862,8 +862,8 @@ pdf_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
pdf_dev_color(ctx, pdev, colorspace, color, 0, color_params);
/* PDF images are upside down, so fiddle the ctm */
- fz_pre_scale(&local_ctm, 1, -1);
- fz_pre_translate(&local_ctm, 0, -1);
+ local_ctm = fz_pre_scale(local_ctm, 1, -1);
+ local_ctm = fz_pre_translate(local_ctm, 0, -1);
pdf_dev_ctm(ctx, pdev, &local_ctm);
fz_append_printf(ctx, gs->buf, "/Img%d Do Q\n", pdf_to_num(ctx, im_res));
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index b29a1a18..b540f4ec 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -1591,7 +1591,7 @@ pdf_add_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_fo
bbox.y0 = font->bbox.y0 * 1000;
bbox.x1 = font->bbox.x1 * 1000;
bbox.y1 = font->bbox.y1 * 1000;
- pdf_dict_put_rect(ctx, fdobj, PDF_NAME(FontBBox), &bbox);
+ pdf_dict_put_rect(ctx, fdobj, PDF_NAME(FontBBox), bbox);
pdf_dict_put_int(ctx, fdobj, PDF_NAME(ItalicAngle), 0);
pdf_dict_put_int(ctx, fdobj, PDF_NAME(Ascent), face->ascender * 1000.0f / face->units_per_EM);
@@ -2226,7 +2226,7 @@ pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *fzfont, int script
{
pdf_dict_put(ctx, fontdesc, PDF_NAME(Type), PDF_NAME(FontDescriptor));
pdf_dict_put_text_string(ctx, fontdesc, PDF_NAME(FontName), basefont);
- pdf_dict_put_rect(ctx, fontdesc, PDF_NAME(FontBBox), &bbox);
+ pdf_dict_put_rect(ctx, fontdesc, PDF_NAME(FontBBox), bbox);
pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Flags), flags);
pdf_dict_put_int(ctx, fontdesc, PDF_NAME(ItalicAngle), 0);
pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Ascent), 1000);
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 16811edd..f5466168 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -534,7 +534,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev
for (annot = page->annots; annot; annot = annot->next)
{
- pdf_bound_annot(ctx, annot, &bbox);
+ bbox = pdf_bound_annot(ctx, annot);
if (pt->x >= bbox.x0 && pt->x <= bbox.x1)
if (pt->y >= bbox.y0 && pt->y <= bbox.y1)
break;
@@ -996,9 +996,9 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
pdf_field_mark_dirty(ctx, doc, field);
}
-fz_rect *pdf_bound_widget(fz_context *ctx, pdf_widget *widget, fz_rect *rect)
+fz_rect pdf_bound_widget(fz_context *ctx, pdf_widget *widget)
{
- return pdf_bound_annot(ctx, (pdf_annot*)widget, rect);
+ return pdf_bound_annot(ctx, (pdf_annot*)widget);
}
char *pdf_text_widget_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw)
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c
index fe874807..55416b90 100644
--- a/source/pdf/pdf-interpret.c
+++ b/source/pdf/pdf-interpret.c
@@ -1072,8 +1072,7 @@ pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_p
if (proc->op_q && proc->op_cm && proc->op_Do_form && proc->op_Q && annot->ap)
{
- fz_matrix matrix;
- pdf_annot_transform(ctx, annot, &matrix);
+ fz_matrix matrix = pdf_annot_transform(ctx, annot);
proc->op_q(ctx, proc);
proc->op_cm(ctx, proc,
matrix.a, matrix.b,
@@ -1179,14 +1178,14 @@ pdf_tos_make_trm(fz_context *ctx, pdf_text_object_state *tos, pdf_text_state *te
tos->char_ty = w1 * text->size + text->char_space;
}
- fz_concat(trm, &tsm, &tos->tm);
+ *trm = fz_concat(tsm, tos->tm);
tos->cid = cid;
tos->gid = pdf_font_cid_to_gid(ctx, fontdesc, cid);
tos->fontdesc = fontdesc;
/* Compensate for the glyph cache limited positioning precision */
- fz_expand_rect(fz_bound_glyph(ctx, fontdesc->font, tos->gid, trm, &tos->char_bbox), 1);
+ tos->char_bbox = fz_expand_rect(fz_bound_glyph(ctx, fontdesc->font, tos->gid, *trm), 1);
return tos->gid;
}
@@ -1194,15 +1193,14 @@ pdf_tos_make_trm(fz_context *ctx, pdf_text_object_state *tos, pdf_text_state *te
void
pdf_tos_move_after_char(fz_context *ctx, pdf_text_object_state *tos)
{
- fz_union_rect(&tos->text_bbox, &tos->char_bbox);
-
- fz_pre_translate(&tos->tm, tos->char_tx, tos->char_ty);
+ tos->text_bbox = fz_union_rect(tos->text_bbox, tos->char_bbox);
+ tos->tm = fz_pre_translate(tos->tm, tos->char_tx, tos->char_ty);
}
void
pdf_tos_translate(pdf_text_object_state *tos, float tx, float ty)
{
- fz_pre_translate(&tos->tlm, tx, ty);
+ tos->tlm = fz_pre_translate(tos->tlm, tx, ty);
tos->tm = tos->tlm;
}
@@ -1221,6 +1219,6 @@ pdf_tos_set_matrix(pdf_text_object_state *tos, float a, float b, float c, float
void
pdf_tos_newline(pdf_text_object_state *tos, float leading)
{
- fz_pre_translate(&tos->tlm, 0, -leading);
+ tos->tlm = fz_pre_translate(tos->tlm, 0, -leading);
tos->tm = tos->tlm;
}
diff --git a/source/pdf/pdf-link.c b/source/pdf/pdf-link.c
index e9f1c36f..6fe6f334 100644
--- a/source/pdf/pdf-link.c
+++ b/source/pdf/pdf-link.c
@@ -255,8 +255,8 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int pagenum, co
if (!obj)
return NULL;
- pdf_to_rect(ctx, obj, &bbox);
- fz_transform_rect(&bbox, page_ctm);
+ bbox = pdf_to_rect(ctx, obj);
+ bbox = fz_transform_rect(bbox, *page_ctm);
obj = pdf_dict_get(ctx, dict, PDF_NAME(Dest));
if (obj)
@@ -274,7 +274,7 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int pagenum, co
return NULL;
fz_try(ctx)
- link = fz_new_link(ctx, &bbox, doc, uri);
+ link = fz_new_link(ctx, bbox, doc, uri);
fz_always(ctx)
fz_free(ctx, uri);
fz_catch(ctx)
@@ -343,7 +343,7 @@ pdf_resolve_link(fz_context *ctx, pdf_document *doc, const char *uri, float *xp,
p.y = y ? fz_atoi(y + 1) : 0;
obj = pdf_lookup_page_obj(ctx, doc, page);
pdf_page_obj_transform(ctx, obj, NULL, &ctm);
- fz_transform_point(&p, &ctm);
+ p = fz_transform_point(p, ctm);
if (xp) *xp = p.x;
if (yp) *yp = p.y;
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index ff425a8f..32a02b9b 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -811,15 +811,15 @@ pdf_array_find(fz_context *ctx, pdf_obj *arr, pdf_obj *obj)
return -1;
}
-pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, const fz_rect *rect)
+pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, fz_rect rect)
{
pdf_obj *arr = pdf_new_array(ctx, doc, 4);
fz_try(ctx)
{
- pdf_array_push_real(ctx, arr, rect->x0);
- pdf_array_push_real(ctx, arr, rect->y0);
- pdf_array_push_real(ctx, arr, rect->x1);
- pdf_array_push_real(ctx, arr, rect->y1);
+ pdf_array_push_real(ctx, arr, rect.x0);
+ pdf_array_push_real(ctx, arr, rect.y0);
+ pdf_array_push_real(ctx, arr, rect.x1);
+ pdf_array_push_real(ctx, arr, rect.y1);
}
fz_catch(ctx)
{
@@ -829,17 +829,17 @@ pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, const fz_rect *rect)
return arr;
}
-pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, const fz_matrix *mtx)
+pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, fz_matrix mtx)
{
pdf_obj *arr = pdf_new_array(ctx, doc, 6);
fz_try(ctx)
{
- pdf_array_push_real(ctx, arr, mtx->a);
- pdf_array_push_real(ctx, arr, mtx->b);
- pdf_array_push_real(ctx, arr, mtx->c);
- pdf_array_push_real(ctx, arr, mtx->d);
- pdf_array_push_real(ctx, arr, mtx->e);
- pdf_array_push_real(ctx, arr, mtx->f);
+ pdf_array_push_real(ctx, arr, mtx.a);
+ pdf_array_push_real(ctx, arr, mtx.b);
+ pdf_array_push_real(ctx, arr, mtx.c);
+ pdf_array_push_real(ctx, arr, mtx.d);
+ pdf_array_push_real(ctx, arr, mtx.e);
+ pdf_array_push_real(ctx, arr, mtx.f);
}
fz_catch(ctx)
{
@@ -2198,12 +2198,12 @@ void pdf_dict_put_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, cons
pdf_dict_put_drop(ctx, dict, key, pdf_new_text_string(ctx, x));
}
-void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_rect *x)
+void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_rect x)
{
pdf_dict_put_drop(ctx, dict, key, pdf_new_rect(ctx, NULL, x));
}
-void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_matrix *x)
+void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_matrix x)
{
pdf_dict_put_drop(ctx, dict, key, pdf_new_matrix(ctx, NULL, x));
}
diff --git a/source/pdf/pdf-op-filter.c b/source/pdf/pdf-op-filter.c
index cea60db5..10138cda 100644
--- a/source/pdf/pdf-op-filter.c
+++ b/source/pdf/pdf-op-filter.c
@@ -176,7 +176,7 @@ static void filter_flush(fz_context *ctx, pdf_filter_processor *p, int flush)
gstate->pending.ctm.e,
gstate->pending.ctm.f);
- fz_concat(&gstate->sent.ctm, &current, &gstate->pending.ctm);
+ gstate->sent.ctm = fz_concat(current, gstate->pending.ctm);
gstate->pending.ctm.a = 1;
gstate->pending.ctm.b = 0;
gstate->pending.ctm.c = 0;
@@ -450,9 +450,9 @@ filter_show_space(fz_context *ctx, pdf_filter_processor *p, float tadj)
pdf_font_desc *fontdesc = gstate->pending.text.font;
if (fontdesc->wmode == 0)
- fz_pre_translate(&p->tos.tm, tadj * gstate->pending.text.scale, 0);
+ p->tos.tm = fz_pre_translate(p->tos.tm, tadj * gstate->pending.text.scale, 0);
else
- fz_pre_translate(&p->tos.tm, 0, tadj);
+ p->tos.tm = fz_pre_translate(p->tos.tm, 0, tadj);
}
/* Process a string (from buf, of length len), from position *pos onwards.
@@ -633,12 +633,12 @@ filter_show_text(fz_context *ctx, pdf_filter_processor *p, pdf_obj *text)
if (fontdesc->wmode == 0)
{
skip.x += tadj;
- fz_pre_translate(&p->tos.tm, tadj * p->gstate->pending.text.scale, 0);
+ p->tos.tm = fz_pre_translate(p->tos.tm, tadj * p->gstate->pending.text.scale, 0);
}
else
{
skip.y += tadj;
- fz_pre_translate(&p->tos.tm, 0, tadj);
+ p->tos.tm = fz_pre_translate(p->tos.tm, 0, tadj);
}
}
@@ -822,7 +822,7 @@ pdf_filter_cm(fz_context *ctx, pdf_processor *proc, float a, float b, float c, f
{
pdf_filter_processor *p = (pdf_filter_processor*)proc;
filter_gstate *gstate = gstate_to_update(ctx, p);
- fz_matrix old, ctm;
+ fz_matrix ctm;
/* If we're being given an identity matrix, don't bother sending it */
if (a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0)
@@ -835,8 +835,7 @@ pdf_filter_cm(fz_context *ctx, pdf_processor *proc, float a, float b, float c, f
ctm.e = e;
ctm.f = f;
- old = gstate->pending.ctm;
- fz_concat(&gstate->pending.ctm, &ctm, &old);
+ gstate->pending.ctm = fz_concat(ctm, gstate->pending.ctm);
}
/* path construction */
@@ -1038,9 +1037,7 @@ pdf_filter_ET(fz_context *ctx, pdf_processor *proc)
p->chain->op_ET(ctx, p->chain);
if (p->after_text)
{
- fz_matrix ctm;
-
- fz_concat(&ctm, &p->gstate->sent.ctm, &p->gstate->pending.ctm);
+ fz_matrix ctm = fz_concat(p->gstate->sent.ctm, p->gstate->pending.ctm);
if (p->chain->op_q)
p->chain->op_q(ctx, p->chain);
p->after_text(ctx, p->opaque, p->doc, p->chain, &ctm);
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 8ef1943a..61729f0c 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -116,8 +116,8 @@ begin_softmask(fz_context *ctx, pdf_run_processor *pr, softmask_save *save)
save->ctm = gstate->softmask_ctm;
save_ctm = gstate->ctm;
- pdf_xobject_bbox(ctx, softmask, &mask_bbox);
- pdf_xobject_matrix(ctx, softmask, &mask_matrix);
+ mask_bbox = pdf_xobject_bbox(ctx, softmask);
+ mask_matrix = pdf_xobject_matrix(ctx, softmask);
pdf_tos_save(ctx, &pr->tos, tos_save);
@@ -125,8 +125,8 @@ begin_softmask(fz_context *ctx, pdf_run_processor *pr, softmask_save *save)
mask_bbox = fz_infinite_rect;
else
{
- fz_transform_rect(&mask_bbox, &mask_matrix);
- fz_transform_rect(&mask_bbox, &gstate->softmask_ctm);
+ mask_bbox = fz_transform_rect(mask_bbox, mask_matrix);
+ mask_bbox = fz_transform_rect(mask_bbox, gstate->softmask_ctm);
}
gstate->softmask = NULL;
gstate->softmask_resources = NULL;
@@ -208,7 +208,7 @@ pdf_show_shade(fz_context *ctx, pdf_run_processor *pr, fz_shade *shd)
if (pr->super.hidden)
return;
- fz_bound_shade(ctx, shd, &gstate->ctm, &bbox);
+ bbox = fz_bound_shade(ctx, shd, gstate->ctm);
gstate = pdf_begin_group(ctx, pr, &bbox, &softmask);
@@ -389,8 +389,8 @@ pdf_show_pattern(fz_context *ctx, pdf_run_processor *pr, pdf_pattern *pat, pdf_g
gstate->softmask = NULL;
}
- fz_concat(&ptm, &pat->matrix, &pat_gstate->ctm);
- fz_invert_matrix(&invptm, &ptm);
+ ptm = fz_concat(pat->matrix, pat_gstate->ctm);
+ invptm = fz_invert_matrix(ptm);
/* The parent_ctm is amended with our pattern matrix */
gparent_save = pr->gparent;
@@ -403,8 +403,7 @@ pdf_show_pattern(fz_context *ctx, pdf_run_processor *pr, pdf_pattern *pat, pdf_g
/* patterns are painted using the parent_ctm. area = bbox of
* shape to be filled in device space. Map it back to pattern
* space. */
- local_area = *area;
- fz_transform_rect(&local_area, &invptm);
+ local_area = fz_transform_rect(*area, invptm);
fx0 = (local_area.x0 - pat->bbox.x0) / pat->xstep;
fy0 = (local_area.y0 - pat->bbox.y0) / pat->ystep;
@@ -474,8 +473,7 @@ pdf_show_pattern(fz_context *ctx, pdf_run_processor *pr, pdf_pattern *pat, pdf_g
{
for (x = x0; x < x1; x++)
{
- gstate->ctm = ptm;
- fz_pre_translate(&gstate->ctm, x * pat->xstep, y * pat->ystep);
+ gstate->ctm = fz_pre_translate(ptm, x * pat->xstep, y * pat->ystep);
pdf_gsave(ctx, pr);
fz_try(ctx)
pdf_process_contents(ctx, (pdf_processor*)pr, pat->document, pat->resources, pat->contents, NULL);
@@ -547,11 +545,9 @@ pdf_show_image(fz_context *ctx, pdf_run_processor *pr, fz_image *image)
return;
/* PDF has images bottom-up, so flip them right side up here */
- image_ctm = gstate->ctm;
- fz_pre_scale(fz_pre_translate(&image_ctm, 0, 1), 1, -1);
+ image_ctm = fz_pre_scale(fz_pre_translate(gstate->ctm, 0, 1), 1, -1);
- bbox = fz_unit_rect;
- fz_transform_rect(&bbox, &image_ctm);
+ bbox = fz_transform_rect(fz_unit_rect, image_ctm);
if (image->mask && gstate->blendmode)
{
@@ -631,7 +627,7 @@ pdf_show_path(fz_context *ctx, pdf_run_processor *pr, int doclose, int dofill, i
if (doclose)
fz_closepath(ctx, path);
- fz_bound_path(ctx, path, (dostroke ? gstate->stroke_state : NULL), &gstate->ctm, &bbox);
+ bbox = fz_bound_path(ctx, path, (dostroke ? gstate->stroke_state : NULL), gstate->ctm);
if (pr->super.hidden)
dostroke = dofill = 0;
@@ -778,11 +774,9 @@ pdf_flush_text(fz_context *ctx, pdf_run_processor *pr)
fz_try(ctx)
{
- fz_rect tb = pr->tos.text_bbox;
-
- fz_transform_rect(&tb, &gstate->ctm);
+ fz_rect tb = fz_transform_rect(pr->tos.text_bbox, gstate->ctm);
if (dostroke)
- fz_adjust_rect_for_stroke(ctx, &tb, gstate->stroke_state, &gstate->ctm);
+ tb = fz_adjust_rect_for_stroke(ctx, tb, gstate->stroke_state, gstate->ctm);
/* Don't bother sending a text group with nothing in it */
if (!text->head)
@@ -925,8 +919,7 @@ pdf_show_char(fz_context *ctx, pdf_run_processor *pr, int cid)
/* Render the glyph stream direct here (only happens for
* type3 glyphs that seem to inherit current graphics
* attributes, or type 3 glyphs within type3 glyphs). */
- fz_matrix composed;
- fz_concat(&composed, &trm, &gstate->ctm);
+ fz_matrix composed = fz_concat(trm, gstate->ctm);
fz_render_t3_glyph_direct(ctx, pr->dev, fontdesc->font, gid, &composed, gstate, pr->nested_depth, pr->default_cs);
/* Render text invisibly so that it can still be extracted. */
pr->tos.text_mode = 3;
@@ -947,11 +940,11 @@ pdf_show_char(fz_context *ctx, pdf_run_processor *pr, int cid)
}
/* add glyph to textobject */
- fz_show_glyph(ctx, pr->tos.text, fontdesc->font, &trm, gid, ucsbuf[0], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, pr->tos.text, fontdesc->font, trm, gid, ucsbuf[0], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
/* add filler glyphs for one-to-many unicode mapping */
for (i = 1; i < ucslen; i++)
- fz_show_glyph(ctx, pr->tos.text, fontdesc->font, &trm, -1, ucsbuf[i], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, pr->tos.text, fontdesc->font, trm, -1, ucsbuf[i], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
pdf_tos_move_after_char(ctx, &pr->tos);
}
@@ -963,9 +956,9 @@ pdf_show_space(fz_context *ctx, pdf_run_processor *pr, float tadj)
pdf_font_desc *fontdesc = gstate->text.font;
if (fontdesc->wmode == 0)
- fz_pre_translate(&pr->tos.tm, tadj * gstate->text.scale, 0);
+ pr->tos.tm = fz_pre_translate(pr->tos.tm, tadj * gstate->text.scale, 0);
else
- fz_pre_translate(&pr->tos.tm, 0, tadj);
+ pr->tos.tm = fz_pre_translate(pr->tos.tm, 0, tadj);
}
static void
@@ -1232,13 +1225,13 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_obj *xobj, pdf_obj
gstate = pr->gstate + pr->gtop;
- pdf_xobject_bbox(ctx, xobj, &xobj_bbox);
- pdf_xobject_matrix(ctx, xobj, &xobj_matrix);
+ xobj_bbox = pdf_xobject_bbox(ctx, xobj);
+ xobj_matrix = pdf_xobject_matrix(ctx, xobj);
transparency = pdf_xobject_transparency(ctx, xobj);
/* apply xobject's transform matrix */
- fz_concat(&local_transform, &xobj_matrix, &local_transform);
- fz_concat(&gstate->ctm, &local_transform, &gstate->ctm);
+ local_transform = fz_concat(xobj_matrix, local_transform);
+ gstate->ctm = fz_concat(local_transform, gstate->ctm);
/* The gparent is updated with the modified ctm */
gparent_save_ctm = pr->gstate[pr->gparent].ctm;
@@ -1247,11 +1240,9 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_obj *xobj, pdf_obj
/* apply soft mask, create transparency group and reset state */
if (transparency)
{
- fz_rect bbox;
int isolated = pdf_xobject_isolated(ctx, xobj);
- bbox = xobj_bbox;
- fz_transform_rect(&bbox, &gstate->ctm);
+ fz_rect bbox = fz_transform_rect(xobj_bbox, gstate->ctm);
/* Remember that we tried to call begin_softmask. Even
* if it throws an error, we must call end_softmask. */
@@ -1582,7 +1573,7 @@ static void pdf_run_cm(fz_context *ctx, pdf_processor *proc, float a, float b, f
m.d = d;
m.e = e;
m.f = f;
- fz_concat(&gstate->ctm, &m, &gstate->ctm);
+ gstate->ctm = fz_concat(m, gstate->ctm);
}
/* path construction */
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index 8300fdb3..f8131b2c 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -623,13 +623,13 @@ pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition
return transition;
}
-fz_rect *
-pdf_bound_page(fz_context *ctx, pdf_page *page, fz_rect *mediabox)
+fz_rect
+pdf_bound_page(fz_context *ctx, pdf_page *page)
{
fz_matrix page_ctm;
- pdf_page_transform(ctx, page, mediabox, &page_ctm);
- fz_transform_rect(mediabox, &page_ctm);
- return mediabox;
+ fz_rect mediabox;
+ pdf_page_transform(ctx, page, &mediabox, &page_ctm);
+ return fz_transform_rect(mediabox, page_ctm);
}
fz_link *
@@ -661,7 +661,6 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
{
pdf_obj *obj;
fz_rect mediabox, cropbox, realbox, pagebox;
- fz_matrix tmp;
float userunit = 1;
int rotate;
@@ -672,8 +671,8 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
if (pdf_is_real(ctx, obj))
userunit = pdf_to_real(ctx, obj);
- pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(MediaBox)), &mediabox);
- if (fz_is_empty_rect(&mediabox))
+ mediabox = pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(MediaBox)));
+ if (fz_is_empty_rect(mediabox))
{
mediabox.x0 = 0;
mediabox.y0 = 0;
@@ -681,9 +680,9 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
mediabox.y1 = 792;
}
- pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(CropBox)), &cropbox);
- if (!fz_is_empty_rect(&cropbox))
- fz_intersect_rect(&mediabox, &cropbox);
+ cropbox = pdf_to_rect(ctx, pdf_lookup_inherited_page_item(ctx, pageobj, PDF_NAME(CropBox)));
+ if (!fz_is_empty_rect(cropbox))
+ mediabox = fz_intersect_rect(mediabox, cropbox);
page_mediabox->x0 = fz_min(mediabox.x0, mediabox.x1);
page_mediabox->y0 = fz_min(mediabox.y0, mediabox.y1);
@@ -708,16 +707,14 @@ pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *page_mediabox
* to PDF user space (arbitrary page origin, y ascending, UserUnit dpi). */
/* Make left-handed and scale by UserUnit */
- fz_scale(page_ctm, userunit, -userunit);
+ *page_ctm = fz_scale(userunit, -userunit);
/* Rotate */
- fz_pre_rotate(page_ctm, -rotate);
+ *page_ctm = fz_pre_rotate(*page_ctm, -rotate);
/* Translate page origin to 0,0 */
- realbox = *page_mediabox;
- fz_transform_rect(&realbox, page_ctm);
- fz_translate(&tmp, -realbox.x0, -realbox.y0);
- fz_concat(page_ctm, page_ctm, &tmp);
+ realbox = fz_transform_rect(*page_mediabox, *page_ctm);
+ *page_ctm = fz_concat(*page_ctm, fz_translate(-realbox.x0, -realbox.y0));
}
void
@@ -1166,7 +1163,7 @@ pdf_delete_page_range(fz_context *ctx, pdf_document *doc, int start, int end)
}
pdf_obj *
-pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int rotate, pdf_obj *resources, fz_buffer *contents)
+pdf_add_page(fz_context *ctx, pdf_document *doc, fz_rect mediabox, int rotate, pdf_obj *resources, fz_buffer *contents)
{
pdf_obj *page_obj = pdf_new_dict(ctx, doc, 5);
fz_try(ctx)
diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c
index fb1cc595..501c5626 100644
--- a/source/pdf/pdf-parse.c
+++ b/source/pdf/pdf-parse.c
@@ -3,40 +3,42 @@
#include <string.h>
-fz_rect *
-pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *r)
+fz_rect
+pdf_to_rect(fz_context *ctx, pdf_obj *array)
{
if (!pdf_is_array(ctx, array))
- *r = fz_empty_rect;
+ return fz_empty_rect;
else
{
float a = pdf_array_get_real(ctx, array, 0);
float b = pdf_array_get_real(ctx, array, 1);
float c = pdf_array_get_real(ctx, array, 2);
float d = pdf_array_get_real(ctx, array, 3);
- r->x0 = fz_min(a, c);
- r->y0 = fz_min(b, d);
- r->x1 = fz_max(a, c);
- r->y1 = fz_max(b, d);
+ fz_rect r;
+ r.x0 = fz_min(a, c);
+ r.y0 = fz_min(b, d);
+ r.x1 = fz_max(a, c);
+ r.y1 = fz_max(b, d);
+ return r;
}
- return r;
}
-fz_matrix *
-pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *m)
+fz_matrix
+pdf_to_matrix(fz_context *ctx, pdf_obj *array)
{
if (!pdf_is_array(ctx, array))
- *m = fz_identity;
+ return fz_identity;
else
{
- m->a = pdf_array_get_real(ctx, array, 0);
- m->b = pdf_array_get_real(ctx, array, 1);
- m->c = pdf_array_get_real(ctx, array, 2);
- m->d = pdf_array_get_real(ctx, array, 3);
- m->e = pdf_array_get_real(ctx, array, 4);
- m->f = pdf_array_get_real(ctx, array, 5);
+ fz_matrix m;
+ m.a = pdf_array_get_real(ctx, array, 0);
+ m.b = pdf_array_get_real(ctx, array, 1);
+ m.c = pdf_array_get_real(ctx, array, 2);
+ m.d = pdf_array_get_real(ctx, array, 3);
+ m.e = pdf_array_get_real(ctx, array, 4);
+ m.f = pdf_array_get_real(ctx, array, 5);
+ return m;
}
- return m;
}
static int
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index f1f94352..5574a565 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -58,13 +58,10 @@ pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
pat->ystep = pdf_dict_get_real(ctx, dict, PDF_NAME(YStep));
obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
- pdf_to_rect(ctx, obj, &pat->bbox);
+ pat->bbox = pdf_to_rect(ctx, obj);
obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
- if (obj)
- pdf_to_matrix(ctx, obj, &pat->matrix);
- else
- pat->matrix = fz_identity;
+ pat->matrix = pdf_to_matrix(ctx, obj);
pat->resources = pdf_dict_get(ctx, dict, PDF_NAME(Resources));
if (pat->resources)
diff --git a/source/pdf/pdf-run.c b/source/pdf/pdf-run.c
index 2cc56edb..15339373 100644
--- a/source/pdf/pdf-run.c
+++ b/source/pdf/pdf-run.c
@@ -16,7 +16,7 @@ pdf_run_annot_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf
fz_set_default_colorspaces(ctx, dev, default_cs);
pdf_page_transform(ctx, page, &mediabox, &page_ctm);
- fz_concat(&local_ctm, &page_ctm, ctm);
+ local_ctm = fz_concat(page_ctm, *ctm);
fz_try(ctx)
{
@@ -54,12 +54,12 @@ pdf_run_page_contents_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *p
fz_try(ctx)
{
pdf_page_transform(ctx, page, &mediabox, &page_ctm);
- fz_concat(&local_ctm, &page_ctm, ctm);
+ local_ctm = fz_concat(page_ctm, *ctm);
+ mediabox = fz_transform_rect(mediabox, local_ctm);
resources = pdf_page_resources(ctx, page);
contents = pdf_page_contents(ctx, page);
-
if (page->transparency)
{
pdf_obj *group = pdf_page_group(ctx, page);
@@ -78,7 +78,7 @@ pdf_run_page_contents_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *p
else
colorspace = fz_keep_colorspace(ctx, fz_default_output_intent(ctx, default_cs));
- fz_begin_group(ctx, dev, fz_transform_rect(&mediabox, &local_ctm), colorspace, 1, 0, 0, 1);
+ fz_begin_group(ctx, dev, &mediabox, colorspace, 1, 0, 0, 1);
fz_drop_colorspace(ctx, colorspace);
colorspace = NULL;
}
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index 5476c8b8..d34e8440 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -54,7 +54,6 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
pdf_obj *obj;
float x0, y0, x1, y1;
float fv[2];
- fz_matrix matrix;
int xx, yy;
float *p;
int n = fz_colorspace_n(ctx, shade->colorspace);
@@ -70,12 +69,7 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
y1 = pdf_array_get_real(ctx, obj, 3);
}
- obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
- if (obj)
- pdf_to_matrix(ctx, obj, &matrix);
- else
- matrix = fz_identity;
- shade->u.f.matrix = matrix;
+ shade->u.f.matrix = pdf_to_matrix(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Matrix)));
shade->u.f.xdivs = FUNSEGS;
shade->u.f.ydivs = FUNSEGS;
shade->u.f.fn_vals = fz_malloc(ctx, (FUNSEGS+1)*(FUNSEGS+1)*n*sizeof(float));
@@ -346,7 +340,7 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f
obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
if (pdf_is_array(ctx, obj))
- pdf_to_rect(ctx, obj, &shade->bbox);
+ shade->bbox = pdf_to_rect(ctx, obj);
obj = pdf_dict_get(ctx, dict, PDF_NAME(Function));
if (pdf_is_dict(ctx, obj))
@@ -449,10 +443,7 @@ pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
if (pdf_dict_get(ctx, dict, PDF_NAME(PatternType)))
{
obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
- if (obj)
- pdf_to_matrix(ctx, obj, &mat);
- else
- mat = fz_identity;
+ mat = pdf_to_matrix(ctx, obj);
obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState));
if (obj)
diff --git a/source/pdf/pdf-signature.c b/source/pdf/pdf-signature.c
index 6ccb7ab2..cfb623d9 100644
--- a/source/pdf/pdf-signature.c
+++ b/source/pdf/pdf-signature.c
@@ -71,10 +71,10 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget,
pdf_signature_set_value(ctx, doc, wobj, signer);
- pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME(Rect)), &rect);
+ rect = pdf_to_rect(ctx, pdf_dict_get(ctx, wobj, PDF_NAME(Rect)));
/* Create an appearance stream only if the signature is intended to be visible */
- if (!fz_is_empty_rect(&rect))
+ if (!fz_is_empty_rect(rect))
{
dn = signer->designated_name(signer);
fzbuf = fz_new_buffer(ctx, 256);
diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c
index cd7693cf..9d32797e 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -56,12 +56,12 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
fontdesc = pdf_new_font_desc(ctx);
obj = pdf_dict_get(ctx, dict, PDF_NAME(FontMatrix));
- pdf_to_matrix(ctx, obj, &matrix);
+ matrix = pdf_to_matrix(ctx, obj);
obj = pdf_dict_get(ctx, dict, PDF_NAME(FontBBox));
- fz_transform_rect(pdf_to_rect(ctx, obj, &bbox), &matrix);
+ bbox = fz_transform_rect(pdf_to_rect(ctx, obj), matrix);
- font = fz_new_type3_font(ctx, buf, &matrix);
+ font = fz_new_type3_font(ctx, buf, matrix);
fontdesc->font = font;
fontdesc->size += sizeof(fz_font) + 256 * (sizeof(fz_buffer*) + sizeof(float));
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 0a66365e..63863104 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -3304,7 +3304,7 @@ pdf_writer_end_page(fz_context *ctx, fz_document_writer *wri_, fz_device *dev)
fz_try(ctx)
{
fz_close_device(ctx, dev);
- obj = pdf_add_page(ctx, wri->pdf, &wri->mediabox, 0, wri->resources, wri->contents);
+ obj = pdf_add_page(ctx, wri->pdf, wri->mediabox, 0, wri->resources, wri->contents);
pdf_insert_page(ctx, wri->pdf, -1, obj);
}
fz_always(ctx)
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index 871f001a..2cfe1f8f 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -7,16 +7,16 @@ pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj)
return pdf_dict_get(ctx, xobj, PDF_NAME(Resources));
}
-fz_rect *
-pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj, fz_rect *bbox)
+fz_rect
+pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj)
{
- return pdf_to_rect(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(BBox)), bbox);
+ return pdf_to_rect(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(BBox)));
}
-fz_matrix *
-pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj, fz_matrix *matrix)
+fz_matrix
+pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj)
{
- return pdf_to_matrix(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(Matrix)), matrix);
+ return pdf_to_matrix(ctx, pdf_dict_get(ctx, xobj, PDF_NAME(Matrix)));
}
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj)
@@ -65,7 +65,7 @@ pdf_xobject_colorspace(fz_context *ctx, pdf_obj *xobj)
}
pdf_obj *
-pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const fz_matrix *mat, pdf_obj *res, fz_buffer *contents)
+pdf_new_xobject(fz_context *ctx, pdf_document *doc, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *contents)
{
pdf_obj *ind = NULL;
pdf_obj *form = pdf_new_dict(ctx, doc, 5);
@@ -74,8 +74,7 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
pdf_dict_put(ctx, form, PDF_NAME(Type), PDF_NAME(XObject));
pdf_dict_put(ctx, form, PDF_NAME(Subtype), PDF_NAME(Form));
pdf_dict_put_rect(ctx, form, PDF_NAME(BBox), bbox);
- if (mat)
- pdf_dict_put_matrix(ctx, form, PDF_NAME(Matrix), mat);
+ pdf_dict_put_matrix(ctx, form, PDF_NAME(Matrix), matrix);
if (res)
pdf_dict_put(ctx, form, PDF_NAME(Resources), res);
ind = pdf_add_stream(ctx, doc, contents, form, 0);
@@ -88,13 +87,10 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
}
void
-pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *form, const fz_rect *bbox, const fz_matrix *mat, pdf_obj *res, fz_buffer *contents)
+pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *form, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *contents)
{
pdf_dict_put_rect(ctx, form, PDF_NAME(BBox), bbox);
- if (mat)
- pdf_dict_put_matrix(ctx, form, PDF_NAME(Matrix), mat);
- else
- pdf_dict_del(ctx, form, PDF_NAME(Matrix));
+ pdf_dict_put_matrix(ctx, form, PDF_NAME(Matrix), matrix);
if (res)
pdf_dict_put(ctx, form, PDF_NAME(Resources), res);
else
diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c
index a651c9ae..89ff148c 100644
--- a/source/svg/svg-doc.c
+++ b/source/svg/svg-doc.c
@@ -23,19 +23,15 @@ svg_count_pages(fz_context *ctx, fz_document *doc_)
return 1;
}
-static fz_rect *
-svg_bound_page(fz_context *ctx, fz_page *page_, fz_rect *rect)
+static fz_rect
+svg_bound_page(fz_context *ctx, fz_page *page_)
{
svg_page *page = (svg_page*)page_;
svg_document *doc = page->doc;
svg_parse_document_bounds(ctx, doc, fz_xml_root(doc->xml));
- rect->x0 = 0;
- rect->y0 = 0;
- rect->x1 = doc->width;
- rect->y1 = doc->height;
- return rect;
+ return fz_make_rect(0, 0, doc->width, doc->height);
}
static void
diff --git a/source/svg/svg-parse.c b/source/svg/svg-parse.c
index e5bf93a2..5c7fc33a 100644
--- a/source/svg/svg-parse.c
+++ b/source/svg/svg-parse.c
@@ -214,7 +214,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr
m.e = args[4];
m.f = args[5];
- fz_concat(transform, transform, &m);
+ *transform = fz_concat(*transform, m);
}
else if (!strcmp(keyword, "translate"))
@@ -222,15 +222,15 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr
if (nargs != 2)
fz_throw(ctx, FZ_ERROR_SYNTAX, "wrong number of arguments to translate(): %d", nargs);
- fz_pre_translate(transform, args[0], args[1]);
+ *transform = fz_pre_translate(*transform, args[0], args[1]);
}
else if (!strcmp(keyword, "scale"))
{
if (nargs == 1)
- fz_pre_scale(transform, args[0], args[0]);
+ *transform = fz_pre_scale(*transform, args[0], args[0]);
else if (nargs == 2)
- fz_pre_scale(transform, args[0], args[1]);
+ *transform = fz_pre_scale(*transform, args[0], args[1]);
else
fz_throw(ctx, FZ_ERROR_SYNTAX, "wrong number of arguments to scale(): %d", nargs);
}
@@ -239,7 +239,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr
{
if (nargs != 1)
fz_throw(ctx, FZ_ERROR_SYNTAX, "wrong number of arguments to rotate(): %d", nargs);
- fz_pre_rotate(transform, args[0]);
+ *transform = fz_pre_rotate(*transform, args[0]);
}
else if (!strcmp(keyword, "skewX"))
@@ -256,7 +256,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr
m.e = 0;
m.f = 0;
- fz_concat(transform, transform, &m);
+ *transform = fz_concat(*transform, m);
}
else if (!strcmp(keyword, "skewY"))
@@ -273,7 +273,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr
m.e = 0;
m.f = 0;
- fz_concat(transform, transform, &m);
+ *transform = fz_concat(*transform, m);
}
else
diff --git a/source/svg/svg-run.c b/source/svg/svg-run.c
index 19e49836..a3e6193f 100644
--- a/source/svg/svg-run.c
+++ b/source/svg/svg-run.c
@@ -330,7 +330,7 @@ svg_add_arc_segment(fz_context *ctx, fz_path *path, const fz_matrix *mtx, float
{
for (t = th0 + d; t < th1 - d/2; t += d)
{
- fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
+ p = fz_transform_point_xy(cosf(t), sinf(t), *mtx);
fz_lineto(ctx, path, p.x, p.y);
}
}
@@ -339,7 +339,7 @@ svg_add_arc_segment(fz_context *ctx, fz_path *path, const fz_matrix *mtx, float
th0 += FZ_PI * 2;
for (t = th0 - d; t > th1 + d/2; t -= d)
{
- fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
+ p = fz_transform_point_xy(cosf(t), sinf(t), *mtx);
fz_lineto(ctx, path, p.x, p.y);
}
}
@@ -390,8 +390,8 @@ svg_add_arc(fz_context *ctx, fz_path *path,
else
sign = -1;
- fz_rotate(&rotmat, rotation_angle);
- fz_rotate(&revmat, -rotation_angle);
+ rotmat = fz_rotate(rotation_angle);
+ revmat = fz_rotate(-rotation_angle);
/* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes */
/* Conversion from endpoint to center parameterization */
@@ -408,7 +408,7 @@ svg_add_arc(fz_context *ctx, fz_path *path,
/* F.6.5.1 */
pt.x = (x1 - x2) / 2;
pt.y = (y1 - y2) / 2;
- fz_transform_vector(&pt, &revmat);
+ pt = fz_transform_vector(pt, revmat);
x1t = pt.x;
y1t = pt.y;
@@ -434,7 +434,7 @@ svg_add_arc(fz_context *ctx, fz_path *path,
/* F.6.5.3 */
pt.x = cxt;
pt.y = cyt;
- fz_transform_vector(&pt, &rotmat);
+ pt = fz_transform_vector(pt, rotmat);
cx = pt.x + (x1 + x2) / 2;
cy = pt.y + (y1 + y2) / 2;
@@ -457,7 +457,7 @@ svg_add_arc(fz_context *ctx, fz_path *path,
dth -= ((FZ_PI / 180) * 360);
}
- fz_pre_scale(fz_pre_rotate(fz_translate(&mtx, cx, cy), rotation_angle), rx, ry);
+ mtx = fz_pre_scale(fz_pre_rotate(fz_translate(cx, cy), rotation_angle), rx, ry);
svg_add_arc_segment(ctx, path, &mtx, th1, th1 + dth, is_clockwise);
fz_lineto(ctx, path, point_x, point_y);
@@ -1037,7 +1037,7 @@ svg_run_use(fz_context *ctx, fz_device *dev, svg_document *doc, fz_xml *root, co
if (x_att) x = svg_parse_length(x_att, local_state.viewbox_w, local_state.fontsize);
if (y_att) y = svg_parse_length(y_att, local_state.viewbox_h, local_state.fontsize);
- fz_pre_translate(&local_state.transform, x, y);
+ local_state.transform = fz_pre_translate(local_state.transform, x, y);
if (xlink_href_att && xlink_href_att[0] == '#')
{
diff --git a/source/tools/muconvert.c b/source/tools/muconvert.c
index e2a51c6e..ed4b4615 100644
--- a/source/tools/muconvert.c
+++ b/source/tools/muconvert.c
@@ -75,7 +75,7 @@ static void runpage(int number)
fz_try(ctx)
{
- fz_bound_page(ctx, page, &mediabox);
+ mediabox = fz_bound_page(ctx, page);
dev = fz_begin_page(ctx, out, &mediabox);
fz_run_page(ctx, page, dev, &fz_identity, NULL);
}
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 0649bae0..2e1e759d 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -517,9 +517,9 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_try(ctx)
{
if (list)
- fz_bound_display_list(ctx, list, &mediabox);
+ mediabox = fz_bound_display_list(ctx, list);
else
- fz_bound_page(ctx, page, &mediabox);
+ mediabox = fz_bound_page(ctx, page);
}
fz_catch(ctx)
{
@@ -564,7 +564,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_matrix ctm;
zoom = resolution / 72;
- fz_pre_scale(fz_rotate(&ctm, rotation), zoom, zoom);
+ ctm = fz_pre_scale(fz_rotate(rotation), zoom, zoom);
fz_var(text);
@@ -573,7 +573,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_stext_options stext_options;
stext_options.flags = (output_format == OUT_HTML || output_format == OUT_XHTML) ? FZ_STEXT_PRESERVE_IMAGES : 0;
- text = fz_new_stext_page(ctx, &mediabox);
+ text = fz_new_stext_page(ctx, mediabox);
dev = fz_new_stext_device(ctx, text, &stext_options);
if (lowmemory)
fz_enable_device_hints(ctx, dev, FZ_NO_CACHE);
@@ -638,7 +638,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_drop_device(ctx, dev);
dev = NULL;
- page_obj = pdf_add_page(ctx, pdfout, &mediabox, rotation, resources, contents);
+ page_obj = pdf_add_page(ctx, pdfout, mediabox, rotation, resources, contents);
pdf_insert_page(ctx, pdfout, -1, page_obj);
pdf_drop_obj(ctx, page_obj);
}
@@ -669,9 +669,8 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_var(out);
zoom = resolution / 72;
- fz_pre_rotate(fz_scale(&ctm, zoom, zoom), rotation);
- tbounds = mediabox;
- fz_transform_rect(&tbounds, &ctm);
+ ctm = fz_pre_rotate(fz_scale(zoom, zoom), rotation);
+ tbounds = fz_transform_rect(mediabox, ctm);
fz_try(ctx)
{
@@ -721,15 +720,15 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_var(bit);
zoom = resolution / 72;
- fz_pre_scale(fz_rotate(&ctm, rotation), zoom, zoom);
+ ctm = fz_pre_scale(fz_rotate(rotation), zoom, zoom);
if (output_format == OUT_TGA)
{
- fz_pre_scale(fz_pre_translate(&ctm, 0, -height), 1, -1);
+ ctm = fz_pre_scale(fz_pre_translate(ctm, 0, -height), 1, -1);
}
- tbounds = mediabox;
- fz_round_rect(&ibounds, fz_transform_rect(&tbounds, &ctm));
+ tbounds = fz_transform_rect(mediabox, ctm);
+ ibounds = fz_round_rect(tbounds);
/* Make local copies of our width/height */
w = width;
@@ -776,13 +775,12 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
else
scaley = scalex;
}
- fz_scale(&scale_mat, scalex, scaley);
- fz_concat(&ctm, &ctm, &scale_mat);
- tbounds = mediabox;
- fz_transform_rect(&tbounds, &ctm);
+ scale_mat = fz_scale(scalex, scaley);
+ ctm = fz_concat(ctm, scale_mat);
+ tbounds = fz_transform_rect(mediabox, ctm);
}
- fz_round_rect(&ibounds, &tbounds);
- fz_rect_from_irect(&tbounds, &ibounds);
+ ibounds = fz_round_rect(tbounds);
+ tbounds = fz_rect_from_irect(ibounds);
fz_try(ctx)
{
@@ -812,7 +810,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
workers[band].tbounds = tbounds;
memset(&workers[band].cookie, 0, sizeof(fz_cookie));
workers[band].list = list;
- workers[band].pix = fz_new_pixmap_with_bbox(ctx, colorspace, &band_ibounds, seps, alpha);
+ workers[band].pix = fz_new_pixmap_with_bbox(ctx, colorspace, band_ibounds, seps, alpha);
fz_set_pixmap_resolution(ctx, workers[band].pix, resolution, resolution);
#ifndef DISABLE_MUTHREADS
DEBUG_THREADS(("Worker %d, Pre-triggering band %d\n", band, band));
@@ -824,7 +822,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
}
else
{
- pix = fz_new_pixmap_with_bbox(ctx, colorspace, &band_ibounds, seps, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, colorspace, band_ibounds, seps, alpha);
fz_set_pixmap_resolution(ctx, pix, resolution, resolution);
}
@@ -1030,7 +1028,6 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
fz_device *dev = NULL;
int start;
fz_cookie cookie = { 0 };
- fz_rect bounds;
fz_separations *seps = NULL;
fz_var(list);
@@ -1082,7 +1079,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
{
fz_try(ctx)
{
- list = fz_new_display_list(ctx, fz_bound_page(ctx, page, &bounds));
+ list = fz_new_display_list(ctx, fz_bound_page(ctx, page));
dev = fz_new_list_device(ctx, list);
if (lowmemory)
fz_enable_device_hints(ctx, dev, FZ_NO_CACHE);
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 10d76e8b..a4e88ea2 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1829,7 +1829,7 @@ static void ffi_Page_bound(js_State *J)
fz_rect bounds;
fz_try(ctx)
- fz_bound_page(ctx, page, &bounds);
+ bounds = fz_bound_page(ctx, page);
fz_catch(ctx)
rethrow(J);
@@ -2017,7 +2017,7 @@ static void ffi_Annotation_bound(js_State *J)
fz_rect bounds;
fz_try(ctx)
- fz_bound_annot(ctx, annot, &bounds);
+ bounds = fz_bound_annot(ctx, annot);
fz_catch(ctx)
rethrow(J);
@@ -2107,7 +2107,7 @@ static void ffi_new_Pixmap(js_State *J)
fz_pixmap *pixmap = NULL;
fz_try(ctx)
- pixmap = fz_new_pixmap_with_bbox(ctx, colorspace, &bounds, 0, alpha);
+ pixmap = fz_new_pixmap_with_bbox(ctx, colorspace, bounds, 0, alpha);
fz_catch(ctx)
rethrow(J);
@@ -2339,7 +2339,7 @@ static void ffi_Shade_bound(js_State *J)
fz_rect bounds;
fz_try(ctx)
- fz_bound_shade(ctx, shade, &ctm, &bounds);
+ bounds = fz_bound_shade(ctx, shade, ctm);
fz_catch(ctx)
rethrow(J);
@@ -2459,7 +2459,7 @@ static void ffi_Text_showGlyph(js_State *J)
int wmode = js_isdefined(J, 5) ? js_toboolean(J, 5) : 0;
fz_try(ctx)
- fz_show_glyph(ctx, text, font, &trm, glyph, unicode, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, trm, glyph, unicode, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
fz_catch(ctx)
rethrow(J);
}
@@ -2687,7 +2687,7 @@ static void ffi_Path_bound(js_State *J)
fz_rect bounds;
fz_try(ctx)
- fz_bound_path(ctx, path, &stroke, &ctm, &bounds);
+ bounds = fz_bound_path(ctx, path, &stroke, ctm);
fz_catch(ctx)
rethrow(J);
@@ -2701,7 +2701,7 @@ static void ffi_Path_transform(js_State *J)
fz_matrix ctm = ffi_tomatrix(J, 1);
fz_try(ctx)
- fz_transform_path(ctx, path, &ctm);
+ fz_transform_path(ctx, path, ctm);
fz_catch(ctx)
rethrow(J);
}
@@ -2713,7 +2713,7 @@ static void ffi_new_DisplayList(js_State *J)
fz_display_list *list = NULL;
fz_try(ctx)
- list = fz_new_display_list(ctx, &mediabox);
+ list = fz_new_display_list(ctx, mediabox);
fz_catch(ctx)
rethrow(J);
@@ -3354,7 +3354,7 @@ static void ffi_PDFDocument_addPage(js_State *J)
pdf_obj *ind = NULL;
fz_try(ctx)
- ind = pdf_add_page(ctx, pdf, &mediabox, rotate, resources, contents);
+ ind = pdf_add_page(ctx, pdf, mediabox, rotate, resources, contents);
fz_always(ctx) {
fz_drop_buffer(ctx, contents);
pdf_drop_obj(ctx, resources);
@@ -4110,7 +4110,7 @@ static void ffi_PDFAnnotation_getRect(js_State *J)
pdf_annot *annot = js_touserdata(J, 0, "pdf_annot");
fz_rect rect;
fz_try(ctx)
- pdf_annot_rect(ctx, annot, &rect);
+ rect = pdf_annot_rect(ctx, annot);
fz_catch(ctx)
rethrow(J);
ffi_pushrect(J, rect);
@@ -4122,7 +4122,7 @@ static void ffi_PDFAnnotation_setRect(js_State *J)
pdf_annot *annot = js_touserdata(J, 0, "pdf_annot");
fz_rect rect = ffi_torect(J, 1);
fz_try(ctx)
- pdf_set_annot_rect(ctx, annot, &rect);
+ pdf_set_annot_rect(ctx, annot, rect);
fz_catch(ctx)
rethrow(J);
}
diff --git a/source/tools/mutrace.c b/source/tools/mutrace.c
index 2baef7d1..350de919 100644
--- a/source/tools/mutrace.c
+++ b/source/tools/mutrace.c
@@ -44,7 +44,7 @@ static void runpage(fz_context *ctx, fz_document *doc, int number)
fz_try(ctx)
{
page = fz_load_page(ctx, doc, number - 1);
- fz_bound_page(ctx, page, &mediabox);
+ mediabox = fz_bound_page(ctx, page);
printf("<page number=\"%d\" mediabox=\"%g %g %g %g\">\n",
number, mediabox.x0, mediabox.y0, mediabox.x1, mediabox.y1);
dev = fz_new_trace_device(ctx, fz_stdout(ctx));
diff --git a/source/tools/pdfcreate.c b/source/tools/pdfcreate.c
index a8502fdc..52d16dbe 100644
--- a/source/tools/pdfcreate.c
+++ b/source/tools/pdfcreate.c
@@ -207,7 +207,7 @@ static void create_page(char *input)
}
fz_drop_stream(ctx, stm);
- page = pdf_add_page(ctx, doc, &mediabox, rotate, resources, contents);
+ page = pdf_add_page(ctx, doc, mediabox, rotate, resources, contents);
pdf_insert_page(ctx, doc, -1, page);
pdf_drop_obj(ctx, page);
diff --git a/source/tools/pdfinfo.c b/source/tools/pdfinfo.c
index 65178561..4a726bfe 100644
--- a/source/tools/pdfinfo.c
+++ b/source/tools/pdfinfo.c
@@ -213,7 +213,7 @@ gatherdimensions(fz_context *ctx, globals *glo, int page, pdf_obj *pageref)
if (!pdf_is_array(ctx, obj))
return;
- pdf_to_rect(ctx, obj, &bbox);
+ bbox = pdf_to_rect(ctx, obj);
obj = pdf_dict_get(ctx, pageref, PDF_NAME(UserUnit));
if (pdf_is_real(ctx, obj))
diff --git a/source/tools/pdfpages.c b/source/tools/pdfpages.c
index cf5a8bf2..fa13e91e 100644
--- a/source/tools/pdfpages.c
+++ b/source/tools/pdfpages.c
@@ -33,7 +33,7 @@ showbox(fz_context *ctx, fz_output *out, pdf_obj *page, char *text, pdf_obj *nam
if (!pdf_is_array(ctx, obj))
break;
- pdf_to_rect(ctx, obj, &bbox);
+ bbox = pdf_to_rect(ctx, obj);
fz_write_printf(ctx, out, "<%s l=\"%g\" b=\"%g\" r=\"%g\" t=\"%g\" />\n", text, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
}
diff --git a/source/tools/pdfportfolio.c b/source/tools/pdfportfolio.c
index a5830149..beeeaf23 100644
--- a/source/tools/pdfportfolio.c
+++ b/source/tools/pdfportfolio.c
@@ -263,7 +263,7 @@ int pdfportfolio_main(int argc, char **argv)
contents = fz_new_buffer_from_shared_data(ctx, (const unsigned char *)template, strlen(template));
- page_obj = pdf_add_page(ctx, doc, &mediabox, 0, resources, contents);
+ page_obj = pdf_add_page(ctx, doc, mediabox, 0, resources, contents);
pdf_insert_page(ctx, doc, -1, page_obj);
pdf_drop_obj(ctx, page_obj);
pdf_drop_obj(ctx, resources);
diff --git a/source/xps/xps-common.c b/source/xps/xps-common.c
index f2f9b93c..75baa2bf 100644
--- a/source/xps/xps-common.c
+++ b/source/xps/xps-common.c
@@ -33,7 +33,7 @@ xps_lookup_alternate_content(fz_context *ctx, xps_document *doc, fz_xml *node)
}
void
-xps_parse_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node)
+xps_parse_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node)
{
if (doc->cookie && doc->cookie->abort)
return;
@@ -51,7 +51,7 @@ xps_parse_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const
}
void
-xps_parse_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node)
+xps_parse_element(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node)
{
if (doc->cookie && doc->cookie->abort)
return;
@@ -71,7 +71,7 @@ xps_parse_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, cons
}
void
-xps_begin_opacity(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_begin_opacity(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict,
char *opacity_att, fz_xml *opacity_mask_tag)
{
@@ -109,7 +109,7 @@ xps_begin_opacity(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, cons
if (opacity_mask_tag)
{
- fz_begin_mask(ctx, dev, area, 0, NULL, NULL, NULL);
+ fz_begin_mask(ctx, dev, &area, 0, NULL, NULL, NULL);
xps_parse_brush(ctx, doc, ctm, area, base_uri, dict, opacity_mask_tag);
fz_end_mask(ctx, dev);
}
@@ -134,9 +134,10 @@ xps_end_opacity(fz_context *ctx, xps_document *doc, char *base_uri, xps_resource
}
}
-static void
-xps_parse_render_transform(fz_context *ctx, xps_document *doc, char *transform, fz_matrix *matrix)
+static fz_matrix
+xps_parse_render_transform(fz_context *ctx, xps_document *doc, char *transform)
{
+ fz_matrix matrix;
float args[6];
char *s = transform;
int i;
@@ -154,40 +155,38 @@ xps_parse_render_transform(fz_context *ctx, xps_document *doc, char *transform,
s++;
}
- matrix->a = args[0]; matrix->b = args[1];
- matrix->c = args[2]; matrix->d = args[3];
- matrix->e = args[4]; matrix->f = args[5];
+ matrix.a = args[0]; matrix.b = args[1];
+ matrix.c = args[2]; matrix.d = args[3];
+ matrix.e = args[4]; matrix.f = args[5];
+ return matrix;
}
-static void
-xps_parse_matrix_transform(fz_context *ctx, xps_document *doc, fz_xml *root, fz_matrix *matrix)
+static fz_matrix
+xps_parse_matrix_transform(fz_context *ctx, xps_document *doc, fz_xml *root)
{
- char *transform;
-
- *matrix = fz_identity;
-
if (fz_xml_is_tag(root, "MatrixTransform"))
{
- transform = fz_xml_att(root, "Matrix");
+ char *transform = fz_xml_att(root, "Matrix");
if (transform)
- xps_parse_render_transform(ctx, doc, transform, matrix);
+ return xps_parse_render_transform(ctx, doc, transform);
}
+ return fz_identity;
}
-void
-xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix *transform, const fz_matrix *ctm)
+fz_matrix
+xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix ctm)
{
- *transform = fz_identity;
if (att)
- xps_parse_render_transform(ctx, doc, att, transform);
+ return fz_concat(xps_parse_render_transform(ctx, doc, att), ctm);
if (tag)
- xps_parse_matrix_transform(ctx, doc, tag, transform);
- fz_concat(transform, transform, ctm);
+ return fz_concat(xps_parse_matrix_transform(ctx, doc, tag), ctm);
+ return ctm;
}
-void
-xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text, fz_rect *rect)
+fz_rect
+xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text)
{
+ fz_rect rect;
float args[4];
char *s = text;
int i;
@@ -204,10 +203,11 @@ xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text, fz_rect *rec
s++;
}
- rect->x0 = args[0];
- rect->y0 = args[1];
- rect->x1 = args[0] + args[2];
- rect->y1 = args[1] + args[3];
+ rect.x0 = args[0];
+ rect.y0 = args[1];
+ rect.x1 = args[0] + args[2];
+ rect.y1 = args[1] + args[3];
+ return rect;
}
static int count_commas(char *s)
diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c
index a58aab72..de68c96f 100644
--- a/source/xps/xps-doc.c
+++ b/source/xps/xps-doc.c
@@ -377,13 +377,14 @@ xps_load_fixed_page(fz_context *ctx, xps_document *doc, xps_fixpage *page)
return xml;
}
-static fz_rect *
-xps_bound_page(fz_context *ctx, fz_page *page_, fz_rect *bounds)
+static fz_rect
+xps_bound_page(fz_context *ctx, fz_page *page_)
{
xps_page *page = (xps_page*)page_;
- bounds->x0 = bounds->y0 = 0;
- bounds->x1 = page->fix->width * 72.0f / 96.0f;
- bounds->y1 = page->fix->height * 72.0f / 96.0f;
+ fz_rect bounds;
+ bounds.x0 = bounds.y0 = 0;
+ bounds.x1 = page->fix->width * 72.0f / 96.0f;
+ bounds.y1 = page->fix->height * 72.0f / 96.0f;
return bounds;
}
diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c
index 31da84fd..1effccc2 100644
--- a/source/xps/xps-glyphs.c
+++ b/source/xps/xps-glyphs.c
@@ -344,7 +344,7 @@ xps_parse_glyph_metrics(char *s, float *advance, float *uofs, float *vofs, int b
* Calculate metrics for positioning.
*/
fz_text *
-xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, fz_matrix ctm,
fz_font *font, float size, float originx, float originy,
int is_sideways, int bidi_level,
char *indices, char *unicode)
@@ -369,11 +369,9 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
}
if (is_sideways)
- {
- fz_pre_scale(fz_rotate(&tm, 90), -size, size);
- }
+ tm = fz_pre_scale(fz_rotate(90), -size, size);
else
- fz_scale(&tm, size, -size);
+ tm = fz_scale(size, -size);
text = fz_new_text(ctx);
@@ -454,7 +452,7 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
}
dir = bidi_level & 1 ? FZ_BIDI_RTL : FZ_BIDI_LTR;
- fz_show_glyph(ctx, text, font, &tm, glyph_index, char_code, is_sideways, bidi_level, dir, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, tm, glyph_index, char_code, is_sideways, bidi_level, dir, FZ_LANG_UNSET);
x += advance * 0.01f * size;
}
@@ -464,7 +462,7 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
}
void
-xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_parse_glyphs(fz_context *ctx, xps_document *doc, fz_matrix ctm,
char *base_uri, xps_resource *dict, fz_xml *root)
{
fz_device *dev = doc->dev;
@@ -505,8 +503,6 @@ xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
fz_text *text;
fz_rect area;
- fz_matrix local_ctm;
-
/*
* Extract attributes and extended attributes.
*/
@@ -576,20 +572,20 @@ xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
* Set up graphics state.
*/
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (clip_att || clip_tag)
- xps_clip(ctx, doc, &local_ctm, dict, clip_att, clip_tag);
+ xps_clip(ctx, doc, ctm, dict, clip_att, clip_tag);
font_size = fz_atof(font_size_att);
- text = xps_parse_glyphs_imp(ctx, doc, &local_ctm, font, font_size,
+ text = xps_parse_glyphs_imp(ctx, doc, ctm, font, font_size,
fz_atof(origin_x_att), fz_atof(origin_y_att),
is_sideways, bidi_level, indices_att, unicode_att);
- fz_bound_text(ctx, text, NULL, &local_ctm, &area);
+ area = fz_bound_text(ctx, text, NULL, ctm);
- xps_begin_opacity(ctx, doc, &local_ctm, &area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
+ xps_begin_opacity(ctx, doc, ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
/* If it's a solid color brush fill/stroke do a simple fill */
@@ -610,7 +606,7 @@ xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
samples[0] *= fz_atof(fill_opacity_att);
xps_set_color(ctx, doc, colorspace, samples);
- fz_fill_text(ctx, dev, text, &local_ctm,
+ fz_fill_text(ctx, dev, text, &ctm,
doc->colorspace, doc->color, doc->alpha, NULL);
}
@@ -618,8 +614,8 @@ xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
if (fill_tag)
{
- fz_clip_text(ctx, dev, text, &local_ctm, &area);
- xps_parse_brush(ctx, doc, &local_ctm, &area, fill_uri, dict, fill_tag);
+ fz_clip_text(ctx, dev, text, &ctm, &area);
+ xps_parse_brush(ctx, doc, ctm, area, fill_uri, dict, fill_tag);
fz_pop_clip(ctx, dev);
}
diff --git a/source/xps/xps-gradient.c b/source/xps/xps-gradient.c
index 7916d088..73022790 100644
--- a/source/xps/xps-gradient.c
+++ b/source/xps/xps-gradient.c
@@ -210,7 +210,7 @@ xps_sample_gradient_stops(fz_context *ctx, xps_document *doc, fz_shade *shade, s
*/
static void
-xps_draw_one_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_draw_one_radial_gradient(fz_context *ctx, xps_document *doc, fz_matrix ctm,
struct stop *stops, int count,
int extend,
float x0, float y0, float r0,
@@ -240,7 +240,7 @@ xps_draw_one_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix
shade->u.l_or_r.coords[1][1] = y1;
shade->u.l_or_r.coords[1][2] = r1;
- fz_fill_shade(ctx, dev, shade, ctm, 1, fz_default_color_params(ctx));
+ fz_fill_shade(ctx, dev, shade, &ctm, 1, fz_default_color_params(ctx));
fz_drop_shade(ctx, shade);
}
@@ -250,7 +250,7 @@ xps_draw_one_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix
*/
static void
-xps_draw_one_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_draw_one_linear_gradient(fz_context *ctx, xps_document *doc, fz_matrix ctm,
struct stop *stops, int count,
int extend,
float x0, float y0, float x1, float y1)
@@ -279,7 +279,7 @@ xps_draw_one_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix
shade->u.l_or_r.coords[1][1] = y1;
shade->u.l_or_r.coords[1][2] = 0;
- fz_fill_shade(ctx, dev, shade, ctm, doc->opacity[doc->opacity_top], fz_default_color_params(ctx));
+ fz_fill_shade(ctx, dev, shade, &ctm, doc->opacity[doc->opacity_top], fz_default_color_params(ctx));
fz_drop_shade(ctx, shade);
}
@@ -293,7 +293,7 @@ xps_draw_one_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix
*/
static void
-xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
struct stop *stops, int count,
fz_xml *root, int spread)
{
@@ -303,9 +303,7 @@ xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
float yrad = 1;
float invscale;
int i, ma = 1;
- fz_matrix local_ctm = *ctm;
fz_matrix inv;
- fz_rect local_area = *area;
char *center_att = fz_xml_att(root, "Center");
char *origin_att = fz_xml_att(root, "GradientOrigin");
@@ -332,7 +330,7 @@ xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
/* scale the ctm to make ellipses */
if (fz_abs(xrad) > FLT_EPSILON)
{
- fz_pre_scale(&local_ctm, 1, yrad/xrad);
+ ctm = fz_pre_scale(ctm, 1, yrad/xrad);
}
if (yrad != 0.0f)
@@ -345,16 +343,17 @@ xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
r0 = 0;
r1 = xrad;
- fz_transform_rect(&local_area, fz_invert_matrix(&inv, &local_ctm));
- ma = fz_maxi(ma, ceilf(hypotf(local_area.x0 - x0, local_area.y0 - y0) / xrad));
- ma = fz_maxi(ma, ceilf(hypotf(local_area.x1 - x0, local_area.y0 - y0) / xrad));
- ma = fz_maxi(ma, ceilf(hypotf(local_area.x0 - x0, local_area.y1 - y0) / xrad));
- ma = fz_maxi(ma, ceilf(hypotf(local_area.x1 - x0, local_area.y1 - y0) / xrad));
+ inv = fz_invert_matrix(ctm);
+ area = fz_transform_rect(area, inv);
+ ma = fz_maxi(ma, ceilf(hypotf(area.x0 - x0, area.y0 - y0) / xrad));
+ ma = fz_maxi(ma, ceilf(hypotf(area.x1 - x0, area.y0 - y0) / xrad));
+ ma = fz_maxi(ma, ceilf(hypotf(area.x0 - x0, area.y1 - y0) / xrad));
+ ma = fz_maxi(ma, ceilf(hypotf(area.x1 - x0, area.y1 - y0) / xrad));
if (spread == SPREAD_REPEAT)
{
for (i = ma - 1; i >= 0; i--)
- xps_draw_one_radial_gradient(ctx, doc, &local_ctm, stops, count, 0, x0, y0, r0 + i * xrad, x1, y1, r1 + i * xrad);
+ xps_draw_one_radial_gradient(ctx, doc, ctm, stops, count, 0, x0, y0, r0 + i * xrad, x1, y1, r1 + i * xrad);
}
else if (spread == SPREAD_REFLECT)
{
@@ -362,13 +361,13 @@ xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
ma++;
for (i = ma - 2; i >= 0; i -= 2)
{
- xps_draw_one_radial_gradient(ctx, doc, &local_ctm, stops, count, 0, x0, y0, r0 + i * xrad, x1, y1, r1 + i * xrad);
- xps_draw_one_radial_gradient(ctx, doc, &local_ctm, stops, count, 0, x0, y0, r0 + (i + 2) * xrad, x1, y1, r1 + i * xrad);
+ xps_draw_one_radial_gradient(ctx, doc, ctm, stops, count, 0, x0, y0, r0 + i * xrad, x1, y1, r1 + i * xrad);
+ xps_draw_one_radial_gradient(ctx, doc, ctm, stops, count, 0, x0, y0, r0 + (i + 2) * xrad, x1, y1, r1 + i * xrad);
}
}
else
{
- xps_draw_one_radial_gradient(ctx, doc, &local_ctm, stops, count, 1, x0, y0, r0, x1, y1, r1);
+ xps_draw_one_radial_gradient(ctx, doc, ctm, stops, count, 1, x0, y0, r0, x1, y1, r1);
}
}
@@ -378,7 +377,7 @@ xps_draw_radial_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
*/
static void
-xps_draw_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_draw_linear_gradient(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
struct stop *stops, int count,
fz_xml *root, int spread)
{
@@ -387,7 +386,6 @@ xps_draw_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
float dx, dy, x, y, k;
fz_point p1, p2;
fz_matrix inv;
- fz_rect local_area = *area;
char *start_point_att = fz_xml_att(root, "StartPoint");
char *end_point_att = fz_xml_att(root, "EndPoint");
@@ -401,15 +399,16 @@ xps_draw_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
xps_parse_point(ctx, doc, end_point_att, &x1, &y1);
p1.x = x0; p1.y = y0; p2.x = x1; p2.y = y1;
- fz_transform_rect(&local_area, fz_invert_matrix(&inv, ctm));
+ inv = fz_invert_matrix(ctm);
+ area = fz_transform_rect(area, inv);
x = p2.x - p1.x; y = p2.y - p1.y;
- k = ((local_area.x0 - p1.x) * x + (local_area.y0 - p1.y) * y) / (x * x + y * y);
+ k = ((area.x0 - p1.x) * x + (area.y0 - p1.y) * y) / (x * x + y * y);
mi = floorf(k); ma = ceilf(k);
- k = ((local_area.x1 - p1.x) * x + (local_area.y0 - p1.y) * y) / (x * x + y * y);
+ k = ((area.x1 - p1.x) * x + (area.y0 - p1.y) * y) / (x * x + y * y);
mi = fz_mini(mi, floorf(k)); ma = fz_maxi(ma, ceilf(k));
- k = ((local_area.x0 - p1.x) * x + (local_area.y1 - p1.y) * y) / (x * x + y * y);
+ k = ((area.x0 - p1.x) * x + (area.y1 - p1.y) * y) / (x * x + y * y);
mi = fz_mini(mi, floorf(k)); ma = fz_maxi(ma, ceilf(k));
- k = ((local_area.x1 - p1.x) * x + (local_area.y1 - p1.y) * y) / (x * x + y * y);
+ k = ((area.x1 - p1.x) * x + (area.y1 - p1.y) * y) / (x * x + y * y);
mi = fz_mini(mi, floorf(k)); ma = fz_maxi(ma, ceilf(k));
dx = x1 - x0; dy = y1 - y0;
@@ -440,9 +439,9 @@ xps_draw_linear_gradient(fz_context *ctx, xps_document *doc, const fz_matrix *ct
*/
static void
-xps_parse_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root,
- void (*draw)(fz_context *ctx, xps_document *, const fz_matrix*, const fz_rect *, struct stop *, int, fz_xml *, int))
+ void (*draw)(fz_context *ctx, xps_document *, fz_matrix, fz_rect, struct stop *, int, fz_xml *, int))
{
fz_xml *node;
@@ -455,7 +454,6 @@ xps_parse_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ct
struct stop stop_list[MAX_STOPS];
int stop_count;
- fz_matrix local_ctm;
int spread_method;
opacity_att = fz_xml_att(root, "Opacity");
@@ -487,7 +485,7 @@ xps_parse_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ct
spread_method = SPREAD_REPEAT;
}
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (!stop_tag) {
fz_warn(ctx, "missing gradient stops tag");
@@ -501,22 +499,22 @@ xps_parse_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ct
return;
}
- xps_begin_opacity(ctx, doc, &local_ctm, area, base_uri, dict, opacity_att, NULL);
+ xps_begin_opacity(ctx, doc, ctm, area, base_uri, dict, opacity_att, NULL);
- draw(ctx, doc, &local_ctm, area, stop_list, stop_count, root, spread_method);
+ draw(ctx, doc, ctm, area, stop_list, stop_count, root, spread_method);
xps_end_opacity(ctx, doc, base_uri, dict, opacity_att, NULL);
}
void
-xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root)
{
xps_parse_gradient_brush(ctx, doc, ctm, area, base_uri, dict, root, xps_draw_linear_gradient);
}
void
-xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root)
{
xps_parse_gradient_brush(ctx, doc, ctm, area, base_uri, dict, root, xps_draw_radial_gradient);
diff --git a/source/xps/xps-image.c b/source/xps/xps-image.c
index 82eee8e5..b5affe35 100644
--- a/source/xps/xps-image.c
+++ b/source/xps/xps-image.c
@@ -11,19 +11,18 @@ xps_load_image(fz_context *ctx, xps_document *doc, xps_part *part)
/* FIXME: area unused! */
static void
-xps_paint_image_brush(fz_context *ctx, 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, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict,
fz_xml *root, void *vimage)
{
fz_image *image = vimage;
float xs, ys;
- fz_matrix local_ctm = *ctm;
if (image->xres == 0 || image->yres == 0)
return;
xs = image->w * 96 / image->xres;
ys = image->h * 96 / image->yres;
- fz_pre_scale(&local_ctm, xs, ys);
- fz_fill_image(ctx, doc->dev, image, &local_ctm, doc->opacity[doc->opacity_top], fz_default_color_params(ctx));
+ ctm = fz_pre_scale(ctm, xs, ys);
+ fz_fill_image(ctx, doc->dev, image, &ctm, doc->opacity[doc->opacity_top], fz_default_color_params(ctx));
}
static void
@@ -90,7 +89,7 @@ xps_find_image_brush_source_part(fz_context *ctx, xps_document *doc, char *base_
}
void
-xps_parse_image_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_image_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root)
{
xps_part *part = NULL;
diff --git a/source/xps/xps-imp.h b/source/xps/xps-imp.h
index 1d2baaf0..fc820033 100644
--- a/source/xps/xps-imp.h
+++ b/source/xps/xps-imp.h
@@ -142,35 +142,35 @@ void xps_print_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resou
* Fixed page/graphics parsing.
*/
-void xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_page *page);
-void xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_solid_color_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void 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 *node);
-void xps_parse_visual_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-
-void xps_parse_tiling_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(*func)(fz_context *ctx, xps_document*, const fz_matrix *, const fz_rect *, char*, xps_resource*, fz_xml*, void*), void *user);
+void xps_parse_fixed_page(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_page *page);
+void xps_parse_canvas(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_path(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_glyphs(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_solid_color_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_image_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_visual_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+
+void xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *root, void(*func)(fz_context *ctx, xps_document*, fz_matrix, fz_rect, char*, xps_resource*, fz_xml*, void*), void *user);
fz_font *xps_lookup_font(fz_context *ctx, xps_document *doc, char *base_uri, char *font_uri, char *style_att);
-fz_text *xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+fz_text *xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, fz_matrix ctm,
fz_font *font, float size, float originx, float originy,
int is_sideways, int bidi_level,
char *indices, char *unicode);
fz_path *xps_parse_abbreviated_geometry(fz_context *ctx, xps_document *doc, char *geom, int *fill_rule);
fz_path *xps_parse_path_geometry(fz_context *ctx, xps_document *doc, xps_resource *dict, fz_xml *root, int stroking, int *fill_rule);
-void xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix *new_ctm, const fz_matrix *ctm);
-void xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text, fz_rect *rect);
+fz_matrix xps_parse_transform(fz_context *ctx, xps_document *doc, char *att, fz_xml *tag, fz_matrix ctm);
+fz_rect xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text);
-void xps_begin_opacity(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
+void xps_begin_opacity(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
void xps_end_opacity(fz_context *ctx, xps_document *doc, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
-void xps_parse_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_element(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_clip(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag);
+void xps_clip(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag);
fz_xml *xps_lookup_alternate_content(fz_context *ctx, xps_document *doc, fz_xml *node);
diff --git a/source/xps/xps-link.c b/source/xps/xps-link.c
index 59b4d1a5..9da2e5e2 100644
--- a/source/xps/xps-link.c
+++ b/source/xps/xps-link.c
@@ -7,11 +7,11 @@
/* Quick parsing of document to find links. */
static void
-xps_load_links_in_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_load_links_in_element(fz_context *ctx, xps_document *doc, fz_matrix ctm,
char *base_uri, xps_resource *dict, fz_xml *node, fz_link **link);
static void
-xps_add_link(fz_context *ctx, xps_document *doc, const fz_rect *area, char *base_uri, char *target_uri, fz_link **head)
+xps_add_link(fz_context *ctx, xps_document *doc, fz_rect area, char *base_uri, char *target_uri, fz_link **head)
{
fz_link *link = fz_new_link(ctx, area, doc, target_uri);
link->next = *head;
@@ -19,7 +19,7 @@ xps_add_link(fz_context *ctx, xps_document *doc, const fz_rect *area, char *base
}
static void
-xps_load_links_in_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_load_links_in_path(fz_context *ctx, xps_document *doc, fz_matrix ctm,
char *base_uri, xps_resource *dict, fz_xml *root, fz_link **link)
{
char *navigate_uri_att = fz_xml_att(root, "FixedPage.NavigateUri");
@@ -33,13 +33,12 @@ xps_load_links_in_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
fz_path *path = NULL;
int fill_rule;
- fz_matrix local_ctm;
fz_rect area;
xps_resolve_resource_reference(ctx, doc, dict, &data_att, &data_tag, NULL);
xps_resolve_resource_reference(ctx, doc, dict, &transform_att, &transform_tag, NULL);
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (data_att)
path = xps_parse_abbreviated_geometry(ctx, doc, data_att, &fill_rule);
@@ -47,15 +46,15 @@ xps_load_links_in_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
path = xps_parse_path_geometry(ctx, doc, dict, data_tag, 0, &fill_rule);
if (path)
{
- fz_bound_path(ctx, path, NULL, &local_ctm, &area);
+ area = fz_bound_path(ctx, path, NULL, ctm);
fz_drop_path(ctx, path);
- xps_add_link(ctx, doc, &area, base_uri, navigate_uri_att, link);
+ xps_add_link(ctx, doc, area, base_uri, navigate_uri_att, link);
}
}
}
static void
-xps_load_links_in_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_load_links_in_glyphs(fz_context *ctx, xps_document *doc, fz_matrix ctm,
char *base_uri, xps_resource *dict, fz_xml *root, fz_link **link)
{
char *navigate_uri_att = fz_xml_att(root, "FixedPage.NavigateUri");
@@ -76,14 +75,13 @@ xps_load_links_in_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ct
int is_sideways = 0;
int bidi_level = 0;
- fz_matrix local_ctm;
fz_font *font;
fz_text *text;
fz_rect area;
xps_resolve_resource_reference(ctx, doc, dict, &transform_att, &transform_tag, NULL);
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (is_sideways_att)
is_sideways = !strcmp(is_sideways_att, "true");
@@ -93,23 +91,22 @@ xps_load_links_in_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ct
font = xps_lookup_font(ctx, doc, base_uri, font_uri_att, style_att);
if (!font)
return;
- text = xps_parse_glyphs_imp(ctx, doc, &local_ctm, font, fz_atof(font_size_att),
+ text = xps_parse_glyphs_imp(ctx, doc, ctm, font, fz_atof(font_size_att),
fz_atof(origin_x_att), fz_atof(origin_y_att),
is_sideways, bidi_level, indices_att, unicode_att);
- fz_bound_text(ctx, text, NULL, &local_ctm, &area);
+ area = fz_bound_text(ctx, text, NULL, ctm);
fz_drop_text(ctx, text);
fz_drop_font(ctx, font);
- xps_add_link(ctx, doc, &area, base_uri, navigate_uri_att, link);
+ xps_add_link(ctx, doc, area, base_uri, navigate_uri_att, link);
}
}
static void
-xps_load_links_in_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
+xps_load_links_in_canvas(fz_context *ctx, xps_document *doc, fz_matrix ctm,
char *base_uri, xps_resource *dict, fz_xml *root, fz_link **link)
{
xps_resource *new_dict = NULL;
- fz_matrix local_ctm;
fz_xml *node;
char *navigate_uri_att = fz_xml_att(root, "FixedPage.NavigateUri");
@@ -129,20 +126,20 @@ xps_load_links_in_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ct
xps_resolve_resource_reference(ctx, doc, dict, &transform_att, &transform_tag, NULL);
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (navigate_uri_att)
fz_warn(ctx, "FixedPage.NavigateUri attribute on Canvas element");
for (node = fz_xml_down(root); node; node = fz_xml_next(node))
- xps_load_links_in_element(ctx, doc, &local_ctm, base_uri, dict, node, link);
+ xps_load_links_in_element(ctx, doc, ctm, base_uri, dict, node, link);
if (new_dict)
xps_drop_resource_dictionary(ctx, doc, new_dict);
}
static void
-xps_load_links_in_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node, fz_link **link)
+xps_load_links_in_element(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *node, fz_link **link)
{
if (fz_xml_is_tag(node, "Path"))
xps_load_links_in_path(ctx, doc, ctm, base_uri, dict, node, link);
@@ -159,7 +156,7 @@ xps_load_links_in_element(fz_context *ctx, xps_document *doc, const fz_matrix *c
}
static void
-xps_load_links_in_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_page *page, fz_link **link)
+xps_load_links_in_fixed_page(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_page *page, fz_link **link)
{
fz_xml *root, *node, *resource_tag;
xps_resource *dict = NULL;
@@ -193,7 +190,7 @@ xps_load_links(fz_context *ctx, fz_page *page_)
xps_page *page = (xps_page*)page_;
fz_matrix ctm;
fz_link *link = NULL;
- fz_scale(&ctm, 72.0f / 96.0f, 72.0f / 96.0f);
- xps_load_links_in_fixed_page(ctx, page->doc, &ctm, page, &link);
+ ctm = fz_scale(72.0f / 96.0f, 72.0f / 96.0f);
+ xps_load_links_in_fixed_page(ctx, page->doc, ctm, page, &link);
return link;
}
diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c
index 021d2021..ad8ea535 100644
--- a/source/xps/xps-path.c
+++ b/source/xps/xps-path.c
@@ -49,7 +49,7 @@ xps_parse_point(fz_context *ctx, xps_document *doc, char *s_in, float *x, float
* calculated by th0, and on exit, a point is generated for us at th0.
*/
static void
-xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz_matrix *mtx, float th0, float th1, int iscw)
+xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, fz_matrix mtx, float th0, float th1, int iscw)
{
float t, d;
fz_point p;
@@ -63,7 +63,7 @@ xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz
{
for (t = th0 + d; t < th1 - d/2; t += d)
{
- fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
+ p = fz_transform_point_xy(cosf(t), sinf(t), mtx);
fz_lineto(ctx, path, p.x, p.y);
}
}
@@ -72,7 +72,7 @@ xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz
th0 += FZ_PI * 2;
for (t = th0 - d; t > th1 + d/2; t -= d)
{
- fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
+ p = fz_transform_point_xy(cosf(t), sinf(t), mtx);
fz_lineto(ctx, path, p.x, p.y);
}
}
@@ -80,7 +80,7 @@ xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz
/* Given two vectors find the angle between them. */
static float
-angle_between(const fz_point u, const fz_point v)
+angle_between(fz_point u, fz_point v)
{
float det = u.x * v.y - u.y * v.x;
float sign = (det < 0 ? -1 : 1);
@@ -140,8 +140,8 @@ xps_draw_arc(fz_context *ctx, xps_document *doc, fz_path *path,
else
sign = -1;
- fz_rotate(&rotmat, rotation_angle);
- fz_rotate(&revmat, -rotation_angle);
+ rotmat = fz_rotate(rotation_angle);
+ revmat = fz_rotate(-rotation_angle);
/* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes */
/* Conversion from endpoint to center parameterization */
@@ -158,7 +158,7 @@ xps_draw_arc(fz_context *ctx, xps_document *doc, fz_path *path,
/* F.6.5.1 */
pt.x = (x1 - x2) / 2;
pt.y = (y1 - y2) / 2;
- fz_transform_vector(&pt, &revmat);
+ pt = fz_transform_vector(pt, revmat);
x1t = pt.x;
y1t = pt.y;
@@ -184,7 +184,7 @@ xps_draw_arc(fz_context *ctx, xps_document *doc, fz_path *path,
/* F.6.5.3 */
pt.x = cxt;
pt.y = cyt;
- fz_transform_vector(&pt, &rotmat);
+ pt = fz_transform_vector(pt, rotmat);
cx = pt.x + (x1 + x2) / 2;
cy = pt.y + (y1 + y2) / 2;
@@ -207,8 +207,8 @@ xps_draw_arc(fz_context *ctx, xps_document *doc, fz_path *path,
dth -= ((FZ_PI / 180) * 360);
}
- fz_pre_scale(fz_pre_rotate(fz_translate(&mtx, cx, cy), rotation_angle), rx, ry);
- xps_draw_arc_segment(ctx, doc, path, &mtx, th1, th1 + dth, is_clockwise);
+ mtx = fz_pre_scale(fz_pre_rotate(fz_translate(cx, cy), rotation_angle), rx, ry);
+ xps_draw_arc_segment(ctx, doc, path, mtx, th1, th1 + dth, is_clockwise);
fz_lineto(ctx, path, point_x, point_y);
}
@@ -719,7 +719,7 @@ xps_parse_path_geometry(fz_context *ctx, xps_document *doc, xps_resource *dict,
*fill_rule = 0;
}
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &transform, &fz_identity);
+ transform = xps_parse_transform(ctx, doc, transform_att, transform_tag, fz_identity);
if (figures_att)
path = xps_parse_abbreviated_geometry(ctx, doc, figures_att, fill_rule);
@@ -736,7 +736,7 @@ xps_parse_path_geometry(fz_context *ctx, xps_document *doc, xps_resource *dict,
}
if (transform_att || transform_tag)
- fz_transform_path(ctx, path, &transform);
+ fz_transform_path(ctx, path, transform);
return path;
}
@@ -755,7 +755,7 @@ xps_parse_line_cap(char *attr)
}
void
-xps_clip(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag)
+xps_clip(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag)
{
fz_device *dev = doc->dev;
fz_path *path;
@@ -767,7 +767,7 @@ xps_clip(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_resource
path = xps_parse_path_geometry(ctx, doc, dict, clip_tag, 0, &fill_rule);
else
path = fz_new_path(ctx);
- fz_clip_path(ctx, dev, path, fill_rule == 0, ctm, NULL);
+ fz_clip_path(ctx, dev, path, fill_rule == 0, &ctm, NULL);
fz_drop_path(ctx, path);
}
@@ -777,7 +777,7 @@ xps_clip(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_resource
*/
void
-xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *root)
+xps_parse_path(fz_context *ctx, xps_document *doc, fz_matrix ctm, char *base_uri, xps_resource *dict, fz_xml *root)
{
fz_device *dev = doc->dev;
@@ -822,7 +822,6 @@ xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *b
fz_rect area;
int fill_rule;
int dash_len = 0;
- fz_matrix local_ctm;
/*
* Extract attributes and extended attributes.
@@ -963,10 +962,10 @@ xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *b
}
}
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (clip_att || clip_tag)
- xps_clip(ctx, doc, &local_ctm, dict, clip_att, clip_tag);
+ xps_clip(ctx, doc, ctm, dict, clip_att, clip_tag);
fz_try(ctx)
{
@@ -985,17 +984,16 @@ xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *b
if (stroke_att || stroke_tag)
{
- fz_bound_path(ctx, stroke_path, stroke, &local_ctm, &area);
+ area = fz_bound_path(ctx, stroke_path, stroke, ctm);
if (stroke_path != path && (fill_att || fill_tag)) {
- fz_rect bounds;
- fz_bound_path(ctx, path, NULL, &local_ctm, &bounds);
- fz_union_rect(&area, &bounds);
+ fz_rect bounds = fz_bound_path(ctx, path, NULL, ctm);
+ area = fz_union_rect(area, bounds);
}
}
else
- fz_bound_path(ctx, path, NULL, &local_ctm, &area);
+ area = fz_bound_path(ctx, path, NULL, ctm);
- xps_begin_opacity(ctx, doc, &local_ctm, &area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
+ xps_begin_opacity(ctx, doc, ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
if (fill_att)
{
@@ -1003,14 +1001,14 @@ xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *b
if (fill_opacity_att)
samples[0] *= fz_atof(fill_opacity_att);
xps_set_color(ctx, doc, colorspace, samples);
- fz_fill_path(ctx, dev, path, fill_rule == 0, &local_ctm,
+ fz_fill_path(ctx, dev, path, fill_rule == 0, &ctm,
doc->colorspace, doc->color, doc->alpha, NULL);
}
if (fill_tag)
{
- fz_clip_path(ctx, dev, path, fill_rule == 0, &local_ctm, &area);
- xps_parse_brush(ctx, doc, &local_ctm, &area, fill_uri, dict, fill_tag);
+ fz_clip_path(ctx, dev, path, fill_rule == 0, &ctm, &area);
+ xps_parse_brush(ctx, doc, ctm, area, fill_uri, dict, fill_tag);
fz_pop_clip(ctx, dev);
}
@@ -1020,14 +1018,14 @@ xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *b
if (stroke_opacity_att)
samples[0] *= fz_atof(stroke_opacity_att);
xps_set_color(ctx, doc, colorspace, samples);
- fz_stroke_path(ctx, dev, stroke_path, stroke, &local_ctm,
+ fz_stroke_path(ctx, dev, stroke_path, stroke, &ctm,
doc->colorspace, doc->color, doc->alpha, NULL);
}
if (stroke_tag)
{
- fz_clip_stroke_path(ctx, dev, stroke_path, stroke, &local_ctm, &area);
- xps_parse_brush(ctx, doc, &local_ctm, &area, stroke_uri, dict, stroke_tag);
+ fz_clip_stroke_path(ctx, dev, stroke_path, stroke, &ctm, &area);
+ xps_parse_brush(ctx, doc, ctm, area, stroke_uri, dict, stroke_tag);
fz_pop_clip(ctx, dev);
}
diff --git a/source/xps/xps-tile.c b/source/xps/xps-tile.c
index 3e144123..6a75481f 100644
--- a/source/xps/xps-tile.c
+++ b/source/xps/xps-tile.c
@@ -19,28 +19,28 @@ struct closure
xps_resource *dict;
fz_xml *root;
void *user;
- void (*func)(fz_context *ctx, xps_document*, const fz_matrix *, const fz_rect *, char*, xps_resource*, fz_xml*, void*);
+ void (*func)(fz_context *ctx, xps_document*, fz_matrix, fz_rect, char*, xps_resource*, fz_xml*, void*);
};
static void
-xps_paint_tiling_brush_clipped(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *viewbox, struct closure *c)
+xps_paint_tiling_brush_clipped(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect viewbox, struct closure *c)
{
fz_device *dev = doc->dev;
fz_path *path = fz_new_path(ctx);
- fz_moveto(ctx, path, viewbox->x0, viewbox->y0);
- fz_lineto(ctx, path, viewbox->x0, viewbox->y1);
- fz_lineto(ctx, path, viewbox->x1, viewbox->y1);
- fz_lineto(ctx, path, viewbox->x1, viewbox->y0);
+ fz_moveto(ctx, path, viewbox.x0, viewbox.y0);
+ fz_lineto(ctx, path, viewbox.x0, viewbox.y1);
+ fz_lineto(ctx, path, viewbox.x1, viewbox.y1);
+ fz_lineto(ctx, path, viewbox.x1, viewbox.y0);
fz_closepath(ctx, path);
- fz_clip_path(ctx, dev, path, 0, ctm, NULL);
+ fz_clip_path(ctx, dev, path, 0, &ctm, NULL);
fz_drop_path(ctx, path);
c->func(ctx, doc, ctm, viewbox, c->base_uri, c->dict, c->root, c->user);
fz_pop_clip(ctx, dev);
}
static void
-xps_paint_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *viewbox, int tile_mode, struct closure *c)
+xps_paint_tiling_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect viewbox, int tile_mode, struct closure *c)
{
fz_matrix ttm;
@@ -48,30 +48,27 @@ xps_paint_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
if (tile_mode == TILE_FLIP_X || tile_mode == TILE_FLIP_X_Y)
{
- ttm = *ctm;
- fz_pre_scale(fz_pre_translate(&ttm, viewbox->x1 * 2, 0), -1, 1);
- xps_paint_tiling_brush_clipped(ctx, doc, &ttm, viewbox, c);
+ ttm = fz_pre_scale(fz_pre_translate(ctm, viewbox.x1 * 2, 0), -1, 1);
+ xps_paint_tiling_brush_clipped(ctx, doc, ttm, viewbox, c);
}
if (tile_mode == TILE_FLIP_Y || tile_mode == TILE_FLIP_X_Y)
{
- ttm = *ctm;
- fz_pre_scale(fz_pre_translate(&ttm, 0, viewbox->y1 * 2), 1, -1);
- xps_paint_tiling_brush_clipped(ctx, doc, &ttm, viewbox, c);
+ ttm = fz_pre_scale(fz_pre_translate(ctm, 0, viewbox.y1 * 2), 1, -1);
+ xps_paint_tiling_brush_clipped(ctx, doc, ttm, viewbox, c);
}
if (tile_mode == TILE_FLIP_X_Y)
{
- ttm = *ctm;
- fz_pre_scale(fz_pre_translate(&ttm, viewbox->x1 * 2, viewbox->y1 * 2), -1, -1);
- xps_paint_tiling_brush_clipped(ctx, doc, &ttm, viewbox, c);
+ ttm = fz_pre_scale(fz_pre_translate(ctm, viewbox.x1 * 2, viewbox.y1 * 2), -1, -1);
+ xps_paint_tiling_brush_clipped(ctx, doc, ttm, viewbox, c);
}
}
void
-xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root,
- void (*func)(fz_context *ctx, xps_document*, const fz_matrix*, const fz_rect*, char*, xps_resource*, fz_xml*, void*), void *user)
+ void (*func)(fz_context *ctx, xps_document*, fz_matrix, fz_rect, char*, xps_resource*, fz_xml*, void*), void *user)
{
fz_device *dev = doc->dev;
fz_xml *node;
@@ -85,7 +82,6 @@ xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
fz_xml *transform_tag = NULL;
- fz_matrix local_ctm;
fz_rect viewbox;
fz_rect viewport;
float xstep, ystep;
@@ -114,15 +110,15 @@ xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
xps_resolve_resource_reference(ctx, doc, dict, &transform_att, &transform_tag, NULL);
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
viewbox = fz_unit_rect;
if (viewbox_att)
- xps_parse_rectangle(ctx, doc, viewbox_att, &viewbox);
+ viewbox = xps_parse_rectangle(ctx, doc, viewbox_att);
viewport = fz_unit_rect;
if (viewport_att)
- xps_parse_rectangle(ctx, doc, viewport_att, &viewport);
+ viewport = xps_parse_rectangle(ctx, doc, viewport_att);
if (fabsf(viewport.x1 - viewport.x0) < 0.01f || fabsf(viewport.y1 - viewport.y0) < 0.01f)
fz_warn(ctx, "not drawing tile for viewport size %.4f x %.4f", viewport.x1 - viewport.x0, viewport.y1 - viewport.y0);
@@ -161,22 +157,22 @@ xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
if (tile_mode == TILE_FLIP_Y || tile_mode == TILE_FLIP_X_Y)
ystep *= 2;
- xps_begin_opacity(ctx, doc, &local_ctm, area, base_uri, dict, opacity_att, NULL);
+ xps_begin_opacity(ctx, doc, ctm, area, base_uri, dict, opacity_att, NULL);
- fz_pre_translate(&local_ctm, viewport.x0, viewport.y0);
- fz_pre_scale(&local_ctm, xscale, yscale);
- fz_pre_translate(&local_ctm, -viewbox.x0, -viewbox.y0);
+ ctm = fz_pre_translate(ctm, viewport.x0, viewport.y0);
+ ctm = fz_pre_scale(ctm, xscale, yscale);
+ ctm = fz_pre_translate(ctm, -viewbox.x0, -viewbox.y0);
if (tile_mode != TILE_NONE)
{
int x0, y0, x1, y1;
fz_matrix invctm;
- fz_rect local_area = *area;
- fz_transform_rect(&local_area, fz_invert_matrix(&invctm, &local_ctm));
- x0 = floorf(local_area.x0 / xstep);
- y0 = floorf(local_area.y0 / ystep);
- x1 = ceilf(local_area.x1 / xstep);
- y1 = ceilf(local_area.y1 / ystep);
+ invctm = fz_invert_matrix(ctm);
+ area = fz_transform_rect(area, invctm);
+ x0 = floorf(area.x0 / xstep);
+ y0 = floorf(area.y0 / ystep);
+ x1 = ceilf(area.x1 / xstep);
+ y1 = ceilf(area.y1 / ystep);
#ifdef TILE
if ((x1 - x0) * (y1 - y0) > 1)
@@ -187,8 +183,8 @@ xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
fz_rect bigview = viewbox;
bigview.x1 = bigview.x0 + xstep;
bigview.y1 = bigview.y0 + ystep;
- fz_begin_tile(ctx, dev, &local_area, &bigview, xstep, ystep, &local_ctm);
- xps_paint_tiling_brush(ctx, doc, &local_ctm, &viewbox, tile_mode, &c);
+ fz_begin_tile(ctx, dev, &area, &bigview, xstep, ystep, &ctm);
+ xps_paint_tiling_brush(ctx, doc, ctm, viewbox, tile_mode, &c);
fz_end_tile(ctx, dev);
}
else
@@ -198,30 +194,29 @@ xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
{
for (x = x0; x < x1; x++)
{
- fz_matrix ttm = local_ctm;
- fz_pre_translate(&ttm, xstep * x, ystep * y);
- xps_paint_tiling_brush(ctx, doc, &ttm, &viewbox, tile_mode, &c);
+ fz_matrix ttm = fz_pre_translate(ctm, xstep * x, ystep * y);
+ xps_paint_tiling_brush(ctx, doc, ttm, viewbox, tile_mode, &c);
}
}
}
}
else
{
- xps_paint_tiling_brush(ctx, doc, &local_ctm, &viewbox, tile_mode, &c);
+ xps_paint_tiling_brush(ctx, doc, ctm, viewbox, tile_mode, &c);
}
xps_end_opacity(ctx, doc, base_uri, dict, opacity_att, NULL);
}
static void
-xps_paint_visual_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_paint_visual_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root, void *visual_tag)
{
xps_parse_element(ctx, doc, ctm, area, base_uri, dict, (fz_xml *)visual_tag);
}
void
-xps_parse_visual_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area,
+xps_parse_visual_brush(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area,
char *base_uri, xps_resource *dict, fz_xml *root)
{
fz_xml *node;
@@ -249,7 +244,7 @@ xps_parse_visual_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
}
void
-xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *root)
+xps_parse_canvas(fz_context *ctx, xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, xps_resource *dict, fz_xml *root)
{
fz_device *dev = doc->dev;
xps_resource *new_dict = NULL;
@@ -265,8 +260,6 @@ xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const
fz_xml *clip_tag = NULL;
fz_xml *opacity_mask_tag = NULL;
- fz_matrix local_ctm;
-
transform_att = fz_xml_att(root, "RenderTransform");
clip_att = fz_xml_att(root, "Clip");
opacity_att = fz_xml_att(root, "Opacity");
@@ -306,15 +299,15 @@ xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const
xps_resolve_resource_reference(ctx, doc, dict, &clip_att, &clip_tag, NULL);
xps_resolve_resource_reference(ctx, doc, dict, &opacity_mask_att, &opacity_mask_tag, &opacity_mask_uri);
- xps_parse_transform(ctx, doc, transform_att, transform_tag, &local_ctm, ctm);
+ ctm = xps_parse_transform(ctx, doc, transform_att, transform_tag, ctm);
if (clip_att || clip_tag)
- xps_clip(ctx, doc, &local_ctm, dict, clip_att, clip_tag);
+ xps_clip(ctx, doc, ctm, dict, clip_att, clip_tag);
- xps_begin_opacity(ctx, doc, &local_ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
+ xps_begin_opacity(ctx, doc, ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
for (node = fz_xml_down(root); node; node = fz_xml_next(node))
- xps_parse_element(ctx, doc, &local_ctm, area, base_uri, dict, node);
+ xps_parse_element(ctx, doc, ctm, area, base_uri, dict, node);
xps_end_opacity(ctx, doc, opacity_mask_uri, dict, opacity_att, opacity_mask_tag);
@@ -329,14 +322,13 @@ xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const
}
void
-xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_page *page)
+xps_parse_fixed_page(fz_context *ctx, xps_document *doc, fz_matrix ctm, xps_page *page)
{
fz_xml *root, *node;
xps_resource *dict;
char base_uri[1024];
fz_rect area;
char *s;
- fz_matrix scm;
fz_strlcpy(base_uri, page->fix->name, sizeof base_uri);
s = strrchr(base_uri, '/');
@@ -352,8 +344,7 @@ xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, x
if (!root)
return;
- area = fz_unit_rect;
- fz_transform_rect(&area, fz_scale(&scm, page->fix->width, page->fix->height));
+ area = fz_transform_rect(fz_unit_rect, fz_scale(page->fix->width, page->fix->height));
fz_try(ctx)
{
@@ -366,7 +357,7 @@ xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, x
else
dict = xps_parse_resource_dictionary(ctx, doc, base_uri, fz_xml_down(node));
}
- xps_parse_element(ctx, doc, ctm, &area, base_uri, dict, node);
+ xps_parse_element(ctx, doc, ctm, area, base_uri, dict, node);
}
}
fz_always(ctx)
@@ -380,13 +371,13 @@ xps_run_page(fz_context *ctx, fz_page *page_, fz_device *dev, const fz_matrix *c
{
xps_page *page = (xps_page*)page_;
xps_document *doc = page->doc;
- fz_matrix page_ctm = *ctm;
+ fz_matrix page_ctm;
- fz_pre_scale(&page_ctm, 72.0f / 96.0f, 72.0f / 96.0f);
+ page_ctm = fz_pre_scale(*ctm, 72.0f / 96.0f, 72.0f / 96.0f);
doc->cookie = cookie;
doc->dev = dev;
- xps_parse_fixed_page(ctx, doc, &page_ctm, page);
+ xps_parse_fixed_page(ctx, doc, page_ctm, page);
doc->cookie = NULL;
doc->dev = NULL;
}