wdvi

network DVI viewer
Log | Files | Refs

commit 618d9d85b7d2bb3da750e6666e68f0733f9a8ee4
parent 45c819c32aa4af91b40dbca82734cd83c8795328
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu,  9 Mar 2023 03:44:12 +0000

cleanup shrink_glyph_grey()

- ansi function signature
- if statement bodies on newline
- indentation

Diffstat:
Mdvi-draw.c | 94++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 48 insertions(+), 46 deletions(-)

diff --git a/dvi-draw.c b/dvi-draw.c @@ -379,8 +379,7 @@ sample(BMUNIT *bits, int bytes_wide, int bit_skip, int w, int h) static void -shrink_glyph_grey(g) - struct glyph *g; +shrink_glyph_grey(struct glyph *g) { int rows_left, rows, init_cols; int cols_left; @@ -392,78 +391,81 @@ shrink_glyph_grey(g) int rtmp; unsigned int depth; - if (fg_active != fg_current) do_color_change(); + if (fg_active != fg_current) + do_color_change(); /* These machinations ensure that the character is shrunk according to its hot point, rather than its upper left-hand corner. */ g->x2 = g->x / shrink_factor; init_cols = g->x - g->x2 * shrink_factor; - if (init_cols <= 0) init_cols += shrink_factor; - else ++g->x2; + if (init_cols <= 0) + init_cols += shrink_factor; + else + ++g->x2; g->bitmap2.w = g->x2 + ROUNDUP((int) g->bitmap.w - g->x, shrink_factor); /* include row zero with the positively numbered rows */ rtmp = g->y + 1; g->y2 = rtmp / shrink_factor; rows = rtmp - g->y2 * shrink_factor; if (rows <= 0) { - rows += shrink_factor; - --g->y2; + rows += shrink_factor; + --g->y2; } - g->bitmap2.h = g->y2 + ROUNDUP((int) g->bitmap.h - rtmp, shrink_factor) - + 1; + g->bitmap2.h = g->y2 + ROUNDUP((int) g->bitmap.h - rtmp, shrink_factor) + 1; if (g->pixmap2 == NULL) { depth = DefaultDepthOfScreen(SCRN); - g->image2 = XCreateImage(DISP, CopyFromParent, depth, ZPixmap, - 0, (char *) NULL, g->bitmap2.w, g->bitmap2.h, BMBITS, 0); - size = g->image2->bytes_per_line * g->bitmap2.h; - g->pixmap2 = g->image2->data = xmalloc(size != 0 ? size : 1); + g->image2 = XCreateImage(DISP, CopyFromParent, depth, ZPixmap, 0, + (char *) NULL, g->bitmap2.w, g->bitmap2.h, + BMBITS, 0); + size = g->image2->bytes_per_line * g->bitmap2.h; + g->pixmap2 = g->image2->data = xmalloc(size != 0 ? size : 1); } if (foreGC2 != NULL && g->pixmap2_t == NULL) { - size = g->image2->bytes_per_line * g->bitmap2.h; - g->pixmap2_t = xmalloc(size != 0 ? size : 1); + size = g->image2->bytes_per_line * g->bitmap2.h; + g->pixmap2_t = xmalloc(size != 0 ? size : 1); } old_ptr = (BMUNIT *) g->bitmap.bits; rows_left = g->bitmap.h; y = 0; while (rows_left) { - x = 0; - if (rows > rows_left) rows = rows_left; - cols_left = g->bitmap.w; - cols = init_cols; - while (cols_left) { - if (cols > cols_left) cols = cols_left; - - thesample = sample(old_ptr, g->bitmap.bytes_wide, - (int) g->bitmap.w - cols_left, cols, rows); - XPutPixel(g->image2, x, y, pixeltbl[thesample]); - if (foreGC2 != NULL) { - g->image2->data = g->pixmap2_t; - XPutPixel(g->image2, x, y, pixeltbl_t[thesample]); - g->image2->data = g->pixmap2; - } + x = 0; + if (rows > rows_left) rows = rows_left; + cols_left = g->bitmap.w; + cols = init_cols; + while (cols_left) { + if (cols > cols_left) cols = cols_left; + + thesample = sample(old_ptr, g->bitmap.bytes_wide, + (int) g->bitmap.w - cols_left, cols, rows); + XPutPixel(g->image2, x, y, pixeltbl[thesample]); + if (foreGC2 != NULL) { + g->image2->data = g->pixmap2_t; + XPutPixel(g->image2, x, y, pixeltbl_t[thesample]); + g->image2->data = g->pixmap2; + } - cols_left -= cols; - cols = shrink_factor; - x++; - } - *((char **) &old_ptr) += rows * g->bitmap.bytes_wide; - rows_left -= rows; - rows = shrink_factor; - y++; + cols_left -= cols; + cols = shrink_factor; + x++; + } + *((char **) &old_ptr) += rows * g->bitmap.bytes_wide; + rows_left -= rows; + rows = shrink_factor; + y++; } while (y < (int) g->bitmap2.h) { - for (x = 0; x < (int) g->bitmap2.w; x++) { - XPutPixel(g->image2, x, y, *pixeltbl); - if (foreGC2 != NULL) { - g->image2->data = g->pixmap2_t; - XPutPixel(g->image2, x, y, *pixeltbl_t); - g->image2->data = g->pixmap2; + for (x = 0; x < (int) g->bitmap2.w; x++) { + XPutPixel(g->image2, x, y, *pixeltbl); + if (foreGC2 != NULL) { + g->image2->data = g->pixmap2_t; + XPutPixel(g->image2, x, y, *pixeltbl_t); + g->image2->data = g->pixmap2; + } } - } - y++; + y++; } g->y2 = g->y / shrink_factor;