summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-04-30 11:32:05 +0200
committerRobin Watts <robin.watts@artifex.com>2013-04-30 15:55:25 +0100
commita61bb97a5ddbf63472044447f10ee6b3bd336ed8 (patch)
tree4c0ae6af74b61aee25f483b79088b4299d67e415 /fitz
parentc5fe69a30dc09a094c6f8237b7f8bf72dc1768b0 (diff)
downloadmupdf-a61bb97a5ddbf63472044447f10ee6b3bd336ed8.tar.xz
Move fz_normalize_vector into base_geometry.c
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_geometry.c12
-rw-r--r--fitz/fitz.h5
-rw-r--r--fitz/text_extract.c18
-rw-r--r--fitz/text_paragraph.c16
4 files changed, 22 insertions, 29 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c
index 7f589ff5..4819c930 100644
--- a/fitz/base_geometry.c
+++ b/fitz/base_geometry.c
@@ -260,6 +260,18 @@ fz_transform_vector(fz_point *restrict p, const fz_matrix *restrict m)
return p;
}
+void
+fz_normalize_vector(fz_point *p)
+{
+ float len = p->x * p->x + p->y * p->y;
+ if (len != 0)
+ {
+ len = sqrtf(len);
+ p->x /= len;
+ p->y /= len;
+ }
+}
+
/* Rectangles and bounding boxes */
/* biggest and smallest integers that a float can represent perfectly (i.e. 24 bits) */
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 8822437b..ac3bb246 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -1222,6 +1222,11 @@ fz_point *fz_transform_vector(fz_point *restrict vector, const fz_matrix *restri
fz_rect *fz_transform_rect(fz_rect *restrict rect, const fz_matrix *restrict transform);
/*
+ fz_normalize_vector: Normalize a vector to length one.
+*/
+void fz_normalize_vector(fz_point *p);
+
+/*
fz_buffer is a wrapper around a dynamically allocated array of bytes.
Buffers have a capacity (the number of bytes storage immediately
diff --git a/fitz/text_extract.c b/fitz/text_extract.c
index 259fd690..a2c3947a 100644
--- a/fitz/text_extract.c
+++ b/fitz/text_extract.c
@@ -252,18 +252,6 @@ dump_line(fz_text_line *line)
}
#endif
-static inline void
-normalise(fz_point *p)
-{
- float len = p->x * p->x + p->y * p->y;
- if (len != 0)
- {
- len = sqrtf(len);
- p->x /= len;
- p->y /= len;
- }
-}
-
static void
strain_soup(fz_context *ctx, fz_text_device *tdev)
{
@@ -300,10 +288,10 @@ strain_soup(fz_context *ctx, fz_text_device *tdev)
p.x = last_line->spans[0]->max.x - last_line->spans[0]->min.x;
p.y = last_line->spans[0]->max.y - last_line->spans[0]->min.y;
- normalise(&p);
+ fz_normalize_vector(&p);
q.x = span->max.x - span->min.x;
q.y = span->max.y - span->min.y;
- normalise(&q);
+ fz_normalize_vector(&q);
#ifdef DEBUG_SPANS
printf("last_span=%g %g -> %g %g = %g %g\n", last_span->min.x, last_span->min.y, last_span->max.x, last_span->max.y, p.x, p.y);
printf("span =%g %g -> %g %g = %g %g\n", span->min.x, span->min.y, span->max.x, span->max.y, q.x, q.y);
@@ -566,7 +554,7 @@ fz_add_text_char_imp(fz_context *ctx, fz_text_device *dev, fz_text_style *style,
}
fz_transform_vector(&dir, trm);
ndir = dir;
- normalise(&ndir);
+ fz_normalize_vector(&ndir);
/* dir = direction vector for motion. ndir = normalised(dir) */
size = fz_matrix_expansion(trm);
diff --git a/fitz/text_paragraph.c b/fitz/text_paragraph.c
index d303cb30..b7828a81 100644
--- a/fitz/text_paragraph.c
+++ b/fitz/text_paragraph.c
@@ -11,18 +11,6 @@
#undef SPOT_LINE_NUMBERS
-static inline void
-normalise(fz_point *p)
-{
- float len = p->x * p->x + p->y * p->y;
- if (len != 0)
- {
- len = sqrtf(len);
- p->x /= len;
- p->y /= len;
- }
-}
-
typedef struct line_height_s
{
float height;
@@ -1199,7 +1187,7 @@ force_paragraph:
blv = line->spans[0]->max;
blv.x -= line->spans[0]->min.x;
blv.y -= line->spans[0]->min.y;
- normalise(&blv);
+ fz_normalize_vector(&blv);
rm = new_region_mask(ctx, &blv);
for (span_num = 0; span_num < line->len; span_num++)
@@ -1284,7 +1272,7 @@ force_paragraph:
blv = line->spans[0]->max;
blv.x -= line->spans[0]->min.x;
blv.y -= line->spans[0]->min.y;
- normalise(&blv);
+ fz_normalize_vector(&blv);
#ifdef DEBUG_MASKS
dump_line(line);