mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
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>
This commit is contained in:
parent
6ad4ed8408
commit
a30e9e6b01
|
|
@ -15,6 +15,12 @@
|
|||
|
||||
#include "font.h"
|
||||
|
||||
/* number of bits per line */
|
||||
static unsigned int font_glyph_bit_pitch(unsigned int width)
|
||||
{
|
||||
return round_up(width, 8);
|
||||
}
|
||||
|
||||
static unsigned int __font_glyph_pos(unsigned int x, unsigned int y, unsigned int bit_pitch,
|
||||
unsigned int *bit)
|
||||
{
|
||||
|
|
@ -44,18 +50,21 @@ static void font_glyph_set_bit(unsigned char *glyph, unsigned int x, unsigned in
|
|||
glyph[i] |= bit;
|
||||
}
|
||||
|
||||
static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
|
||||
static void __font_glyph_rotate_90(const unsigned char *glyph,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char *out)
|
||||
{
|
||||
int i, j, h = height, w = width;
|
||||
int shift = (8 - (height % 8)) & 7;
|
||||
unsigned int x, y;
|
||||
unsigned int shift = (8 - (height % 8)) & 7;
|
||||
unsigned int bit_pitch = font_glyph_bit_pitch(width);
|
||||
unsigned int out_bit_pitch = font_glyph_bit_pitch(height);
|
||||
|
||||
width = (width + 7) & ~7;
|
||||
height = (height + 7) & ~7;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
if (font_glyph_test_bit(in, j, i, width))
|
||||
font_glyph_set_bit(out, height - 1 - i - shift, j, height);
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
|
||||
font_glyph_set_bit(out, out_bit_pitch - 1 - y - shift, x,
|
||||
out_bit_pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -79,22 +88,24 @@ void font_glyph_rotate_90(const unsigned char *glyph, unsigned int width, unsign
|
|||
{
|
||||
memset(out, 0, font_glyph_size(height, width)); /* flip width/height */
|
||||
|
||||
rotate_cw(glyph, out, width, height);
|
||||
__font_glyph_rotate_90(glyph, width, height, out);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(font_glyph_rotate_90);
|
||||
|
||||
static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
|
||||
static void __font_glyph_rotate_180(const unsigned char *glyph,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char *out)
|
||||
{
|
||||
int i, j;
|
||||
int shift = (8 - (width % 8)) & 7;
|
||||
unsigned int x, y;
|
||||
unsigned int shift = (8 - (width % 8)) & 7;
|
||||
unsigned int bit_pitch = font_glyph_bit_pitch(width);
|
||||
|
||||
width = (width + 7) & ~7;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width - shift; j++) {
|
||||
if (font_glyph_test_bit(in, j, i, width))
|
||||
font_glyph_set_bit(out, width - (1 + j + shift),
|
||||
height - (1 + i), width);
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
|
||||
font_glyph_set_bit(out, width - (1 + x + shift), height - (1 + y),
|
||||
bit_pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,22 +126,24 @@ void font_glyph_rotate_180(const unsigned char *glyph, unsigned int width, unsig
|
|||
{
|
||||
memset(out, 0, font_glyph_size(width, height));
|
||||
|
||||
rotate_ud(glyph, out, width, height);
|
||||
__font_glyph_rotate_180(glyph, width, height, out);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(font_glyph_rotate_180);
|
||||
|
||||
static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
|
||||
static void __font_glyph_rotate_270(const unsigned char *glyph,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned char *out)
|
||||
{
|
||||
int i, j, h = height, w = width;
|
||||
int shift = (8 - (width % 8)) & 7;
|
||||
unsigned int x, y;
|
||||
unsigned int shift = (8 - (width % 8)) & 7;
|
||||
unsigned int bit_pitch = font_glyph_bit_pitch(width);
|
||||
unsigned int out_bit_pitch = font_glyph_bit_pitch(height);
|
||||
|
||||
width = (width + 7) & ~7;
|
||||
height = (height + 7) & ~7;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
if (font_glyph_test_bit(in, j, i, width))
|
||||
font_glyph_set_bit(out, i, width - 1 - j - shift, height);
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
if (font_glyph_test_bit(glyph, x, y, bit_pitch))
|
||||
font_glyph_set_bit(out, y, bit_pitch - 1 - x - shift,
|
||||
out_bit_pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,6 +167,6 @@ void font_glyph_rotate_270(const unsigned char *glyph, unsigned int width, unsig
|
|||
{
|
||||
memset(out, 0, font_glyph_size(height, width)); /* flip width/height */
|
||||
|
||||
rotate_ccw(glyph, out, width, height);
|
||||
__font_glyph_rotate_270(glyph, width, height, out);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(font_glyph_rotate_270);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user