summaryrefslogtreecommitdiff
path: root/source/svg/svg-parse.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-06-25 13:15:50 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-07-05 15:32:34 +0200
commit4a99615a609eec2b84bb2341d74fac46a5998137 (patch)
tree486eacff07448e4c655df1fa1bcb20df709dd8df /source/svg/svg-parse.c
parent2aa62902447760764e7a763dea322145d9c4808c (diff)
downloadmupdf-4a99615a609eec2b84bb2341d74fac46a5998137.tar.xz
Pass rect and matrix by value in geometry functions.
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
Diffstat (limited to 'source/svg/svg-parse.c')
-rw-r--r--source/svg/svg-parse.c14
1 files changed, 7 insertions, 7 deletions
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