summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-02-20 21:56:37 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-02-27 14:08:02 +0100
commitbcfee39b0ab6de6a5fa223f1e204a35e39a92bb4 (patch)
tree059d14395fdc2b49c52380e9c9ff9e2553e6443a
parent6f199ed40fdeab280e745502fa0de13d814b9343 (diff)
downloadmupdf-bcfee39b0ab6de6a5fa223f1e204a35e39a92bb4.tar.xz
Add convenience functions to create point/rect/matrix.
In the absence of C99 (fz_rect){0,0,1,1} syntax, this will have to do.
-rw-r--r--include/mupdf/fitz/geometry.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/mupdf/fitz/geometry.h b/include/mupdf/fitz/geometry.h
index 0667c3ee..f1f1501f 100644
--- a/include/mupdf/fitz/geometry.h
+++ b/include/mupdf/fitz/geometry.h
@@ -125,6 +125,12 @@ struct fz_point_s
float x, y;
};
+static inline fz_point fz_make_point(float x, float y)
+{
+ fz_point p = { x, y };
+ return p;
+}
+
/*
fz_rect is a rectangle represented by two diagonally opposite
corners at arbitrary coordinates.
@@ -150,6 +156,12 @@ struct fz_rect_s
float x1, y1;
};
+static inline fz_rect fz_make_rect(float x0, float y0, float x1, float y1)
+{
+ fz_rect r = { x0, y0, x1, y1 };
+ return r;
+}
+
/*
fz_rect_min: get the minimum point from a rectangle as a fz_point.
*/
@@ -178,6 +190,12 @@ struct fz_irect_s
int x1, y1;
};
+static inline fz_irect fz_make_irect(int x0, int y0, int x1, int y1)
+{
+ fz_irect r = { x0, y0, x1, y1 };
+ return r;
+}
+
/*
A rectangle with sides of length one.
@@ -269,6 +287,12 @@ struct fz_matrix_s
*/
extern const fz_matrix fz_identity;
+static inline fz_matrix fz_make_matrix(float a, float b, float c, float d, float e, float f)
+{
+ fz_matrix m = { a, b, c, d, e, f };
+ return m;
+}
+
static inline fz_matrix *fz_copy_matrix(fz_matrix *restrict m, const fz_matrix *restrict s)
{
*m = *s;