From 7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 4 Apr 2011 23:35:45 +0200 Subject: Le Roi est mort, vive le Roi! The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code. --- draw/arch_arm.c | 6 +- draw/arch_port.c | 4 +- draw/draw_affine.c | 120 +++++++++++++-------------- draw/draw_blend.c | 62 +++++++------- draw/draw_edge.c | 92 ++++++++++----------- draw/draw_glyph.c | 90 ++++++++++----------- draw/draw_mesh.c | 195 ++++++++++++++++++++++---------------------- draw/draw_paint.c | 84 +++++++++---------- draw/draw_path.c | 232 ++++++++++++++++++++++++++--------------------------- draw/draw_scale.c | 48 +++++------ draw/draw_unpack.c | 54 ++++++------- 11 files changed, 493 insertions(+), 494 deletions(-) (limited to 'draw') diff --git a/draw/arch_arm.c b/draw/arch_arm.c index c601a70c..55016a8b 100644 --- a/draw/arch_arm.c +++ b/draw/arch_arm.c @@ -104,7 +104,7 @@ path_w4i1o4_arm(byte * restrict rgba, byte * restrict src, byte cov, int len, by ); } -static void loadtile8_arm(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) +static void load_tile8_arm(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) { if ((h == 0) || (w == 0)) return; @@ -221,10 +221,10 @@ static void loadtile8_arm(byte * restrict src, int sw, byte * restrict dst, int } void -fz_acceleratearch(void) +fz_accelerate_arch(void) { fz_path_w4i1o4 = path_w4i1o4_arm; - fz_loadtile8 = loadtile8_arm; + fz_loadtile8 = load_tile8_arm; fz_srow4 = fz_srow4_arm; fz_scol4 = fz_scol4_arm; } diff --git a/draw/arch_port.c b/draw/arch_port.c index c7be977a..fa5890b5 100644 --- a/draw/arch_port.c +++ b/draw/arch_port.c @@ -471,7 +471,7 @@ img_1o1_32bit(byte * restrict src, byte cov, int len, byte * restrict dst, void fz_accelerate(void) { - if (sizeof(int) == 4 && sizeof(unsigned int) == 4 && !fz_isbigendian()) + if (sizeof(int) == 4 && sizeof(unsigned int) == 4 && !fz_is_big_endian()) { // fz_path_w4i1o4 = path_w4i1o4_32bit; // fz_text_w4i1o4 = text_w4i1o4_32bit; @@ -481,6 +481,6 @@ void fz_accelerate(void) } #ifdef HAVE_CPUDEP - fz_acceleratearch(); + fz_accelerate_arch(); #endif } diff --git a/draw/draw_affine.c b/draw/draw_affine.c index 044b2938..dce2189d 100644 --- a/draw/draw_affine.c +++ b/draw/draw_affine.c @@ -17,7 +17,7 @@ static inline int bilerp(int a, int b, int c, int d, int u, int v) return lerp(lerp(a, b, u), lerp(c, d, u), v); } -static inline byte *samplenearest(byte *s, int w, int h, int n, int u, int v) +static inline byte *sample_nearest(byte *s, int w, int h, int n, int u, int v) { if (u < 0) u = 0; if (v < 0) v = 0; @@ -29,7 +29,7 @@ static inline byte *samplenearest(byte *s, int w, int h, int n, int u, int v) /* Blend premultiplied source image in constant alpha over destination */ static inline void -fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_alpha_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { int k; @@ -41,10 +41,10 @@ fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, n, ui, vi); - byte *b = samplenearest(sp, sw, sh, n, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, n, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, n, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, n, ui, vi); + byte *b = sample_nearest(sp, sw, sh, n, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, n, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, n, ui+1, vi+1); int x = bilerp(a[n-1], b[n-1], c[n-1], d[n-1], uf, vf); int t = 255 - fz_mul255(x, alpha); for (k = 0; k < n; k++) @@ -60,7 +60,7 @@ fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static inline void -fz_paintaffinealphaNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_alpha_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { int k; @@ -84,7 +84,7 @@ fz_paintaffinealphaNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int f /* Blend premultiplied source image over destination */ static inline void -fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) +fz_paint_affine_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) { int k; @@ -96,10 +96,10 @@ fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, n, ui, vi); - byte *b = samplenearest(sp, sw, sh, n, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, n, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, n, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, n, ui, vi); + byte *b = sample_nearest(sp, sw, sh, n, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, n, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, n, ui+1, vi+1); int t = 255 - bilerp(a[n-1], b[n-1], c[n-1], d[n-1], uf, vf); for (k = 0; k < n; k++) { @@ -114,7 +114,7 @@ fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in } static inline void -fz_paintaffineNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) +fz_paint_affine_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) { int k; @@ -138,7 +138,7 @@ fz_paintaffineNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in /* Blend non-premultiplied color in source image mask over destination */ static inline void -fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { int sa = color[n-1]; int k; @@ -151,10 +151,10 @@ fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, 1, ui, vi); - byte *b = samplenearest(sp, sw, sh, 1, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, 1, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, 1, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, 1, ui, vi); + byte *b = sample_nearest(sp, sw, sh, 1, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, 1, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, 1, ui+1, vi+1); int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf); int masa = FZ_COMBINE(FZ_EXPAND(ma), sa); for (k = 0; k < n - 1; k++) @@ -168,7 +168,7 @@ fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static inline void -fz_paintaffinecolorNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { int sa = color[n-1]; int k; @@ -192,81 +192,81 @@ fz_paintaffinecolorNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static void -fz_paintaffinelerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; - case 2: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; - case 4: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; - default: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n); break; + case 1: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; + case 2: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; + case 4: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; + default: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n); break; } } else if (alpha > 0) { switch (n) { - case 1: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; - case 2: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; - case 4: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; - default: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; + case 1: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; + case 2: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; + case 4: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; + default: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; } } } static void -fz_paintaffinenear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; - case 2: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; - case 4: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; - default: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, n); break; + case 1: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; + case 2: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; + case 4: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; + default: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n); break; } } else if (alpha > 0) { switch (n) { - case 1: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; - case 2: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; - case 4: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; - default: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; + case 1: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; + case 2: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; + case 4: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; + default: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; } } } static void -fz_paintaffinecolorlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { switch (n) { - case 2: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; - case 4: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; - default: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; + case 2: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; + case 4: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; + default: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; } } static void -fz_paintaffinecolornear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { switch (n) { - case 2: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; - case 4: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; - default: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; + case 2: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; + case 4: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; + default: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; } } /* Draw an image with an affine transform on destination */ static void -fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha) +fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha) { byte *dp, *sp; int u, v, fa, fb, fc, fd; @@ -277,7 +277,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int dolerp; /* grid fit the image */ - if (fz_isrectilinear(ctm)) + if (fz_is_rectilinear(ctm)) { ctm.a = roundup(ctm.a); ctm.b = roundup(ctm.b); @@ -289,7 +289,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, /* turn on interpolation for upscaled and non-rectilinear transforms */ dolerp = 0; - if (!fz_isrectilinear(ctm)) + if (!fz_is_rectilinear(ctm)) dolerp = 1; if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w) dolerp = 1; @@ -305,8 +305,8 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, dolerp = 0; } - bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect)); - bbox = fz_intersectbbox(bbox, scissor); + bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect)); + bbox = fz_intersect_bbox(bbox, scissor); x = bbox.x0; y = bbox.y0; w = bbox.x1 - bbox.x0; @@ -316,7 +316,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, inv = fz_scale(1.0f / img->w, -1.0f / img->h); inv = fz_concat(inv, fz_translate(0, 1)); inv = fz_concat(inv, ctm); - inv = fz_invertmatrix(inv); + inv = fz_invert_matrix(inv); fa = inv.a * 65536; fb = inv.b * 65536; @@ -333,23 +333,23 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, sw = img->w; sh = img->h; - /* TODO: if (fb == 0 && fa == 1) call fz_paintspan */ + /* TODO: if (fb == 0 && fa == 1) call fz_paint_span */ while (h--) { if (dolerp) { if (color) - fz_paintaffinecolorlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); + fz_paint_affine_color_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); else - fz_paintaffinelerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); + fz_paint_affine_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); } else { if (color) - fz_paintaffinecolornear(dp, sp, sw, sh, u, v, fa, fb, w, n, color); + fz_paint_affine_color_near(dp, sp, sw, sh, u, v, fa, fb, w, n, color); else - fz_paintaffinenear(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); + fz_paint_affine_near(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); } dp += dst->w * n; u += fc; @@ -358,15 +358,15 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, } void -fz_paintimagecolor(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color) +fz_paint_image_with_color(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color) { assert(img->n == 1); - fz_paintimageimp(dst, scissor, img, ctm, color, 255); + fz_paint_image_imp(dst, scissor, img, ctm, color, 255); } void -fz_paintimage(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha) +fz_paint_image(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha) { assert(dst->n == img->n); - fz_paintimageimp(dst, scissor, img, ctm, nil, alpha); + fz_paint_image_imp(dst, scissor, img, ctm, NULL, alpha); } diff --git a/draw/draw_blend.c b/draw/draw_blend.c index ac2e6c27..5b4d8e83 100644 --- a/draw/draw_blend.c +++ b/draw/draw_blend.c @@ -4,7 +4,7 @@ typedef unsigned char byte; -const char *fz_blendnames[] = +const char *fz_blendmode_names[] = { "Normal", "Multiply", @@ -22,7 +22,7 @@ const char *fz_blendnames[] = "Saturation", "Color", "Luminosity", - nil + NULL }; /* Separable blend modes */ @@ -34,7 +34,7 @@ fz_screen_byte(int b, int s) } static inline int -fz_hardlight_byte(int b, int s) +fz_hard_light_byte(int b, int s) { int s2 = s << 1; if (s <= 127) @@ -46,7 +46,7 @@ fz_hardlight_byte(int b, int s) static inline int fz_overlay_byte(int b, int s) { - return fz_hardlight_byte(s, b); /* note swapped order */ + return fz_hard_light_byte(s, b); /* note swapped order */ } static inline int @@ -62,7 +62,7 @@ fz_lighten_byte(int b, int s) } static inline int -fz_colordodge_byte(int b, int s) +fz_color_dodge_byte(int b, int s) { s = 255 - s; if (b == 0) @@ -74,7 +74,7 @@ fz_colordodge_byte(int b, int s) } static inline int -fz_colorburn_byte(int b, int s) +fz_color_burn_byte(int b, int s) { b = 255 - b; if (b == 0) @@ -86,7 +86,7 @@ fz_colorburn_byte(int b, int s) } static inline int -fz_softlight_byte(int b, int s) +fz_soft_light_byte(int b, int s) { /* review this */ if (s < 128) { @@ -228,7 +228,7 @@ fz_hue_rgb(int *rr, int *rg, int *rb, int br, int bg, int bb, int sr, int sg, in /* Blending loops */ void -fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode) +fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode) { int k; int n1 = n - 1; @@ -251,18 +251,18 @@ fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blend switch (blendmode) { default: - case FZ_BNORMAL: rc = sc; break; - case FZ_BMULTIPLY: rc = fz_mul255(bc, sc); break; - case FZ_BSCREEN: rc = fz_screen_byte(bc, sc); break; - case FZ_BOVERLAY: rc = fz_overlay_byte(bc, sc); break; - case FZ_BDARKEN: rc = fz_darken_byte(bc, sc); break; - case FZ_BLIGHTEN: rc = fz_lighten_byte(bc, sc); break; - case FZ_BCOLORDODGE: rc = fz_colordodge_byte(bc, sc); break; - case FZ_BCOLORBURN: rc = fz_colorburn_byte(bc, sc); break; - case FZ_BHARDLIGHT: rc = fz_hardlight_byte(bc, sc); break; - case FZ_BSOFTLIGHT: rc = fz_softlight_byte(bc, sc); break; - case FZ_BDIFFERENCE: rc = fz_difference_byte(bc, sc); break; - case FZ_BEXCLUSION: rc = fz_exclusion_byte(bc, sc); break; + case FZ_BLEND_NORMAL: rc = sc; break; + case FZ_BLEND_MULTIPLY: rc = fz_mul255(bc, sc); break; + case FZ_BLEND_SCREEN: rc = fz_screen_byte(bc, sc); break; + case FZ_BLEND_OVERLAY: rc = fz_overlay_byte(bc, sc); break; + case FZ_BLEND_DARKEN: rc = fz_darken_byte(bc, sc); break; + case FZ_BLEND_LIGHTEN: rc = fz_lighten_byte(bc, sc); break; + case FZ_BLEND_COLOR_DODGE: rc = fz_color_dodge_byte(bc, sc); break; + case FZ_BLEND_COLOR_BURN: rc = fz_color_burn_byte(bc, sc); break; + case FZ_BLEND_HARD_LIGHT: rc = fz_hard_light_byte(bc, sc); break; + case FZ_BLEND_SOFT_LIGHT: rc = fz_soft_light_byte(bc, sc); break; + case FZ_BLEND_DIFFERENCE: rc = fz_difference_byte(bc, sc); break; + case FZ_BLEND_EXCLUSION: rc = fz_exclusion_byte(bc, sc); break; } bp[k] = fz_mul255(255 - sa, bp[k]) + fz_mul255(255 - ba, sp[k]) + fz_mul255(saba, rc); @@ -276,7 +276,7 @@ fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blend } void -fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode) +fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode) { while (w--) { @@ -301,16 +301,16 @@ fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode switch (blendmode) { default: - case FZ_BHUE: + case FZ_BLEND_HUE: fz_hue_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BSATURATION: + case FZ_BLEND_SATURATION: fz_saturation_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BCOLOR: + case FZ_BLEND_COLOR: fz_color_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BLUMINOSITY: + case FZ_BLEND_LUMINOSITY: fz_luminosity_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; } @@ -326,7 +326,7 @@ fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode } void -fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode) +fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode) { unsigned char *sp, *dp; fz_bbox bbox; @@ -344,8 +344,8 @@ fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode } } - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -360,10 +360,10 @@ fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode while (h--) { - if (n == 4 && blendmode >= FZ_BHUE) - fz_blendnonseparable(dp, sp, w, blendmode); + if (n == 4 && blendmode >= FZ_BLEND_HUE) + fz_blend_nonseparable(dp, sp, w, blendmode); else - fz_blendseparable(dp, sp, n, w, blendmode); + fz_blend_separable(dp, sp, n, w, blendmode); sp += src->w * n; dp += dst->w * n; } diff --git a/draw/draw_edge.c b/draw/draw_edge.c index aa956077..9e916555 100644 --- a/draw/draw_edge.c +++ b/draw/draw_edge.c @@ -20,7 +20,7 @@ enum { HSCALE = 17, VSCALE = 15, SF = 1 }; */ fz_gel * -fz_newgel(void) +fz_new_gel(void) { fz_gel *gel; @@ -39,9 +39,9 @@ fz_newgel(void) } void -fz_resetgel(fz_gel *gel, fz_bbox clip) +fz_reset_gel(fz_gel *gel, fz_bbox clip) { - if (fz_isinfiniterect(clip)) + if (fz_is_infinite_rect(clip)) { gel->clip.x0 = gel->clip.y0 = BBOX_MAX; gel->clip.x1 = gel->clip.y1 = BBOX_MIN; @@ -60,18 +60,18 @@ fz_resetgel(fz_gel *gel, fz_bbox clip) } void -fz_freegel(fz_gel *gel) +fz_free_gel(fz_gel *gel) { fz_free(gel->edges); fz_free(gel); } fz_bbox -fz_boundgel(fz_gel *gel) +fz_bound_gel(fz_gel *gel) { fz_bbox bbox; if (gel->len == 0) - return fz_emptybbox; + return fz_empty_bbox; bbox.x0 = fz_idiv(gel->bbox.x0, HSCALE); bbox.y0 = fz_idiv(gel->bbox.y0, VSCALE); bbox.x1 = fz_idiv(gel->bbox.x1, HSCALE) + 1; @@ -81,10 +81,10 @@ fz_boundgel(fz_gel *gel) enum { INSIDE, OUTSIDE, LEAVE, ENTER }; -#define cliplerpy(v,m,x0,y0,x1,y1,t) cliplerpx(v,m,y0,x0,y1,x1,t) +#define clip_lerp_y(v,m,x0,y0,x1,y1,t) clip_lerp_x(v,m,y0,x0,y1,x1,t) static int -cliplerpx(int val, int m, int x0, int y0, int x1, int y1, int *out) +clip_lerp_x(int val, int m, int x0, int y0, int x1, int y1, int *out) { int v0out = m ? x0 > val : x0 < val; int v1out = m ? x1 > val : x1 < val; @@ -109,7 +109,7 @@ cliplerpx(int val, int m, int x0, int y0, int x1, int y1, int *out) } static void -fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) +fz_insert_gel_raw(fz_gel *gel, int x0, int y0, int x1, int y1) { fz_edge *edge; int dx, dy; @@ -152,7 +152,7 @@ fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) edge->x = x0; edge->y = y0; edge->h = dy; - edge->adjdown = dy; + edge->adj_down = dy; /* initial error term going l->r and r->l */ if (dx >= 0) @@ -163,18 +163,18 @@ fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) /* y-major edge */ if (dy >= width) { edge->xmove = 0; - edge->adjup = width; + edge->adj_up = width; } /* x-major edge */ else { edge->xmove = (width / dy) * edge->xdir; - edge->adjup = width % dy; + edge->adj_up = width % dy; } } void -fz_insertgel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) +fz_insert_gel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) { int x0, y0, x1, y1; int d, v; @@ -189,51 +189,51 @@ fz_insertgel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) x1 = CLAMP(fx1, BBOX_MIN, BBOX_MAX); y1 = CLAMP(fy1, BBOX_MIN, BBOX_MAX); - d = cliplerpy(gel->clip.y0, 0, x0, y0, x1, y1, &v); + d = clip_lerp_y(gel->clip.y0, 0, x0, y0, x1, y1, &v); if (d == OUTSIDE) return; if (d == LEAVE) { y1 = gel->clip.y0; x1 = v; } if (d == ENTER) { y0 = gel->clip.y0; x0 = v; } - d = cliplerpy(gel->clip.y1, 1, x0, y0, x1, y1, &v); + d = clip_lerp_y(gel->clip.y1, 1, x0, y0, x1, y1, &v); if (d == OUTSIDE) return; if (d == LEAVE) { y1 = gel->clip.y1; x1 = v; } if (d == ENTER) { y0 = gel->clip.y1; x0 = v; } - d = cliplerpx(gel->clip.x0, 0, x0, y0, x1, y1, &v); + d = clip_lerp_x(gel->clip.x0, 0, x0, y0, x1, y1, &v); if (d == OUTSIDE) { x0 = x1 = gel->clip.x0; } if (d == LEAVE) { - fz_insertgelraw(gel, gel->clip.x0, v, gel->clip.x0, y1); + fz_insert_gel_raw(gel, gel->clip.x0, v, gel->clip.x0, y1); x1 = gel->clip.x0; y1 = v; } if (d == ENTER) { - fz_insertgelraw(gel, gel->clip.x0, y0, gel->clip.x0, v); + fz_insert_gel_raw(gel, gel->clip.x0, y0, gel->clip.x0, v); x0 = gel->clip.x0; y0 = v; } - d = cliplerpx(gel->clip.x1, 1, x0, y0, x1, y1, &v); + d = clip_lerp_x(gel->clip.x1, 1, x0, y0, x1, y1, &v); if (d == OUTSIDE) { x0 = x1 = gel->clip.x1; } if (d == LEAVE) { - fz_insertgelraw(gel, gel->clip.x1, v, gel->clip.x1, y1); + fz_insert_gel_raw(gel, gel->clip.x1, v, gel->clip.x1, y1); x1 = gel->clip.x1; y1 = v; } if (d == ENTER) { - fz_insertgelraw(gel, gel->clip.x1, y0, gel->clip.x1, v); + fz_insert_gel_raw(gel, gel->clip.x1, y0, gel->clip.x1, v); x0 = gel->clip.x1; y0 = v; } - fz_insertgelraw(gel, x0, y0, x1, y1); + fz_insert_gel_raw(gel, x0, y0, x1, y1); } void -fz_sortgel(fz_gel *gel) +fz_sort_gel(fz_gel *gel) { fz_edge *a = gel->edges; int n = gel->len; @@ -270,7 +270,7 @@ fz_sortgel(fz_gel *gel) } int -fz_isrectgel(fz_gel *gel) +fz_is_rect_gel(fz_gel *gel) { /* a rectangular path is converted into two vertical edges of identical height */ if (gel->len == 2) @@ -278,8 +278,8 @@ fz_isrectgel(fz_gel *gel) fz_edge *a = gel->edges + 0; fz_edge *b = gel->edges + 1; return a->y == b->y && a->h == b->h && - a->xmove == 0 && a->adjup == 0 && - b->xmove == 0 && b->adjup == 0; + a->xmove == 0 && a->adj_up == 0 && + b->xmove == 0 && b->adj_up == 0; } return 0; } @@ -289,7 +289,7 @@ fz_isrectgel(fz_gel *gel) */ fz_ael * -fz_newael(void) +fz_new_ael(void) { fz_ael *ael; ael = fz_malloc(sizeof(fz_ael)); @@ -300,14 +300,14 @@ fz_newael(void) } void -fz_freeael(fz_ael *ael) +fz_free_ael(fz_ael *ael) { fz_free(ael->edges); fz_free(ael); } static inline void -sortael(fz_edge **a, int n) +sort_ael(fz_edge **a, int n) { int h, i, k; fz_edge *t; @@ -340,7 +340,7 @@ sortael(fz_edge **a, int n) } static fz_error -insertael(fz_ael *ael, fz_gel *gel, int y, int *e) +insert_ael(fz_ael *ael, fz_gel *gel, int y, int *e) { /* insert edges that start here */ while (*e < gel->len && gel->edges[*e].y == y) { @@ -354,13 +354,13 @@ insertael(fz_ael *ael, fz_gel *gel, int y, int *e) } /* shell-sort the edges by increasing x */ - sortael(ael->edges, ael->len); + sort_ael(ael->edges, ael->len); return fz_okay; } static void -advanceael(fz_ael *ael) +advance_ael(fz_ael *ael) { fz_edge *edge; int i = 0; @@ -378,10 +378,10 @@ advanceael(fz_ael *ael) else { edge->x += edge->xmove; - edge->e += edge->adjup; + edge->e += edge->adj_up; if (edge->e > 0) { edge->x += edge->xdir; - edge->e -= edge->adjdown; + edge->e -= edge->adj_down; } i ++; } @@ -393,7 +393,7 @@ advanceael(fz_ael *ael) */ static inline void -addspan(unsigned char *list, int x0, int x1, int xofs) +add_span(unsigned char *list, int x0, int x1, int xofs) { int x0pix, x0sub; int x1pix, x1sub; @@ -426,7 +426,7 @@ addspan(unsigned char *list, int x0, int x1, int xofs) } static inline void -nonzerowinding(fz_ael *ael, unsigned char *list, int xofs) +non_zero_winding(fz_ael *ael, unsigned char *list, int xofs) { int winding = 0; int x = 0; @@ -436,13 +436,13 @@ nonzerowinding(fz_ael *ael, unsigned char *list, int xofs) if (!winding && (winding + ael->edges[i]->ydir)) x = ael->edges[i]->x; if (winding && !(winding + ael->edges[i]->ydir)) - addspan(list, x, ael->edges[i]->x, xofs); + add_span(list, x, ael->edges[i]->x, xofs); winding += ael->edges[i]->ydir; } } static inline void -evenodd(fz_ael *ael, unsigned char *list, int xofs) +even_odd(fz_ael *ael, unsigned char *list, int xofs) { int even = 0; int x = 0; @@ -452,7 +452,7 @@ evenodd(fz_ael *ael, unsigned char *list, int xofs) if (!even) x = ael->edges[i]->x; else - addspan(list, x, ael->edges[i]->x, xofs); + add_span(list, x, ael->edges[i]->x, xofs); even = !even; } } @@ -476,13 +476,13 @@ blit(fz_pixmap *dest, int x, int y, unsigned char *mp, int w, unsigned char *col dp = dest->samples + ( (y - dest->y) * dest->w + (x - dest->x) ) * dest->n; if (color) - fz_paintspancolor(dp, mp, dest->n, w, color); + fz_paint_span_with_color(dp, mp, dest->n, w, color); else - fz_paintspan(dp, mp, 1, w, 255); + fz_paint_span(dp, mp, 1, w, 255); } fz_error -fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, +fz_scan_convert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, fz_pixmap *dest, unsigned char *color) { fz_error error; @@ -526,7 +526,7 @@ fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, } yd = yc; - error = insertael(ael, gel, y, &e); + error = insert_ael(ael, gel, y, &e); if (error) { fz_free(deltas); return error; @@ -535,12 +535,12 @@ fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, if (yd >= clip.y0 && yd < clip.y1) { if (eofill) - evenodd(ael, deltas, xofs); + even_odd(ael, deltas, xofs); else - nonzerowinding(ael, deltas, xofs); + non_zero_winding(ael, deltas, xofs); } - advanceael(ael); + advance_ael(ael); if (ael->len > 0) y ++; diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c index 15bb7cae..2a6ae616 100644 --- a/draw/draw_glyph.c +++ b/draw/draw_glyph.c @@ -1,18 +1,18 @@ #include "fitz.h" -#define MAXFONTSIZE 1000 -#define MAXGLYPHSIZE 256 -#define MAXCACHESIZE (1024*1024) +#define MAX_FONT_SIZE 1000 +#define MAX_GLYPH_SIZE 256 +#define MAX_CACHE_SIZE (1024*1024) -typedef struct fz_glyphkey_s fz_glyphkey; +typedef struct fz_glyph_key_s fz_glyph_key; -struct fz_glyphcache_s +struct fz_glyph_cache_s { - fz_hashtable *hash; + fz_hash_table *hash; int total; }; -struct fz_glyphkey_s +struct fz_glyph_key_s { fz_font *font; int a, b; @@ -21,68 +21,68 @@ struct fz_glyphkey_s unsigned char e, f; }; -fz_glyphcache * -fz_newglyphcache(void) +fz_glyph_cache * +fz_new_glyph_cache(void) { - fz_glyphcache *cache; + fz_glyph_cache *cache; - cache = fz_malloc(sizeof(fz_glyphcache)); - cache->hash = fz_newhash(509, sizeof(fz_glyphkey)); + cache = fz_malloc(sizeof(fz_glyph_cache)); + cache->hash = fz_new_hash_table(509, sizeof(fz_glyph_key)); cache->total = 0; return cache; } static void -fz_evictglyphcache(fz_glyphcache *cache) +fz_evict_glyph_cache(fz_glyph_cache *cache) { - fz_glyphkey *key; + fz_glyph_key *key; fz_pixmap *pixmap; int i; - for (i = 0; i < fz_hashlen(cache->hash); i++) + for (i = 0; i < fz_hash_len(cache->hash); i++) { - key = fz_hashgetkey(cache->hash, i); + key = fz_hash_get_key(cache->hash, i); if (key->font) - fz_dropfont(key->font); - pixmap = fz_hashgetval(cache->hash, i); + fz_drop_font(key->font); + pixmap = fz_hash_get_val(cache->hash, i); if (pixmap) - fz_droppixmap(pixmap); + fz_drop_pixmap(pixmap); } cache->total = 0; - fz_emptyhash(cache->hash); + fz_empty_hash(cache->hash); } void -fz_freeglyphcache(fz_glyphcache *cache) +fz_free_glyph_cache(fz_glyph_cache *cache) { - fz_evictglyphcache(cache); - fz_freehash(cache->hash); + fz_evict_glyph_cache(cache); + fz_free_hash(cache->hash); fz_free(cache); } fz_pixmap * -fz_renderstrokedglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_strokestate *stroke) +fz_render_stroked_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke) { - if (font->ftface) - return fz_renderftstrokedglyph(font, cid, trm, ctm, stroke); - return fz_renderglyph(cache, font, cid, trm); + if (font->ft_face) + return fz_render_ft_stroked_glyph(font, cid, trm, ctm, stroke); + return fz_render_glyph(cache, font, cid, trm); } fz_pixmap * -fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm) +fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix ctm) { - fz_glyphkey key; + fz_glyph_key key; fz_pixmap *val; - float size = fz_matrixexpansion(ctm); + float size = fz_matrix_expansion(ctm); - if (size > MAXFONTSIZE) + if (size > MAX_FONT_SIZE) { /* TODO: this case should be handled by rendering glyph as a path fill */ fz_warn("font size too large (%g), not rendering glyph", size); - return nil; + return NULL; } memset(&key, 0, sizeof key); @@ -95,40 +95,40 @@ fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm) key.e = (ctm.e - floorf(ctm.e)) * 256; key.f = (ctm.f - floorf(ctm.f)) * 256; - val = fz_hashfind(cache->hash, &key); + val = fz_hash_find(cache->hash, &key); if (val) - return fz_keeppixmap(val); + return fz_keep_pixmap(val); ctm.e = floorf(ctm.e) + key.e / 256.0f; ctm.f = floorf(ctm.f) + key.f / 256.0f; - if (font->ftface) + if (font->ft_face) { - val = fz_renderftglyph(font, cid, ctm); + val = fz_render_ft_glyph(font, cid, ctm); } else if (font->t3procs) { - val = fz_rendert3glyph(font, cid, ctm); + val = fz_render_t3_glyph(font, cid, ctm); } else { fz_warn("assert: uninitialized font structure"); - return nil; + return NULL; } if (val) { - if (val->w < MAXGLYPHSIZE && val->h < MAXGLYPHSIZE) + if (val->w < MAX_GLYPH_SIZE && val->h < MAX_GLYPH_SIZE) { - if (cache->total + val->w * val->h > MAXCACHESIZE) - fz_evictglyphcache(cache); - fz_keepfont(key.font); - fz_hashinsert(cache->hash, &key, val); + if (cache->total + val->w * val->h > MAX_CACHE_SIZE) + fz_evict_glyph_cache(cache); + fz_keep_font(key.font); + fz_hash_insert(cache->hash, &key, val); cache->total += val->w * val->h; - return fz_keeppixmap(val); + return fz_keep_pixmap(val); } return val; } - return nil; + return NULL; } diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c index 79437505..eeebf0a1 100644 --- a/draw/draw_mesh.c +++ b/draw/draw_mesh.c @@ -6,7 +6,7 @@ enum { IN, OUT, ENTER, LEAVE }; enum { MAXV = 3 + 4 }; -enum { MAXN = 2 + FZ_MAXCOLORS }; +enum { MAXN = 2 + FZ_MAX_COLORS }; static int clipx(float val, int ismax, float *v1, float *v2, int n) { @@ -68,13 +68,13 @@ static int clipy(float val, int ismax, float *v1, float *v2, int n) } } -static inline void copyvert(float *dst, float *src, int n) +static inline void copy_vert(float *dst, float *src, int n) { while (n--) *dst++ = *src++; } -static int clippoly(float src[MAXV][MAXN], +static int clip_poly(float src[MAXV][MAXN], float dst[MAXV][MAXN], int len, int n, float val, int isy, int ismax) { @@ -88,8 +88,8 @@ static int clippoly(float src[MAXV][MAXN], for (v2 = 0; v2 < len; v2++) { - copyvert(cv1, src[v1], n); - copyvert(cv2, src[v2], n); + copy_vert(cv1, src[v1], n); + copy_vert(cv2, src[v2], n); if (isy) r = clipy(val, ismax, cv1, cv2, n); @@ -99,16 +99,16 @@ static int clippoly(float src[MAXV][MAXN], switch (r) { case IN: - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv2, n); break; case OUT: break; case LEAVE: - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv2, n); break; case ENTER: - copyvert(dst[cp++], cv1, n); - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv1, n); + copy_vert(dst[cp++], cv2, n); break; } v1 = v2; @@ -122,11 +122,11 @@ static int clippoly(float src[MAXV][MAXN], */ static inline void -paintscan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) +paint_scan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) { unsigned char *p = pix->samples + ((y - pix->y) * pix->w + (x1 - pix->x)) * pix->n; - int v[FZ_MAXCOLORS]; - int dv[FZ_MAXCOLORS]; + int v[FZ_MAX_COLORS]; + int dv[FZ_MAX_COLORS]; int w = x2 - x1; int k; @@ -157,7 +157,7 @@ paintscan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) } static inline int -findnext(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) +find_next(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) { int b; @@ -187,7 +187,7 @@ findnext(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) } static inline void -loadedge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) +load_edge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) { int swp, k, dy; @@ -208,7 +208,7 @@ loadedge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) } static inline void -stepedge(int *ael, int *del, int n) +step_edge(int *ael, int *del, int n) { int k; ael[0] += del[0]; @@ -217,7 +217,7 @@ stepedge(int *ael, int *del, int n) } static void -fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox) +fz_paint_triangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox) { float poly[MAXV][MAXN]; float temp[MAXV][MAXN]; @@ -234,14 +234,14 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox int i, k; - copyvert(poly[0], av, n); - copyvert(poly[1], bv, n); - copyvert(poly[2], cv, n); + copy_vert(poly[0], av, n); + copy_vert(poly[1], bv, n); + copy_vert(poly[2], cv, n); - len = clippoly(poly, temp, 3, n, cx0, 0, 0); - len = clippoly(temp, poly, len, n, cx1, 0, 1); - len = clippoly(poly, temp, len, n, cy0, 1, 0); - len = clippoly(temp, poly, len, n, cy1, 1, 1); + len = clip_poly(poly, temp, 3, n, cx0, 0, 0); + len = clip_poly(temp, poly, len, n, cx1, 0, 1); + len = clip_poly(poly, temp, len, n, cy0, 1, 0); + len = clip_poly(temp, poly, len, n, cy1, 1, 1); if (len < 3) return; @@ -268,13 +268,13 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox y = gel[top][1]; - if (findnext(gel, len, top, &s0, &e0, 1)) + if (find_next(gel, len, top, &s0, &e0, 1)) return; - if (findnext(gel, len, top, &s1, &e1, -1)) + if (find_next(gel, len, top, &s1, &e1, -1)) return; - loadedge(gel, s0, e0, ael[0], del[0], n); - loadedge(gel, s1, e1, ael[1], del[1], n); + load_edge(gel, s0, e0, ael[0], del[0], n); + load_edge(gel, s1, e1, ael[1], del[1], n); while (1) { @@ -282,32 +282,32 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox int x1 = ael[1][0] >> 16; if (ael[0][0] < ael[1][0]) - paintscan(pix, y, x0, x1, ael[0]+2, ael[1]+2, n-2); + paint_scan(pix, y, x0, x1, ael[0]+2, ael[1]+2, n-2); else - paintscan(pix, y, x1, x0, ael[1]+2, ael[0]+2, n-2); + paint_scan(pix, y, x1, x0, ael[1]+2, ael[0]+2, n-2); - stepedge(ael[0], del[0], n); - stepedge(ael[1], del[1], n); + step_edge(ael[0], del[0], n); + step_edge(ael[1], del[1], n); y ++; if (y >= gel[e0][1]) { - if (findnext(gel, len, e0, &s0, &e0, 1)) + if (find_next(gel, len, e0, &s0, &e0, 1)) return; - loadedge(gel, s0, e0, ael[0], del[0], n); + load_edge(gel, s0, e0, ael[0], del[0], n); } if (y >= gel[e1][1]) { - if (findnext(gel, len, e1, &s1, &e1, -1)) + if (find_next(gel, len, e1, &s1, &e1, -1)) return; - loadedge(gel, s1, e1, ael[1], del[1], n); + load_edge(gel, s1, e1, ael[1], del[1], n); } } } static void -fz_paintquad(fz_pixmap *pix, +fz_paint_quad(fz_pixmap *pix, fz_point p0, fz_point p1, fz_point p2, fz_point p3, float c0, float c1, float c2, float c3, int n, fz_bbox bbox) @@ -330,8 +330,8 @@ fz_paintquad(fz_pixmap *pix, v[3][1] = p3.y; v[3][2] = c3; - fz_painttriangle(pix, v[0], v[2], v[3], n, bbox); - fz_painttriangle(pix, v[0], v[3], v[1], n, bbox); + fz_paint_triangle(pix, v[0], v[2], v[3], n, bbox); + fz_paint_triangle(pix, v[0], v[3], v[1], n, bbox); } /* @@ -342,7 +342,7 @@ fz_paintquad(fz_pixmap *pix, #define RADSEGS 32 /* how many segments to generate for radial meshes */ static fz_point -fz_pointoncircle(fz_point p, float r, float theta) +fz_point_on_circle(fz_point p, float r, float theta) { p.x = p.x + cosf(theta) * r; p.y = p.y + sinf(theta) * r; @@ -351,7 +351,7 @@ fz_pointoncircle(fz_point p, float r, float theta) } static void -fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_linear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { fz_point p0, p1; fz_point v0, v1, v2, v3; @@ -360,21 +360,21 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) p0.x = shade->mesh[0]; p0.y = shade->mesh[1]; - p0 = fz_transformpoint(ctm, p0); + p0 = fz_transform_point(ctm, p0); p1.x = shade->mesh[3]; p1.y = shade->mesh[4]; - p1 = fz_transformpoint(ctm, p1); + p1 = fz_transform_point(ctm, p1); theta = atan2f(p1.y - p0.y, p1.x - p0.x); theta += (float)M_PI * 0.5f; - v0 = fz_pointoncircle(p0, HUGENUM, theta); - v1 = fz_pointoncircle(p1, HUGENUM, theta); - v2 = fz_pointoncircle(p0, -HUGENUM, theta); - v3 = fz_pointoncircle(p1, -HUGENUM, theta); + v0 = fz_point_on_circle(p0, HUGENUM, theta); + v1 = fz_point_on_circle(p1, HUGENUM, theta); + v2 = fz_point_on_circle(p0, -HUGENUM, theta); + v3 = fz_point_on_circle(p1, -HUGENUM, theta); - fz_paintquad(dest, v0, v1, v2, v3, 0, 255, 0, 255, 3, bbox); + fz_paint_quad(dest, v0, v1, v2, v3, 0, 255, 0, 255, 3, bbox); if (shade->extend[0]) { @@ -384,7 +384,7 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e1.x = v2.x - (p1.x - p0.x) * HUGENUM; e1.y = v2.y - (p1.y - p0.y) * HUGENUM; - fz_paintquad(dest, e0, e1, v0, v2, 0, 0, 0, 0, 3, bbox); + fz_paint_quad(dest, e0, e1, v0, v2, 0, 0, 0, 0, 3, bbox); } if (shade->extend[1]) @@ -395,12 +395,12 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e1.x = v3.x + (p1.x - p0.x) * HUGENUM; e1.y = v3.y + (p1.y - p0.y) * HUGENUM; - fz_paintquad(dest, e0, e1, v1, v3, 255, 255, 255, 255, 3, bbox); + fz_paint_quad(dest, e0, e1, v1, v3, 255, 255, 255, 255, 3, bbox); } } static void -fz_paintannulus(fz_matrix ctm, +fz_paint_annulus(fz_matrix ctm, fz_point p0, float r0, float c0, fz_point p1, float r1, float c1, fz_pixmap *dest, fz_bbox bbox) @@ -414,31 +414,31 @@ fz_paintannulus(fz_matrix ctm, for (i = 0; i < RADSEGS / 2; i++) { - t0 = fz_pointoncircle(p0, r0, theta + i * step); - t1 = fz_pointoncircle(p0, r0, theta + i * step + step); - t2 = fz_pointoncircle(p1, r1, theta + i * step); - t3 = fz_pointoncircle(p1, r1, theta + i * step + step); - b0 = fz_pointoncircle(p0, r0, theta - i * step); - b1 = fz_pointoncircle(p0, r0, theta - i * step - step); - b2 = fz_pointoncircle(p1, r1, theta - i * step); - b3 = fz_pointoncircle(p1, r1, theta - i * step - step); - - t0 = fz_transformpoint(ctm, t0); - t1 = fz_transformpoint(ctm, t1); - t2 = fz_transformpoint(ctm, t2); - t3 = fz_transformpoint(ctm, t3); - b0 = fz_transformpoint(ctm, b0); - b1 = fz_transformpoint(ctm, b1); - b2 = fz_transformpoint(ctm, b2); - b3 = fz_transformpoint(ctm, b3); - - fz_paintquad(dest, t0, t1, t2, t3, c0, c0, c1, c1, 3, bbox); - fz_paintquad(dest, b0, b1, b2, b3, c0, c0, c1, c1, 3, bbox); + t0 = fz_point_on_circle(p0, r0, theta + i * step); + t1 = fz_point_on_circle(p0, r0, theta + i * step + step); + t2 = fz_point_on_circle(p1, r1, theta + i * step); + t3 = fz_point_on_circle(p1, r1, theta + i * step + step); + b0 = fz_point_on_circle(p0, r0, theta - i * step); + b1 = fz_point_on_circle(p0, r0, theta - i * step - step); + b2 = fz_point_on_circle(p1, r1, theta - i * step); + b3 = fz_point_on_circle(p1, r1, theta - i * step - step); + + t0 = fz_transform_point(ctm, t0); + t1 = fz_transform_point(ctm, t1); + t2 = fz_transform_point(ctm, t2); + t3 = fz_transform_point(ctm, t3); + b0 = fz_transform_point(ctm, b0); + b1 = fz_transform_point(ctm, b1); + b2 = fz_transform_point(ctm, b2); + b3 = fz_transform_point(ctm, b3); + + fz_paint_quad(dest, t0, t1, t2, t3, c0, c0, c1, c1, 3, bbox); + fz_paint_quad(dest, b0, b1, b2, b3, c0, c0, c1, c1, 3, bbox); } } static void -fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_radial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { fz_point p0, p1; float r0, r1; @@ -464,10 +464,10 @@ fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e.y = p0.y + (p1.y - p0.y) * rs; er = r0 + (r1 - r0) * rs; - fz_paintannulus(ctm, e, er, 0, p0, r0, 0, dest, bbox); + fz_paint_annulus(ctm, e, er, 0, p0, r0, 0, dest, bbox); } - fz_paintannulus(ctm, p0, r0, 0, p1, r1, 255, dest, bbox); + fz_paint_annulus(ctm, p0, r0, 0, p1, r1, 255, dest, bbox); if (shade->extend[1]) { @@ -480,12 +480,12 @@ fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e.y = p1.y + (p0.y - p1.y) * rs; er = r1 + (r0 - r1) * rs; - fz_paintannulus(ctm, p1, r1, 255, e, er, 255, dest, bbox); + fz_paint_annulus(ctm, p1, r1, 255, e, er, 255, dest, bbox); } } static void -fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_mesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { float tri[3][MAXN]; fz_point p; @@ -495,10 +495,10 @@ fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) mesh = shade->mesh; - if (shade->usefunction) - ntris = shade->meshlen / 9; + if (shade->use_function) + ntris = shade->mesh_len / 9; else - ntris = shade->meshlen / ((2 + shade->colorspace->n) * 3); + ntris = shade->mesh_len / ((2 + shade->colorspace->n) * 3); while (ntris--) { @@ -506,45 +506,45 @@ fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { p.x = *mesh++; p.y = *mesh++; - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); tri[k][0] = p.x; tri[k][1] = p.y; - if (shade->usefunction) + if (shade->use_function) tri[k][2] = *mesh++ * 255; else { - fz_convertcolor(shade->colorspace, mesh, dest->colorspace, tri[k] + 2); + fz_convert_color(shade->colorspace, mesh, dest->colorspace, tri[k] + 2); for (i = 0; i < dest->colorspace->n; i++) tri[k][i + 2] *= 255; mesh += shade->colorspace->n; } } - fz_painttriangle(dest, tri[0], tri[1], tri[2], 2 + dest->colorspace->n, bbox); + fz_paint_triangle(dest, tri[0], tri[1], tri[2], 2 + dest->colorspace->n, bbox); } } void -fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { - unsigned char clut[256][FZ_MAXCOLORS]; + unsigned char clut[256][FZ_MAX_COLORS]; fz_pixmap *temp, *conv; - float color[FZ_MAXCOLORS]; + float color[FZ_MAX_COLORS]; int i, k; ctm = fz_concat(shade->matrix, ctm); - if (shade->usefunction) + if (shade->use_function) { for (i = 0; i < 256; i++) { - fz_convertcolor(shade->colorspace, shade->function[i], dest->colorspace, color); + fz_convert_color(shade->colorspace, shade->function[i], dest->colorspace, color); for (k = 0; k < dest->colorspace->n; k++) clut[i][k] = color[k] * 255; clut[i][k] = shade->function[i][shade->colorspace->n] * 255; } - conv = fz_newpixmapwithrect(dest->colorspace, bbox); - temp = fz_newpixmapwithrect(fz_devicegray, bbox); - fz_clearpixmap(temp); + conv = fz_new_pixmap_with_rect(dest->colorspace, bbox); + temp = fz_new_pixmap_with_rect(fz_device_gray, bbox); + fz_clear_pixmap(temp); } else { @@ -553,12 +553,12 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) switch (shade->type) { - case FZ_LINEAR: fz_paintlinear(shade, ctm, temp, bbox); break; - case FZ_RADIAL: fz_paintradial(shade, ctm, temp, bbox); break; - case FZ_MESH: fz_paintmesh(shade, ctm, temp, bbox); break; + case FZ_LINEAR: fz_paint_linear(shade, ctm, temp, bbox); break; + case FZ_RADIAL: fz_paint_radial(shade, ctm, temp, bbox); break; + case FZ_MESH: fz_paint_mesh(shade, ctm, temp, bbox); break; } - if (shade->usefunction) + if (shade->use_function) { unsigned char *s = temp->samples; unsigned char *d = conv->samples; @@ -571,9 +571,8 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) *d++ = fz_mul255(clut[v][k], a); *d++ = a; } - fz_paintpixmap(dest, conv, 255); - fz_droppixmap(conv); - fz_droppixmap(temp); + fz_paint_pixmap(dest, conv, 255); + fz_drop_pixmap(conv); + fz_drop_pixmap(temp); } } - diff --git a/draw/draw_paint.c b/draw/draw_paint.c index 69df467a..00e6405d 100644 --- a/draw/draw_paint.c +++ b/draw/draw_paint.c @@ -75,7 +75,7 @@ typedef unsigned char byte; /* Blend a non-premultiplied color in mask over destination */ static inline void -fz_paintspancolor2(byte * restrict dp, byte * restrict mp, int w, byte *color) +fz_paint_span_with_color_2(byte * restrict dp, byte * restrict mp, int w, byte *color) { int sa = FZ_EXPAND(color[1]); int g = color[0]; @@ -90,7 +90,7 @@ fz_paintspancolor2(byte * restrict dp, byte * restrict mp, int w, byte *color) } static inline void -fz_paintspancolor4(byte * restrict dp, byte * restrict mp, int w, byte *color) +fz_paint_span_with_color_4(byte * restrict dp, byte * restrict mp, int w, byte *color) { int sa = FZ_EXPAND(color[3]); int r = color[0]; @@ -109,7 +109,7 @@ fz_paintspancolor4(byte * restrict dp, byte * restrict mp, int w, byte *color) } static inline void -fz_paintspancolorN(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) +fz_paint_span_with_color_N(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) { int sa = FZ_EXPAND(color[n-1]); int k; @@ -126,20 +126,20 @@ fz_paintspancolorN(byte * restrict dp, byte * restrict mp, int n, int w, byte *c } void -fz_paintspancolor(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) +fz_paint_span_with_color(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) { switch (n) { - case 2: fz_paintspancolor2(dp, mp, w, color); break; - case 4: fz_paintspancolor4(dp, mp, w, color); break; - default: fz_paintspancolorN(dp, mp, n, w, color); break; + case 2: fz_paint_span_with_color_2(dp, mp, w, color); break; + case 4: fz_paint_span_with_color_4(dp, mp, w, color); break; + default: fz_paint_span_with_color_N(dp, mp, n, w, color); break; } } /* Blend source in mask over destination */ static inline void -fz_paintspanmask2(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) +fz_paint_span_with_mask_2(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) { while (w--) { @@ -157,7 +157,7 @@ fz_paintspanmask2(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static inline void -fz_paintspanmask4(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) +fz_paint_span_with_mask_4(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) { while (w--) { @@ -179,7 +179,7 @@ fz_paintspanmask4(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static inline void -fz_paintspanmaskN(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) +fz_paint_span_with_mask_N(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) { n--; while (w--) @@ -200,20 +200,20 @@ fz_paintspanmaskN(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static void -fz_paintspanmask(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) +fz_paint_span_with_mask(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) { switch (n) { - case 2: fz_paintspanmask2(dp, sp, mp, w); break; - case 4: fz_paintspanmask4(dp, sp, mp, w); break; - default: fz_paintspanmaskN(dp, sp, mp, n, w); break; + case 2: fz_paint_span_with_mask_2(dp, sp, mp, w); break; + case 4: fz_paint_span_with_mask_4(dp, sp, mp, w); break; + default: fz_paint_span_with_mask_N(dp, sp, mp, n, w); break; } } /* Blend source in constant alpha over destination */ static inline void -fz_paintspan2alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) +fz_paint_span_2_with_alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -227,7 +227,7 @@ fz_paintspan2alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) } static inline void -fz_paintspan4alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) +fz_paint_span_4_with_alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -245,7 +245,7 @@ fz_paintspan4alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) } static inline void -fz_paintspanNalpha(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) +fz_paint_span_N_with_alpha(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -263,7 +263,7 @@ fz_paintspanNalpha(byte * restrict dp, byte * restrict sp, int n, int w, int alp /* Blend source over destination */ static inline void -fz_paintspan1(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_1(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -274,7 +274,7 @@ fz_paintspan1(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspan2(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_2(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -287,7 +287,7 @@ fz_paintspan2(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspan4(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_4(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -304,7 +304,7 @@ fz_paintspan4(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspanN(byte * restrict dp, byte * restrict sp, int n, int w) +fz_paint_span_N(byte * restrict dp, byte * restrict sp, int n, int w) { while (w--) { @@ -319,25 +319,25 @@ fz_paintspanN(byte * restrict dp, byte * restrict sp, int n, int w) } void -fz_paintspan(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) +fz_paint_span(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintspan1(dp, sp, w); break; - case 2: fz_paintspan2(dp, sp, w); break; - case 4: fz_paintspan4(dp, sp, w); break; - default: fz_paintspanN(dp, sp, n, w); break; + case 1: fz_paint_span_1(dp, sp, w); break; + case 2: fz_paint_span_2(dp, sp, w); break; + case 4: fz_paint_span_4(dp, sp, w); break; + default: fz_paint_span_N(dp, sp, n, w); break; } } else if (alpha > 0) { switch (n) { - case 2: fz_paintspan2alpha(dp, sp, w, alpha); break; - case 4: fz_paintspan4alpha(dp, sp, w, alpha); break; - default: fz_paintspanNalpha(dp, sp, n, w, alpha); break; + case 2: fz_paint_span_2_with_alpha(dp, sp, w, alpha); break; + case 4: fz_paint_span_4_with_alpha(dp, sp, w, alpha); break; + default: fz_paint_span_N_with_alpha(dp, sp, n, w, alpha); break; } } } @@ -347,15 +347,15 @@ fz_paintspan(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) */ void -fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) +fz_paint_pixmap_with_rect(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) { unsigned char *sp, *dp; int x, y, w, h, n; assert(dst->n == src->n); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(dst)); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(dst)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -370,14 +370,14 @@ fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) while (h--) { - fz_paintspan(dp, sp, n, w, alpha); + fz_paint_span(dp, sp, n, w, alpha); sp += src->w * n; dp += dst->w * n; } } void -fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) +fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) { unsigned char *sp, *dp; fz_bbox bbox; @@ -385,8 +385,8 @@ fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) assert(dst->n == src->n); - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -401,14 +401,14 @@ fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) while (h--) { - fz_paintspan(dp, sp, n, w, alpha); + fz_paint_span(dp, sp, n, w, alpha); sp += src->w * n; dp += dst->w * n; } } void -fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) +fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) { unsigned char *sp, *dp, *mp; fz_bbox bbox; @@ -417,9 +417,9 @@ fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) assert(dst->n == src->n); assert(msk->n == 1); - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(msk)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(msk)); x = bbox.x0; y = bbox.y0; @@ -435,7 +435,7 @@ fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) while (h--) { - fz_paintspanmask(dp, sp, mp, n, w); + fz_paint_span_with_mask(dp, sp, mp, n, w); sp += src->w * n; dp += dst->w * n; mp += msk->w; diff --git a/draw/draw_path.c b/draw/draw_path.c index 23ea3515..55e070c9 100644 --- a/draw/draw_path.c +++ b/draw/draw_path.c @@ -1,6 +1,6 @@ #include "fitz.h" -#define MAXDEPTH 8 +#define MAX_DEPTH 8 enum { BUTT = 0, ROUND = 1, SQUARE = 2, MITER = 0, BEVEL = 2 }; @@ -11,7 +11,7 @@ line(fz_gel *gel, fz_matrix *ctm, float x0, float y0, float x1, float y1) float ty0 = ctm->b * x0 + ctm->d * y0 + ctm->f; float tx1 = ctm->a * x1 + ctm->c * y1 + ctm->e; float ty1 = ctm->b * x1 + ctm->d * y1 + ctm->f; - fz_insertgel(gel, tx0, ty0, tx1, ty1); + fz_insert_gel(gel, tx0, ty0, tx1, ty1); } static void @@ -34,7 +34,7 @@ bezier(fz_gel *gel, fz_matrix *ctm, float flatness, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < flatness || depth >= MAXDEPTH) + if (dmax < flatness || depth >= MAX_DEPTH) { line(gel, ctm, xa, ya, xd, yd); return; @@ -69,7 +69,7 @@ bezier(fz_gel *gel, fz_matrix *ctm, float flatness, } void -fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) +fz_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) { float x1, y1, x2, y2, x3, y3; float cx = 0; @@ -80,39 +80,39 @@ fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: /* implicit closepath before moveto */ if (i && (cx != bx || cy != by)) line(gel, &ctm, cx, cy, bx, by); - x1 = path->els[i++].v; - y1 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; cx = bx = x1; cy = by = y1; break; case FZ_LINETO: - x1 = path->els[i++].v; - y1 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; line(gel, &ctm, cx, cy, x1, y1); cx = x1; cy = y1; break; case FZ_CURVETO: - x1 = path->els[i++].v; - y1 = path->els[i++].v; - x2 = path->els[i++].v; - y2 = path->els[i++].v; - x3 = path->els[i++].v; - y3 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; + x2 = path->items[i++].v; + y2 = path->items[i++].v; + x3 = path->items[i++].v; + y3 = path->items[i++].v; bezier(gel, &ctm, flatness, cx, cy, x1, y1, x2, y2, x3, y3, 0); cx = x3; cy = y3; break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: line(gel, &ctm, cx, cy, bx, by); cx = bx; cy = by; @@ -139,9 +139,9 @@ struct sctx int sn, bn; int dot; - float *dashlist; - float dashphase; - int dashlen; + float *dash_list; + float dash_phase; + int dash_len; int toggle; int offset; float phase; @@ -149,17 +149,17 @@ struct sctx }; static void -fz_addline(struct sctx *s, float x0, float y0, float x1, float y1) +fz_add_line(struct sctx *s, float x0, float y0, float x1, float y1) { float tx0 = s->ctm->a * x0 + s->ctm->c * y0 + s->ctm->e; float ty0 = s->ctm->b * x0 + s->ctm->d * y0 + s->ctm->f; float tx1 = s->ctm->a * x1 + s->ctm->c * y1 + s->ctm->e; float ty1 = s->ctm->b * x1 + s->ctm->d * y1 + s->ctm->f; - fz_insertgel(s->gel, tx0, ty0, tx1, ty1); + fz_insert_gel(s->gel, tx0, ty0, tx1, ty1); } static void -fz_addarc(struct sctx *s, +fz_add_arc(struct sctx *s, float xc, float yc, float x0, float y0, float x1, float y1) @@ -194,12 +194,12 @@ fz_addarc(struct sctx *s, theta = th0 + (th1 - th0) * i / n; nx = cosf(theta) * r; ny = sinf(theta) * r; - fz_addline(s, xc + ox, yc + oy, xc + nx, yc + ny); + fz_add_line(s, xc + ox, yc + oy, xc + nx, yc + ny); ox = nx; oy = ny; } - fz_addline(s, xc + ox, yc + oy, xc + x1, yc + y1); + fz_add_line(s, xc + ox, yc + oy, xc + x1, yc + y1); } static void @@ -210,8 +210,8 @@ fz_linestroke(struct sctx *s, fz_point a, fz_point b) float scale = s->linewidth / sqrtf(dx * dx + dy * dy); float dlx = dy * scale; float dly = -dx * scale; - fz_addline(s, a.x - dlx, a.y - dly, b.x - dlx, b.y - dly); - fz_addline(s, b.x + dlx, b.y + dly, a.x + dlx, a.y + dly); + fz_add_line(s, a.x - dlx, a.y - dly, b.x - dlx, b.y - dly); + fz_add_line(s, b.x + dlx, b.y + dly, a.x + dlx, a.y + dly); } static void @@ -263,8 +263,8 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) if (linejoin == BEVEL) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); } if (linejoin == MITER) @@ -275,15 +275,15 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) if (cross < 0) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dmx, b.y + dmy); - fz_addline(s, b.x + dmx, b.y + dmy, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dmx, b.y + dmy); + fz_add_line(s, b.x + dmx, b.y + dmy, b.x + dlx0, b.y + dly0); } else { - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dmx, b.y - dmy); - fz_addline(s, b.x - dmx, b.y - dmy, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dmx, b.y - dmy); + fz_add_line(s, b.x - dmx, b.y - dmy, b.x - dlx1, b.y - dly1); } } @@ -291,13 +291,13 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) { if (cross < 0) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addarc(s, b.x, b.y, dlx1, dly1, dlx0, dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_arc(s, b.x, b.y, dlx1, dly1, dlx0, dly0); } else { - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); - fz_addarc(s, b.x, b.y, -dlx0, -dly0, -dlx1, -dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_arc(s, b.x, b.y, -dlx0, -dly0, -dlx1, -dly1); } } } @@ -317,7 +317,7 @@ fz_linecap(struct sctx *s, fz_point a, fz_point b) float dly = -dx * scale; if (linecap == BUTT) - fz_addline(s, b.x - dlx, b.y - dly, b.x + dlx, b.y + dly); + fz_add_line(s, b.x - dlx, b.y - dly, b.x + dlx, b.y + dly); if (linecap == ROUND) { @@ -332,23 +332,23 @@ fz_linecap(struct sctx *s, fz_point a, fz_point b) float sth = sinf(theta); float nx = b.x - dlx * cth - dly * sth; float ny = b.y - dly * cth + dlx * sth; - fz_addline(s, ox, oy, nx, ny); + fz_add_line(s, ox, oy, nx, ny); ox = nx; oy = ny; } - fz_addline(s, ox, oy, b.x + dlx, b.y + dly); + fz_add_line(s, ox, oy, b.x + dlx, b.y + dly); } if (linecap == SQUARE) { - fz_addline(s, b.x - dlx, b.y - dly, + fz_add_line(s, b.x - dlx, b.y - dly, b.x - dlx - dly, b.y - dly + dlx); - fz_addline(s, b.x - dlx - dly, + fz_add_line(s, b.x - dlx - dly, b.y - dly + dlx, b.x + dlx - dly, b.y + dly + dlx); - fz_addline(s, b.x + dlx - dly, + fz_add_line(s, b.x + dlx - dly, b.y + dly + dlx, b.x + dlx, b.y + dly); } @@ -371,16 +371,16 @@ fz_linedot(struct sctx *s, fz_point a) float sth = sinf(theta); float nx = a.x - cth * linewidth; float ny = a.y + sth * linewidth; - fz_addline(s, ox, oy, nx, ny); + fz_add_line(s, ox, oy, nx, ny); ox = nx; oy = ny; } - fz_addline(s, ox, oy, a.x - linewidth, a.y); + fz_add_line(s, ox, oy, a.x - linewidth, a.y); } static void -fz_strokeflush(struct sctx *s) +fz_stroke_flush(struct sctx *s) { if (s->sn == 2) { @@ -394,9 +394,9 @@ fz_strokeflush(struct sctx *s) } static void -fz_strokemoveto(struct sctx *s, fz_point cur) +fz_stroke_moveto(struct sctx *s, fz_point cur) { - fz_strokeflush(s); + fz_stroke_flush(s); s->seg[0] = cur; s->beg[0] = cur; s->sn = 1; @@ -405,7 +405,7 @@ fz_strokemoveto(struct sctx *s, fz_point cur) } static void -fz_strokelineto(struct sctx *s, fz_point cur) +fz_stroke_lineto(struct sctx *s, fz_point cur) { float dx = cur.x - s->seg[s->sn-1].x; float dy = cur.y - s->seg[s->sn-1].y; @@ -432,11 +432,11 @@ fz_strokelineto(struct sctx *s, fz_point cur) } static void -fz_strokeclosepath(struct sctx *s) +fz_stroke_closepath(struct sctx *s) { if (s->sn == 2) { - fz_strokelineto(s, s->beg[0]); + fz_stroke_lineto(s, s->beg[0]); if (s->seg[1].x == s->beg[0].x && s->seg[1].y == s->beg[0].y) fz_linejoin(s, s->seg[0], s->beg[0], s->beg[1]); else @@ -454,7 +454,7 @@ fz_strokeclosepath(struct sctx *s) } static void -fz_strokebezier(struct sctx *s, +fz_stroke_bezier(struct sctx *s, float xa, float ya, float xb, float yb, float xc, float yc, @@ -473,12 +473,12 @@ fz_strokebezier(struct sctx *s, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < s->flatness || depth >= MAXDEPTH) + if (dmax < s->flatness || depth >= MAX_DEPTH) { fz_point p; p.x = xd; p.y = yd; - fz_strokelineto(s, p); + fz_stroke_lineto(s, p); return; } @@ -506,12 +506,12 @@ fz_strokebezier(struct sctx *s, xabcd *= 0.125f; yabcd *= 0.125f; - fz_strokebezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); - fz_strokebezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); + fz_stroke_bezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); + fz_stroke_bezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); } void -fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3; @@ -531,7 +531,7 @@ fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, i = 0; - if (path->len > 0 && path->els[0].k != FZ_MOVETO) + if (path->len > 0 && path->items[0].k != FZ_MOVETO) { fz_warn("assert: path must begin with moveto"); return; @@ -541,66 +541,66 @@ fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_strokemoveto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_stroke_moveto(&s, p1); p0 = p1; break; case FZ_LINETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_strokelineto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_stroke_lineto(&s, p1); p0 = p1; break; case FZ_CURVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - p2.x = path->els[i++].v; - p2.y = path->els[i++].v; - p3.x = path->els[i++].v; - p3.y = path->els[i++].v; - fz_strokebezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + p2.x = path->items[i++].v; + p2.y = path->items[i++].v; + p3.x = path->items[i++].v; + p3.y = path->items[i++].v; + fz_stroke_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); p0 = p3; break; - case FZ_CLOSEPATH: - fz_strokeclosepath(&s); + case FZ_CLOSE_PATH: + fz_stroke_closepath(&s); break; } } - fz_strokeflush(&s); + fz_stroke_flush(&s); } static void -fz_dashmoveto(struct sctx *s, fz_point a) +fz_dash_moveto(struct sctx *s, fz_point a) { s->toggle = 1; s->offset = 0; - s->phase = s->dashphase; + s->phase = s->dash_phase; - while (s->phase >= s->dashlist[s->offset]) + while (s->phase >= s->dash_list[s->offset]) { s->toggle = !s->toggle; - s->phase -= s->dashlist[s->offset]; + s->phase -= s->dash_list[s->offset]; s->offset ++; - if (s->offset == s->dashlen) + if (s->offset == s->dash_len) s->offset = 0; } s->cur = a; if (s->toggle) - fz_strokemoveto(s, a); + fz_stroke_moveto(s, a); } static void -fz_dashlineto(struct sctx *s, fz_point b) +fz_dash_lineto(struct sctx *s, fz_point b) { float dx, dy; float total, used, ratio; @@ -613,22 +613,22 @@ fz_dashlineto(struct sctx *s, fz_point b) total = sqrtf(dx * dx + dy * dy); used = 0; - while (total - used > s->dashlist[s->offset] - s->phase) + while (total - used > s->dash_list[s->offset] - s->phase) { - used += s->dashlist[s->offset] - s->phase; + used += s->dash_list[s->offset] - s->phase; ratio = used / total; m.x = a.x + ratio * dx; m.y = a.y + ratio * dy; if (s->toggle) - fz_strokelineto(s, m); + fz_stroke_lineto(s, m); else - fz_strokemoveto(s, m); + fz_stroke_moveto(s, m); s->toggle = !s->toggle; s->phase = 0; s->offset ++; - if (s->offset == s->dashlen) + if (s->offset == s->dash_len) s->offset = 0; } @@ -637,11 +637,11 @@ fz_dashlineto(struct sctx *s, fz_point b) s->cur = b; if (s->toggle) - fz_strokelineto(s, b); + fz_stroke_lineto(s, b); } static void -fz_dashbezier(struct sctx *s, +fz_dash_bezier(struct sctx *s, float xa, float ya, float xb, float yb, float xc, float yc, @@ -660,12 +660,12 @@ fz_dashbezier(struct sctx *s, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < s->flatness || depth >= MAXDEPTH) + if (dmax < s->flatness || depth >= MAX_DEPTH) { fz_point p; p.x = xd; p.y = yd; - fz_dashlineto(s, p); + fz_dash_lineto(s, p); return; } @@ -693,12 +693,12 @@ fz_dashbezier(struct sctx *s, xabcd *= 0.125f; yabcd *= 0.125f; - fz_dashbezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); - fz_dashbezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); + fz_dash_bezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); + fz_dash_bezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); } void -fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3, beg; @@ -716,16 +716,16 @@ fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, f s.bn = 0; s.dot = 0; - s.dashlist = stroke->dashlist; - s.dashphase = stroke->dashphase; - s.dashlen = stroke->dashlen; + s.dash_list = stroke->dash_list; + s.dash_phase = stroke->dash_phase; + s.dash_len = stroke->dash_len; s.toggle = 0; s.offset = 0; s.phase = 0; i = 0; - if (path->len > 0 && path->els[0].k != FZ_MOVETO) + if (path->len > 0 && path->items[0].k != FZ_MOVETO) { fz_warn("assert: path must begin with moveto"); return; @@ -735,39 +735,39 @@ fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, f while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_dashmoveto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_dash_moveto(&s, p1); beg = p0 = p1; break; case FZ_LINETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_dashlineto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_dash_lineto(&s, p1); p0 = p1; break; case FZ_CURVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - p2.x = path->els[i++].v; - p2.y = path->els[i++].v; - p3.x = path->els[i++].v; - p3.y = path->els[i++].v; - fz_dashbezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + p2.x = path->items[i++].v; + p2.y = path->items[i++].v; + p3.x = path->items[i++].v; + p3.y = path->items[i++].v; + fz_dash_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); p0 = p3; break; - case FZ_CLOSEPATH: - fz_dashlineto(&s, beg); + case FZ_CLOSE_PATH: + fz_dash_lineto(&s, beg); p0 = p1 = beg; break; } } - fz_strokeflush(&s); + fz_stroke_flush(&s); } diff --git a/draw/draw_scale.c b/draw/draw_scale.c index 6254e3e4..f66974d3 100644 --- a/draw/draw_scale.c +++ b/draw/draw_scale.c @@ -77,18 +77,18 @@ dst[j] = SUM(filter(dist[j,i] * F) * F * src[i]) */ -typedef struct fz_scalefilter_s fz_scalefilter; +typedef struct fz_scale_filter_s fz_scale_filter; -struct fz_scalefilter_s +struct fz_scale_filter_s { int width; - float (*fn)(fz_scalefilter *, float); + float (*fn)(fz_scale_filter *, float); }; /* Image scale filters */ static float -triangle(fz_scalefilter *filter, float f) +triangle(fz_scale_filter *filter, float f) { if (f >= 1) return 0; @@ -96,7 +96,7 @@ triangle(fz_scalefilter *filter, float f) } static float -box(fz_scalefilter *filter, float f) +box(fz_scale_filter *filter, float f) { if (f >= 0.5f) return 0; @@ -104,7 +104,7 @@ box(fz_scalefilter *filter, float f) } static float -simple(fz_scalefilter *filter, float x) +simple(fz_scale_filter *filter, float x) { if (x >= 1) return 0; @@ -112,7 +112,7 @@ simple(fz_scalefilter *filter, float x) } static float -lanczos2(fz_scalefilter *filter, float x) +lanczos2(fz_scale_filter *filter, float x) { if (x >= 2) return 0; @@ -120,7 +120,7 @@ lanczos2(fz_scalefilter *filter, float x) } static float -lanczos3(fz_scalefilter *filter, float f) +lanczos3(fz_scale_filter *filter, float f) { if (f >= 3) return 0; @@ -147,7 +147,7 @@ The literature suggests that B=1/3, C=1/3 is best. */ static float -mitchell(fz_scalefilter *filter, float x) +mitchell(fz_scale_filter *filter, float x) { if (x >= 2) return 0; @@ -156,12 +156,12 @@ mitchell(fz_scalefilter *filter, float x) return (16 + x*x*(-36 + 21*x))/18; } -fz_scalefilter fz_scalefilter_box = { 1, box }; -fz_scalefilter fz_scalefilter_triangle = { 1, triangle }; -fz_scalefilter fz_scalefilter_simple = { 1, simple }; -fz_scalefilter fz_scalefilter_lanczos2 = { 2, lanczos2 }; -fz_scalefilter fz_scalefilter_lanczos3 = { 3, lanczos3 }; -fz_scalefilter fz_scalefilter_mitchell = { 2, mitchell }; +fz_scale_filter fz_scale_filter_box = { 1, box }; +fz_scale_filter fz_scale_filter_triangle = { 1, triangle }; +fz_scale_filter fz_scale_filter_simple = { 1, simple }; +fz_scale_filter fz_scale_filter_lanczos2 = { 2, lanczos2 }; +fz_scale_filter fz_scale_filter_lanczos3 = { 3, lanczos3 }; +fz_scale_filter fz_scale_filter_mitchell = { 2, mitchell }; /* We build ourselves a set of tables to contain the precalculated weights @@ -256,7 +256,7 @@ struct fz_weights_s }; static fz_weights * -newweights(fz_scalefilter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip) +new_weights(fz_scale_filter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip) { int max_len; fz_weights *weights; @@ -314,7 +314,7 @@ init_weights(fz_weights *weights, int j) } static void -add_weight(fz_weights *weights, int j, int i, fz_scalefilter *filter, +add_weight(fz_weights *weights, int j, int i, fz_scale_filter *filter, float x, float F, float G, int src_w, float dst_w) { float dist = j - x + 0.5f - ((i + 0.5f)*dst_w/src_w); @@ -474,7 +474,7 @@ check_weights(fz_weights *weights, int j, int w) } static fz_weights * -make_weights(int src_w, float x, float dst_w, fz_scalefilter *filter, int vertical, int dst_w_int, int n, int flip) +make_weights(int src_w, float x, float dst_w, fz_scale_filter *filter, int vertical, int dst_w_int, int n, int flip) { fz_weights *weights; float F, G; @@ -495,7 +495,7 @@ make_weights(int src_w, float x, float dst_w, fz_scalefilter *filter, int vertic } window = filter->width / F; DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window)); - weights = newweights(filter, src_w, dst_w, dst_w_int, n, flip); + weights = new_weights(filter, src_w, dst_w, dst_w_int, n, flip); if (weights == NULL) return NULL; for (j = 0; j < dst_w_int; j++) @@ -841,7 +841,7 @@ scale_single_row(unsigned char *dst, unsigned char *src, fz_weights *weights, in { int *contrib = &weights->index[weights->index[0]]; int min, len, i, j, val, n; - int tmp[FZ_MAXCOLORS]; + int tmp[FZ_MAX_COLORS]; n = weights->n; /* Scale a single row */ @@ -914,7 +914,7 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in { int *contrib = &weights->index[weights->index[0]]; int min, len, i, j, val; - int tmp[FZ_MAXCOLORS]; + int tmp[FZ_MAX_COLORS]; if (flip_y) { @@ -989,9 +989,9 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in #endif /* SINGLE_PIXEL_SPECIALS */ fz_pixmap * -fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h) +fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h) { - fz_scalefilter *filter = &fz_scalefilter_simple; + fz_scale_filter *filter = &fz_scale_filter_simple; fz_weights *contrib_rows = NULL; fz_weights *contrib_cols = NULL; fz_pixmap *output = NULL; @@ -1090,7 +1090,7 @@ fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h) assert(contrib_cols == NULL || contrib_cols->count == dst_w_int); assert(contrib_rows == NULL || contrib_rows->count == dst_h_int); - output = fz_newpixmap(src->colorspace, dst_x_int, dst_y_int, dst_w_int, dst_h_int); + output = fz_new_pixmap(src->colorspace, dst_x_int, dst_y_int, dst_w_int, dst_h_int); if (output == NULL) goto cleanup; diff --git a/draw/draw_unpack.c b/draw/draw_unpack.c index 2c7cb452..b60de3b8 100644 --- a/draw/draw_unpack.c +++ b/draw/draw_unpack.c @@ -8,13 +8,13 @@ #define get8(buf,x) (buf[x]) #define get16(buf,x) (buf[x << 1]) -static unsigned char get1tab1[256][8]; -static unsigned char get1tab1p[256][16]; -static unsigned char get1tab255[256][8]; -static unsigned char get1tab255p[256][16]; +static unsigned char get1_tab_1[256][8]; +static unsigned char get1_tab_1p[256][16]; +static unsigned char get1_tab_255[256][8]; +static unsigned char get1_tab_255p[256][16]; static void -initget1tables(void) +init_get1_tables(void) { static int once = 0; unsigned char bits[1]; @@ -32,13 +32,13 @@ initget1tables(void) { x = get1(bits, k); - get1tab1[i][k] = x; - get1tab1p[i][k * 2] = x; - get1tab1p[i][k * 2 + 1] = 255; + get1_tab_1[i][k] = x; + get1_tab_1p[i][k * 2] = x; + get1_tab_1p[i][k * 2 + 1] = 255; - get1tab255[i][k] = x * 255; - get1tab255p[i][k * 2] = x * 255; - get1tab255p[i][k * 2 + 1] = 255; + get1_tab_255[i][k] = x * 255; + get1_tab_255p[i][k * 2] = x * 255; + get1_tab_255p[i][k * 2 + 1] = 255; } } @@ -46,7 +46,7 @@ initget1tables(void) } void -fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale) +fz_unpack_tile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale) { int pad, x, y, k; int w = dst->w; @@ -56,7 +56,7 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in pad = 255; if (depth == 1) - initget1tables(); + init_get1_tables(); if (scale == 0) { @@ -80,12 +80,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab1[*sp++], 8); + memcpy(dp, get1_tab_1[*sp++], 8); dp += 8; } x = x << 3; if (x < w) - memcpy(dp, get1tab1[*sp], w - x); + memcpy(dp, get1_tab_1[*sp], w - x); } else if (n == 1 && depth == 1 && scale == 255 && !pad) @@ -93,12 +93,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab255[*sp++], 8); + memcpy(dp, get1_tab_255[*sp++], 8); dp += 8; } x = x << 3; if (x < w) - memcpy(dp, get1tab255[*sp], w - x); + memcpy(dp, get1_tab_255[*sp], w - x); } else if (n == 1 && depth == 1 && scale == 1 && pad) @@ -106,12 +106,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab1p[*sp++], 16); + memcpy(dp, get1_tab_1p[*sp++], 16); dp += 16; } x = x << 3; if (x < w) - memcpy(dp, get1tab1p[*sp], (w - x) << 1); + memcpy(dp, get1_tab_1p[*sp], (w - x) << 1); } else if (n == 1 && depth == 1 && scale == 255 && pad) @@ -119,12 +119,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab255p[*sp++], 16); + memcpy(dp, get1_tab_255p[*sp++], 16); dp += 16; } x = x << 3; if (x < w) - memcpy(dp, get1tab255p[*sp], (w - x) << 1); + memcpy(dp, get1_tab_255p[*sp], (w - x) << 1); } else if (depth == 8 && !pad) @@ -171,10 +171,10 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in /* Apply decode array */ void -fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval) +fz_decode_indexed_tile(fz_pixmap *pix, float *decode, int maxval) { - int add[FZ_MAXCOLORS]; - int mul[FZ_MAXCOLORS]; + int add[FZ_MAX_COLORS]; + int mul[FZ_MAX_COLORS]; unsigned char *p = pix->samples; int len = pix->w * pix->h; int n = pix->n - 1; @@ -203,10 +203,10 @@ fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval) } void -fz_decodetile(fz_pixmap *pix, float *decode) +fz_decode_tile(fz_pixmap *pix, float *decode) { - int add[FZ_MAXCOLORS]; - int mul[FZ_MAXCOLORS]; + int add[FZ_MAX_COLORS]; + int mul[FZ_MAX_COLORS]; unsigned char *p = pix->samples; int len = pix->w * pix->h; int n = MAX(1, pix->n - 1); -- cgit v1.2.3