Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/fonts: Refactor glyph-rotation helpers

Change the signatures of the glyph-rotation helpers to match their
public interfaces. Drop the inline qualifier.

Rename several variables to better match their meaning. Especially
rename variables to bit_pitch (or a variant thereof) if they store
a pitch value in bits per scanline. The original code is fairly
confusing about this. Move the calculation of the bit pitch into the
new helper font_glyph_bit_pitch().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Thomas Zimmermann and committed by
Helge Deller
a30e9e6b 6ad4ed84

+46 -33
+46 -33
lib/fonts/font_rotate.c
··· 15 15 16 16 #include "font.h" 17 17 18 + /* number of bits per line */ 19 + static unsigned int font_glyph_bit_pitch(unsigned int width) 20 + { 21 + return round_up(width, 8); 22 + } 23 + 18 24 static unsigned int __font_glyph_pos(unsigned int x, unsigned int y, unsigned int bit_pitch, 19 25 unsigned int *bit) 20 26 { ··· 50 44 glyph[i] |= bit; 51 45 } 52 46 53 - static inline void rotate_cw(const char *in, char *out, u32 width, u32 height) 47 + static void __font_glyph_rotate_90(const unsigned char *glyph, 48 + unsigned int width, unsigned int height, 49 + unsigned char *out) 54 50 { 55 - int i, j, h = height, w = width; 56 - int shift = (8 - (height % 8)) & 7; 51 + unsigned int x, y; 52 + unsigned int shift = (8 - (height % 8)) & 7; 53 + unsigned int bit_pitch = font_glyph_bit_pitch(width); 54 + unsigned int out_bit_pitch = font_glyph_bit_pitch(height); 57 55 58 - width = (width + 7) & ~7; 59 - height = (height + 7) & ~7; 60 - 61 - for (i = 0; i < h; i++) { 62 - for (j = 0; j < w; j++) { 63 - if (font_glyph_test_bit(in, j, i, width)) 64 - font_glyph_set_bit(out, height - 1 - i - shift, j, height); 56 + for (y = 0; y < height; y++) { 57 + for (x = 0; x < width; x++) { 58 + if (font_glyph_test_bit(glyph, x, y, bit_pitch)) { 59 + font_glyph_set_bit(out, out_bit_pitch - 1 - y - shift, x, 60 + out_bit_pitch); 61 + } 65 62 } 66 63 } 67 64 } ··· 88 79 { 89 80 memset(out, 0, font_glyph_size(height, width)); /* flip width/height */ 90 81 91 - rotate_cw(glyph, out, width, height); 82 + __font_glyph_rotate_90(glyph, width, height, out); 92 83 } 93 84 EXPORT_SYMBOL_GPL(font_glyph_rotate_90); 94 85 95 - static inline void rotate_ud(const char *in, char *out, u32 width, u32 height) 86 + static void __font_glyph_rotate_180(const unsigned char *glyph, 87 + unsigned int width, unsigned int height, 88 + unsigned char *out) 96 89 { 97 - int i, j; 98 - int shift = (8 - (width % 8)) & 7; 90 + unsigned int x, y; 91 + unsigned int shift = (8 - (width % 8)) & 7; 92 + unsigned int bit_pitch = font_glyph_bit_pitch(width); 99 93 100 - width = (width + 7) & ~7; 101 - 102 - for (i = 0; i < height; i++) { 103 - for (j = 0; j < width - shift; j++) { 104 - if (font_glyph_test_bit(in, j, i, width)) 105 - font_glyph_set_bit(out, width - (1 + j + shift), 106 - height - (1 + i), width); 94 + for (y = 0; y < height; y++) { 95 + for (x = 0; x < width; x++) { 96 + if (font_glyph_test_bit(glyph, x, y, bit_pitch)) { 97 + font_glyph_set_bit(out, width - (1 + x + shift), height - (1 + y), 98 + bit_pitch); 99 + } 107 100 } 108 101 } 109 102 } ··· 126 115 { 127 116 memset(out, 0, font_glyph_size(width, height)); 128 117 129 - rotate_ud(glyph, out, width, height); 118 + __font_glyph_rotate_180(glyph, width, height, out); 130 119 } 131 120 EXPORT_SYMBOL_GPL(font_glyph_rotate_180); 132 121 133 - static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height) 122 + static void __font_glyph_rotate_270(const unsigned char *glyph, 123 + unsigned int width, unsigned int height, 124 + unsigned char *out) 134 125 { 135 - int i, j, h = height, w = width; 136 - int shift = (8 - (width % 8)) & 7; 126 + unsigned int x, y; 127 + unsigned int shift = (8 - (width % 8)) & 7; 128 + unsigned int bit_pitch = font_glyph_bit_pitch(width); 129 + unsigned int out_bit_pitch = font_glyph_bit_pitch(height); 137 130 138 - width = (width + 7) & ~7; 139 - height = (height + 7) & ~7; 140 - 141 - for (i = 0; i < h; i++) { 142 - for (j = 0; j < w; j++) { 143 - if (font_glyph_test_bit(in, j, i, width)) 144 - font_glyph_set_bit(out, i, width - 1 - j - shift, height); 131 + for (y = 0; y < height; y++) { 132 + for (x = 0; x < width; x++) { 133 + if (font_glyph_test_bit(glyph, x, y, bit_pitch)) 134 + font_glyph_set_bit(out, y, bit_pitch - 1 - x - shift, 135 + out_bit_pitch); 145 136 } 146 137 } 147 138 } ··· 167 154 { 168 155 memset(out, 0, font_glyph_size(height, width)); /* flip width/height */ 169 156 170 - rotate_ccw(glyph, out, width, height); 157 + __font_glyph_rotate_270(glyph, width, height, out); 171 158 } 172 159 EXPORT_SYMBOL_GPL(font_glyph_rotate_270);