diff options
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_font.c | 2 | ||||
-rw-r--r-- | pdf/pdf_function.c | 40 | ||||
-rw-r--r-- | pdf/pdf_lex.c | 35 | ||||
-rw-r--r-- | pdf/pdf_shade.c | 16 |
4 files changed, 40 insertions, 53 deletions
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index b19b516e..448ab330 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -105,7 +105,7 @@ static int ft_char_index(FT_Face face, int cid) return gid; } -static inline int ft_cid_to_gid(pdf_font_desc *fontdesc, int cid) +static int ft_cid_to_gid(pdf_font_desc *fontdesc, int cid) { if (fontdesc->to_ttf_cmap) { diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index c08c5e5b..6237bd42 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -59,7 +59,7 @@ struct pdf_function_s #define RADIAN 57.2957795 -static inline float LERP(float x, float xmin, float xmax, float ymin, float ymax) +static inline float lerp(float x, float xmin, float xmax, float ymin, float ymax) { if (xmin == xmax) return ymin; @@ -76,13 +76,15 @@ enum { PS_BOOL, PS_INT, PS_REAL, PS_OPERATOR, PS_BLOCK }; enum { - PS_OP_ABS, PS_OP_ADD, PS_OP_AND, PS_OP_ATAN, PS_OP_BITSHIFT, PS_OP_CEILING, - PS_OP_COPY, PS_OP_COS, PS_OP_CVI, PS_OP_CVR, PS_OP_DIV, PS_OP_DUP, PS_OP_EQ, - PS_OP_EXCH, PS_OP_EXP, PS_OP_FALSE, PS_OP_FLOOR, PS_OP_GE, PS_OP_GT, PS_OP_IDIV, - PS_OP_INDEX, PS_OP_LE, PS_OP_LN, PS_OP_LOG, PS_OP_LT, PS_OP_MOD, PS_OP_MUL, - PS_OP_NE, PS_OP_NEG, PS_OP_NOT, PS_OP_OR, PS_OP_POP, PS_OP_ROLL, PS_OP_ROUND, - PS_OP_SIN, PS_OP_SQRT, PS_OP_SUB, PS_OP_TRUE, PS_OP_TRUNCATE, PS_OP_XOR, - PS_OP_IF, PS_OP_IFELSE, PS_OP_RETURN + PS_OP_ABS, PS_OP_ADD, PS_OP_AND, PS_OP_ATAN, PS_OP_BITSHIFT, + PS_OP_CEILING, PS_OP_COPY, PS_OP_COS, PS_OP_CVI, PS_OP_CVR, + PS_OP_DIV, PS_OP_DUP, PS_OP_EQ, PS_OP_EXCH, PS_OP_EXP, + PS_OP_FALSE, PS_OP_FLOOR, PS_OP_GE, PS_OP_GT, PS_OP_IDIV, + PS_OP_INDEX, PS_OP_LE, PS_OP_LN, PS_OP_LOG, PS_OP_LT, PS_OP_MOD, + PS_OP_MUL, PS_OP_NE, PS_OP_NEG, PS_OP_NOT, PS_OP_OR, PS_OP_POP, + PS_OP_ROLL, PS_OP_ROUND, PS_OP_SIN, PS_OP_SQRT, PS_OP_SUB, + PS_OP_TRUE, PS_OP_TRUNCATE, PS_OP_XOR, PS_OP_IF, PS_OP_IFELSE, + PS_OP_RETURN }; static char *ps_op_names[] = @@ -154,26 +156,22 @@ ps_init_stack(ps_stack *st) st->sp = 0; } -static inline int -ps_overflow(ps_stack *st, int n) +static inline int ps_overflow(ps_stack *st, int n) { return n < 0 || st->sp + n >= nelem(st->stack); } -static inline int -ps_underflow(ps_stack *st, int n) +static inline int ps_underflow(ps_stack *st, int n) { return n < 0 || st->sp - n < 0; } -static inline int -ps_is_type(ps_stack *st, int t) +static inline int ps_is_type(ps_stack *st, int t) { return !ps_underflow(st, 1) && st->stack[st->sp - 1].type == t; } -static inline int -ps_is_type2(ps_stack *st, int t) +static inline int ps_is_type2(ps_stack *st, int t) { return !ps_underflow(st, 2) && st->stack[st->sp - 1].type == t && st->stack[st->sp - 2].type == t; } @@ -1052,7 +1050,7 @@ eval_sample_func(pdf_function *func, float *in, float *out) for (i = 0; i < func->m; i++) { x = CLAMP(in[i], func->domain[i][0], func->domain[i][1]); - x = LERP(x, func->domain[i][0], func->domain[i][1], + x = lerp(x, func->domain[i][0], func->domain[i][1], func->u.sa.encode[i][0], func->u.sa.encode[i][1]); x = CLAMP(x, 0, func->u.sa.size[i] - 1); e0[i] = floorf(x); @@ -1073,7 +1071,7 @@ eval_sample_func(pdf_function *func, float *in, float *out) float ab = a + (b - a) * efrac[0]; - out[i] = LERP(ab, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); + out[i] = lerp(ab, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } @@ -1091,14 +1089,14 @@ eval_sample_func(pdf_function *func, float *in, float *out) float cd = c + (d - c) * efrac[0]; float abcd = ab + (cd - ab) * efrac[1]; - out[i] = LERP(abcd, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); + out[i] = lerp(abcd, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } else { float x = interpolate_sample(func, scale, e0, e1, efrac, func->m - 1, i); - out[i] = LERP(x, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); + out[i] = lerp(x, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } } @@ -1303,7 +1301,7 @@ eval_stitching_func(pdf_function *func, float in, float *out) high = bounds[i]; } - in = LERP(in, low, high, func->u.st.encode[i*2+0], func->u.st.encode[i*2+1]); + in = lerp(in, low, high, func->u.st.encode[i*2+0], func->u.st.encode[i*2+1]); pdf_eval_function(func->u.st.funcs[i], &in, 1, out, func->n); } diff --git a/pdf/pdf_lex.c b/pdf/pdf_lex.c index bb0e6e32..31d8a825 100644 --- a/pdf/pdf_lex.c +++ b/pdf/pdf_lex.c @@ -23,8 +23,7 @@ #define RANGE_A_F \ 'A':case'B':case'C':case'D':case'E':case'F' -static inline int -iswhite(int ch) +static inline int iswhite(int ch) { return ch == '\000' || @@ -35,40 +34,32 @@ iswhite(int ch) ch == '\040'; } -static inline int -from_hex(int ch) +static inline int unhex(int ch) { - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 0xA; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 0xA; + if (ch >= '0' && ch <= '9') return ch - '0'; + if (ch >= 'A' && ch <= 'F') return ch - 'A' + 0xA; + if (ch >= 'a' && ch <= 'f') return ch - 'a' + 0xA; return 0; } -static inline void +static void lex_white(fz_stream *f) { int c; - do - { + do { c = fz_read_byte(f); - } - while ((c <= 32) && (iswhite(c))); + } while ((c <= 32) && (iswhite(c))); if (c != EOF) fz_unread_byte(f); } -static inline void +static void lex_comment(fz_stream *f) { int c; - do - { + do { c = fz_read_byte(f); - } - while ((c != '\012') && (c != '\015') && (c != EOF)); + } while ((c != '\012') && (c != '\015') && (c != EOF)); } static int @@ -329,12 +320,12 @@ lex_hex_string(fz_stream *f, char *buf, int n) case IS_HEX: if (x) { - *s++ = a * 16 + from_hex(c); + *s++ = a * 16 + unhex(c); x = !x; } else { - a = from_hex(c); + a = unhex(c); x = !x; } break; diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c index aded5154..1e0bf5ff 100644 --- a/pdf/pdf_shade.c +++ b/pdf/pdf_shade.c @@ -95,15 +95,14 @@ triangulate_patch(pdf_tensor_patch p, fz_shade *shade) pdf_add_quad(shade, &v0, &v1, &v2, &v3); } -static inline void -midcolor(float *c, float *c1, float *c2) +static inline void midcolor(float *c, float *c1, float *c2) { int i; for (i = 0; i < FZ_MAX_COLORS; i++) c[i] = (c1[i] + c2[i]) * 0.5f; } -static inline void +static void split_curve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep) { /* @@ -139,7 +138,7 @@ split_curve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep) q1[3 * polestep].y = pole[3 * polestep].y; } -static inline void +static void split_stripe(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* @@ -186,7 +185,7 @@ draw_stripe(pdf_tensor_patch *p, fz_shade *shade, int depth) } } -static inline void +static void split_patch(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* @@ -233,7 +232,7 @@ draw_patch(fz_shade *shade, pdf_tensor_patch *p, int depth, int origdepth) } } -static inline fz_point +static fz_point pdf_compute_tensor_interior( fz_point a, fz_point b, fz_point c, fz_point d, fz_point e, fz_point f, fz_point g, fz_point h) @@ -259,7 +258,7 @@ pdf_compute_tensor_interior( return pt; } -static inline void +static void pdf_make_tensor_patch(pdf_tensor_patch *p, int type, fz_point *pt) { if (type == 6) @@ -531,8 +530,7 @@ pdf_load_radial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs /* Type 4-7 -- Triangle and patch mesh shadings */ -static inline float -read_sample(fz_stream *stream, int bits, float min, float max) +static inline float read_sample(fz_stream *stream, int bits, float min, float max) { /* we use pow(2,x) because (1<<x) would overflow the math on 32-bit samples */ float bitscale = 1 / (powf(2, bits) - 1); |