diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/draw-path.c | 14 | ||||
-rw-r--r-- | source/fitz/filter-sgi.c | 10 | ||||
-rw-r--r-- | source/fitz/geometry.c | 8 | ||||
-rw-r--r-- | source/fitz/shade.c | 2 | ||||
-rw-r--r-- | source/fitz/stext-paragraph.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-function.c | 8 | ||||
-rw-r--r-- | source/svg/svg-parse.c | 6 | ||||
-rw-r--r-- | source/svg/svg-run.c | 10 | ||||
-rw-r--r-- | source/xps/xps-path.c | 10 |
9 files changed, 32 insertions, 38 deletions
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c index 0dec60b8..fe140a56 100644 --- a/source/fitz/draw-path.c +++ b/source/fitz/draw-path.c @@ -338,20 +338,20 @@ fz_add_arc(fz_context *ctx, sctx *s, int n, i; r = fabsf(s->linewidth); - theta = 2 * (float)M_SQRT2 * sqrtf(s->flatness / r); + theta = 2 * FZ_SQRT2 * sqrtf(s->flatness / r); th0 = atan2f(y0, x0); th1 = atan2f(y1, x1); if (r > 0) { if (th0 < th1) - th0 += (float)M_PI * 2; + th0 += FZ_PI * 2; n = ceilf((th0 - th1) / theta); } else { if (th1 < th0) - th1 += (float)M_PI * 2; + th1 += FZ_PI * 2; n = ceilf((th1 - th0) / theta); } @@ -549,12 +549,12 @@ fz_add_line_cap(fz_context *ctx, sctx *s, float ax, float ay, float bx, float by case FZ_LINECAP_ROUND: { int i; - int n = ceilf((float)M_PI / (2.0f * (float)M_SQRT2 * sqrtf(flatness / linewidth))); + int n = ceilf(FZ_PI / (2.0f * FZ_SQRT2 * sqrtf(flatness / linewidth))); float ox = bx - dlx; float oy = by - dly; for (i = 1; i < n; i++) { - float theta = (float)M_PI * i / n; + float theta = FZ_PI * i / n; float cth = cosf(theta); float sth = sinf(theta); float nx = bx - dlx * cth - dly * sth; @@ -595,7 +595,7 @@ fz_add_line_dot(fz_context *ctx, sctx *s, float ax, float ay) { float flatness = s->flatness; float linewidth = s->linewidth; - int n = ceilf((float)M_PI / ((float)M_SQRT2 * sqrtf(flatness / linewidth))); + int n = ceilf(FZ_PI / (FZ_SQRT2 * sqrtf(flatness / linewidth))); float ox = ax - linewidth; float oy = ay; int i; @@ -604,7 +604,7 @@ fz_add_line_dot(fz_context *ctx, sctx *s, float ax, float ay) n = 3; for (i = 1; i < n; i++) { - float theta = (float)M_PI * 2 * i / n; + float theta = FZ_PI * 2 * i / n; float cth = cosf(theta); float sth = sinf(theta); float nx = ax - cth * linewidth; diff --git a/source/fitz/filter-sgi.c b/source/fitz/filter-sgi.c index c0946df2..518751ed 100644 --- a/source/fitz/filter-sgi.c +++ b/source/fitz/filter-sgi.c @@ -180,10 +180,6 @@ static struct { { 0.023659f, 21, 16268 }, }; -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif - /* SGI Log 16bit (greyscale) */ typedef struct fz_sgilog16_s fz_sgilog16; @@ -206,7 +202,7 @@ sgilog16val(fz_context *ctx, uint16_t v) Y = 0; else { - Y = expf(M_LN2/256 * (Le + .5f) - M_LN2*64); + Y = expf(FZ_LN2/256 * (Le + .5f) - FZ_LN2*64); if (v & 0x8000) Y = -Y; } @@ -401,7 +397,7 @@ sgilog24val(fz_context *ctx, fz_stream *chain, uint8_t *rgb) /* decode luminance */ p = (luv>>14) & 0x3ff; - Y = (p == 0 ? 0 : expf(M_LN2/64*(p+.5f) - M_LN2*12)); + Y = (p == 0 ? 0 : expf(FZ_LN2/64*(p+.5f) - FZ_LN2*12)); if (Y <= 0) { X = Y = Z = 0; @@ -532,7 +528,7 @@ sgilog32val(fz_context *ctx, uint32_t p, uint8_t *rgb) else { int Le = (p>>16) & 0x7fff; - Y = !Le ? 0 : expf(M_LN2/256*(Le+.5f) - M_LN2*64); + Y = !Le ? 0 : expf(FZ_LN2/256*(Le+.5f) - FZ_LN2*64); /* decode color */ u = (1.f/UVSCALE) * ((p>>8 & 0xff) + .5f); v = (1.f/UVSCALE) * ((p & 0xff) + .5f); diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c index 1940b417..64abd5c4 100644 --- a/source/fitz/geometry.c +++ b/source/fitz/geometry.c @@ -128,8 +128,8 @@ fz_rotate(fz_matrix *m, float theta) } else { - s = sinf(theta * (float)M_PI / 180); - c = cosf(theta * (float)M_PI / 180); + s = sinf(theta * FZ_PI / 180); + c = cosf(theta * FZ_PI / 180); } m->a = c; m->b = s; @@ -177,8 +177,8 @@ fz_pre_rotate(fz_matrix *m, float theta) } else { - float s = sinf(theta * (float)M_PI / 180); - float c = cosf(theta * (float)M_PI / 180); + float s = sinf(theta * FZ_PI / 180); + float c = cosf(theta * FZ_PI / 180); float a = m->a; float b = m->b; m->a = c * a + s * m->c; diff --git a/source/fitz/shade.c b/source/fitz/shade.c index b7e746d7..13788472 100644 --- a/source/fitz/shade.c +++ b/source/fitz/shade.c @@ -201,7 +201,7 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm, int i; theta = atan2f(p1.y - p0.y, p1.x - p0.x); - step = (float)M_PI / count; + step = FZ_PI / count; a = 0; for (i = 1; i <= count; i++) diff --git a/source/fitz/stext-paragraph.c b/source/fitz/stext-paragraph.c index 0a717c1b..b28cb200 100644 --- a/source/fitz/stext-paragraph.c +++ b/source/fitz/stext-paragraph.c @@ -61,7 +61,7 @@ insert_line_height(line_heights *lh, fz_stext_style *style, float height) for (i=0; i < lh->len; i++) { /* Match if we are within 5% */ - if (lh->lh[i].style == style && lh->lh[i].height * 0.95 <= height && lh->lh[i].height * 1.05 >= height) + if (lh->lh[i].style == style && lh->lh[i].height * 0.95f <= height && lh->lh[i].height * 1.05f >= height) { /* Ensure that the average height is correct */ lh->lh[i].height = (lh->lh[i].height * lh->lh[i].count + height) / (lh->lh[i].count+1); diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c index 1c1b4454..1e53291e 100644 --- a/source/pdf/pdf-function.c +++ b/source/pdf/pdf-function.c @@ -84,8 +84,6 @@ pdf_function_size(fz_context *ctx, pdf_function *func) return (func ? func->size : 0); } -#define RADIAN 57.2957795 - static inline float lerp(float x, float xmin, float xmax, float ymin, float ymax) { if (xmin == xmax) @@ -383,7 +381,7 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_ATAN: r2 = ps_pop_real(st); r1 = ps_pop_real(st); - r1 = atan2f(r1, r2) * RADIAN; + r1 = atan2f(r1, r2) * FZ_RADIAN; if (r1 < 0) r1 += 360; ps_push_real(st, r1); @@ -411,7 +409,7 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_COS: r1 = ps_pop_real(st); - ps_push_real(st, cosf(r1/RADIAN)); + ps_push_real(st, cosf(r1/FZ_RADIAN)); break; case PS_OP_CVI: @@ -636,7 +634,7 @@ ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc) case PS_OP_SIN: r1 = ps_pop_real(st); - ps_push_real(st, sinf(r1/RADIAN)); + ps_push_real(st, sinf(r1/FZ_RADIAN)); break; case PS_OP_SQRT: diff --git a/source/svg/svg-parse.c b/source/svg/svg-parse.c index a400e5a5..51746e6c 100644 --- a/source/svg/svg-parse.c +++ b/source/svg/svg-parse.c @@ -111,7 +111,7 @@ svg_parse_angle(const char *str) return val * 0.9; if (!strcmp(end, "rad")) - return val * 57.2957795; + return val * FZ_RADIAN; return val; } @@ -251,7 +251,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr m.a = 1; m.b = 0; - m.c = tanf(args[0] * 0.0174532925); + m.c = tanf(args[0] * FZ_DEGREE); m.d = 1; m.e = 0; m.f = 0; @@ -267,7 +267,7 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix *tr fz_throw(ctx, FZ_ERROR_SYNTAX, "wrong number of arguments to skewY(): %d", nargs); m.a = 1; - m.b = tanf(args[0] * 0.0174532925); + m.b = tanf(args[0] * FZ_DEGREE); m.c = 0; m.d = 1; m.e = 0; diff --git a/source/svg/svg-run.c b/source/svg/svg-run.c index d113fd13..eead3b12 100644 --- a/source/svg/svg-run.c +++ b/source/svg/svg-run.c @@ -322,9 +322,9 @@ svg_add_arc_segment(fz_context *ctx, fz_path *path, const fz_matrix *mtx, float fz_point p; while (th1 < th0) - th1 += (float)M_PI * 2; + th1 += FZ_PI * 2; - d = (float)M_PI / 180; /* 1-degree precision */ + d = FZ_PI / 180; /* 1-degree precision */ if (iscw) { @@ -336,7 +336,7 @@ svg_add_arc_segment(fz_context *ctx, fz_path *path, const fz_matrix *mtx, float } else { - th0 += (float)M_PI * 2; + th0 += FZ_PI * 2; for (t = th0 - d; t > th1 + d/2; t -= d) { fz_transform_point_xy(&p, mtx, cosf(t), sinf(t)); @@ -452,9 +452,9 @@ svg_add_arc(fz_context *ctx, fz_path *path, th1 = angle_between(coord1, coord2); dth = angle_between(coord3, coord4); if (dth < 0 && !is_clockwise) - dth += (((float)M_PI / 180) * 360); + dth += ((FZ_PI / 180) * 360); if (dth > 0 && is_clockwise) - dth -= (((float)M_PI / 180) * 360); + dth -= ((FZ_PI / 180) * 360); } fz_pre_scale(fz_pre_rotate(fz_translate(&mtx, cx, cy), rotation_angle), rx, ry); diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c index 731ffe9c..c60934a2 100644 --- a/source/xps/xps-path.c +++ b/source/xps/xps-path.c @@ -55,9 +55,9 @@ xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz fz_point p; while (th1 < th0) - th1 += (float)M_PI * 2; + th1 += FZ_PI * 2; - d = (float)M_PI / 180; /* 1-degree precision */ + d = FZ_PI / 180; /* 1-degree precision */ if (iscw) { @@ -69,7 +69,7 @@ xps_draw_arc_segment(fz_context *ctx, xps_document *doc, fz_path *path, const fz } else { - th0 += (float)M_PI * 2; + th0 += FZ_PI * 2; for (t = th0 - d; t > th1 + d/2; t -= d) { fz_transform_point_xy(&p, mtx, cosf(t), sinf(t)); @@ -202,9 +202,9 @@ xps_draw_arc(fz_context *ctx, xps_document *doc, fz_path *path, th1 = angle_between(coord1, coord2); dth = angle_between(coord3, coord4); if (dth < 0 && !is_clockwise) - dth += (((float)M_PI / 180) * 360); + dth += ((FZ_PI / 180) * 360); if (dth > 0 && is_clockwise) - dth -= (((float)M_PI / 180) * 360); + dth -= ((FZ_PI / 180) * 360); } fz_pre_scale(fz_pre_rotate(fz_translate(&mtx, cx, cy), rotation_angle), rx, ry); |