summaryrefslogtreecommitdiff
path: root/pdf/pdf_xobject.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-01-25 19:24:49 +0000
committerRobin Watts <robin.watts@artifex.com>2013-02-06 19:24:12 +0000
commitd3aa37962470253083714b5092a1ba759f674d47 (patch)
treeec60a0857cd3d44d3db5bc0c95aa69335b6b2d47 /pdf/pdf_xobject.c
parentc42dac496e0994c4253eb50ce67ceaec864ed379 (diff)
downloadmupdf-d3aa37962470253083714b5092a1ba759f674d47.tar.xz
Change to pass structures by reference rather than value.
This is faster on ARM in particular. The primary changes involve fz_matrix, fz_rect and fz_bbox. Rather than passing 'fz_rect r' into a function, we now consistently pass 'const fz_rect *r'. Where a rect is passed in and modified, we miss the 'const' off. Where possible, we return the pointer to the modified structure to allow 'chaining' of expressions. The basic upshot of this work is that we do far fewer copies of rectangle/matrix structures, and all the copies we do are explicit. This has opened the way to other optimisations, also performed in this commit. Rather than using expressions like: fz_concat(fz_scale(sx, sy), fz_translate(tx, ty)) we now have fz_pre_{scale,translate,rotate} functions. These can be implemented much more efficiently than doing the fully fledged matrix multiplication that fz_concat requires. We add fz_rect_{min,max} functions to return pointers to the min/max points of a rect. These can be used to in transformations to directly manipulate values. With a little casting in the path transformation code we can avoid more needless copying. We rename fz_widget_bbox to the more consistent fz_bound_widget.
Diffstat (limited to 'pdf/pdf_xobject.c')
-rw-r--r--pdf/pdf_xobject.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c
index 17d8300f..a334392f 100644
--- a/pdf/pdf_xobject.c
+++ b/pdf/pdf_xobject.c
@@ -60,11 +60,11 @@ pdf_load_xobject(pdf_document *xref, pdf_obj *dict)
fz_try(ctx)
{
obj = pdf_dict_gets(dict, "BBox");
- form->bbox = pdf_to_rect(ctx, obj);
+ pdf_to_rect(ctx, obj, &form->bbox);
obj = pdf_dict_gets(dict, "Matrix");
if (obj)
- form->matrix = pdf_to_matrix(ctx, obj);
+ pdf_to_matrix(ctx, obj, &form->matrix);
else
form->matrix = fz_identity;
@@ -111,7 +111,7 @@ pdf_load_xobject(pdf_document *xref, pdf_obj *dict)
}
pdf_obj *
-pdf_new_xobject(pdf_document *xref, fz_rect bbox, fz_matrix mat)
+pdf_new_xobject(pdf_document *xref, const fz_rect *bbox, const fz_matrix *mat)
{
int idict_num;
pdf_obj *idict = NULL;
@@ -185,9 +185,9 @@ pdf_new_xobject(pdf_document *xref, fz_rect bbox, fz_matrix mat)
form->me = NULL;
form->iteration = 0;
- form->bbox = bbox;
+ form->bbox = *bbox;
- form->matrix = mat;
+ form->matrix = *mat;
form->isolated = 0;
form->knockout = 0;