diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-02-17 15:46:52 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-02-17 16:36:06 +0100 |
commit | d3e3c894673a72753ba9cea5786ab7fbff78e2e8 (patch) | |
tree | 7668b227a0abef2d4e3018c5e42d4f24ee94c633 /source/fitz | |
parent | 41084f0023df8706fadfa2e2b6373ec03a7c7ca4 (diff) | |
download | mupdf-d3e3c894673a72753ba9cea5786ab7fbff78e2e8.tar.xz |
Add fz_transform_point_xy to simplify transforming a point.
Many times, the idiom p.x = x; p.y = y; fz_transform_point() is used.
This function should simplify that use case by both initializing and
transforming the point in one call.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/font.c | 28 | ||||
-rw-r--r-- | source/fitz/geometry.c | 8 |
2 files changed, 15 insertions, 21 deletions
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; |