summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/math.h1
-rw-r--r--source/fitz/font.c28
-rw-r--r--source/fitz/geometry.c8
-rw-r--r--source/xps/xps-path.c8
4 files changed, 18 insertions, 27 deletions
diff --git a/include/mupdf/fitz/math.h b/include/mupdf/fitz/math.h
index b2a5cd4a..54c8f0c8 100644
--- a/include/mupdf/fitz/math.h
+++ b/include/mupdf/fitz/math.h
@@ -561,6 +561,7 @@ fz_irect *fz_translate_irect(fz_irect *a, int xoff, int yoff);
Does not throw exceptions.
*/
fz_point *fz_transform_point(fz_point *restrict point, const fz_matrix *restrict transform);
+fz_point *fz_transform_point_xy(fz_point *restrict point, const fz_matrix *restrict transform, float x, float y);
/*
fz_transform_vector: Apply a transformation to a vector.
diff --git a/source/fitz/font.c b/source/fitz/font.c
index e8c6fa00..45d75f95 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -884,9 +884,7 @@ static int move_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- pt.x = p->x;
- pt.y = p->y;
- fz_transform_point(&pt, &cc->trm);
+ fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
fz_moveto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -898,9 +896,7 @@ static int line_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- pt.x = p->x;
- pt.y = p->y;
- fz_transform_point(&pt, &cc->trm);
+ fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
fz_lineto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -913,12 +909,8 @@ static int conic_to(const FT_Vector *c, const FT_Vector *p, void *cc_)
fz_point ct, pt;
fz_point s, c1, c2;
- ct.x = c->x;
- ct.y = c->y;
- fz_transform_point(&ct, &cc->trm);
- pt.x = p->x;
- pt.y = p->y;
- fz_transform_point(&pt, &cc->trm);
+ fz_transform_point_xy(&ct, &cc->trm, c->x, c->y);
+ fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
s = fz_currentpoint(ctx, path);
c1.x = (s.x + ct.x * 2) / 3;
@@ -937,15 +929,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;
- c1t.x = c1->x;
- c1t.y = c1->y;
- fz_transform_point(&c1t, &cc->trm);
- c2t.x = c2->x;
- c2t.y = c2->y;
- fz_transform_point(&c2t, &cc->trm);
- pt.x = p->x;
- pt.y = p->y;
- fz_transform_point(&pt, &cc->trm);
+ 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);
fz_curveto(ctx, path, c1t.x, c1t.y, c2t.x, c2t.y, pt.x, pt.y);
return 0;
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c
index c7c3d198..f65373b8 100644
--- a/source/fitz/geometry.c
+++ b/source/fitz/geometry.c
@@ -271,6 +271,14 @@ fz_transform_point(fz_point *restrict p, const fz_matrix *restrict m)
}
fz_point *
+fz_transform_point_xy(fz_point *restrict p, const fz_matrix *restrict m, float x, float y)
+{
+ 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 *restrict p, const fz_matrix *restrict m)
{
float x = p->x;
diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c
index ea84a815..84ee53f0 100644
--- a/source/xps/xps-path.c
+++ b/source/xps/xps-path.c
@@ -58,9 +58,7 @@ xps_draw_arc_segment(fz_context *doc, fz_path *path, const fz_matrix *mtx, float
{
for (t = th0 + d; t < th1 - d/2; t += d)
{
- p.x = cosf(t);
- p.y = sinf(t);
- fz_transform_point(&p, mtx);
+ fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
fz_lineto(doc, path, p.x, p.y);
}
}
@@ -69,9 +67,7 @@ xps_draw_arc_segment(fz_context *doc, fz_path *path, const fz_matrix *mtx, float
th0 += (float)M_PI * 2;
for (t = th0 - d; t > th1 + d/2; t -= d)
{
- p.x = cosf(t);
- p.y = sinf(t);
- fz_transform_point(&p, mtx);
+ fz_transform_point_xy(&p, mtx, cosf(t), sinf(t));
fz_lineto(doc, path, p.x, p.y);
}
}