lib/fonts/font_rotate.c

Source file repositories/reference/linux-study-clean/lib/fonts/font_rotate.c

File Facts

System
Linux kernel
Corpus path
lib/fonts/font_rotate.c
Extension
.c
Size
8526 bytes
Lines
276
Domain
Kernel Services
Bucket
lib
Inferred role
Kernel Services: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

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);
			}
		}
	}
}

/**
 * font_glyph_rotate_90 - Rotate a glyph pattern by 90° in clockwise direction
 * @glyph: The glyph to rotate
 * @width: The glyph width in bits per scanline
 * @height: The number of scanlines in the glyph
 * @out: The rotated glyph bitmap
 *
 * The parameters @width and @height refer to the input glyph given in @glyph.
 * The caller has to provide the output buffer @out of sufficient size to hold
 * the rotated glyph. Rotating by 90° flips the width and height for the output
 * glyph. Depending on the glyph pitch, the size of the output glyph can be
 * different than the size of the input. Callers have to take this into account
 * when allocating the output memory.
 */
void font_glyph_rotate_90(const unsigned char *glyph, unsigned int width, unsigned int height,
			  unsigned char *out)
{
	memset(out, 0, font_glyph_size(height, width)); /* flip width/height */

	__font_glyph_rotate_90(glyph, width, height, out);
}
EXPORT_SYMBOL_GPL(font_glyph_rotate_90);

static void __font_glyph_rotate_180(const unsigned char *glyph,
				    unsigned int width, unsigned int height,
				    unsigned char *out)
{
	unsigned int x, y;
	unsigned int shift = (8 - (width % 8)) & 7;
	unsigned int bit_pitch = font_glyph_bit_pitch(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, bit_pitch - 1 - x - shift, height - 1 - y,
						   bit_pitch);
			}
		}
	}
}

/**
 * font_glyph_rotate_180 - Rotate a glyph pattern by 180°
 * @glyph: The glyph to rotate
 * @width: The glyph width in bits per scanline
 * @height: The number of scanlines in the glyph
 * @out: The rotated glyph bitmap
 *
 * The parameters @width and @height refer to the input glyph given in @glyph.
 * The caller has to provide the output buffer @out of sufficient size to hold
 * the rotated glyph.
 */
void font_glyph_rotate_180(const unsigned char *glyph, unsigned int width, unsigned int height,
			   unsigned char *out)
{
	memset(out, 0, font_glyph_size(width, height));

	__font_glyph_rotate_180(glyph, width, height, out);
}
EXPORT_SYMBOL_GPL(font_glyph_rotate_180);

static void __font_glyph_rotate_270(const unsigned char *glyph,
				    unsigned int width, unsigned int height,
				    unsigned char *out)
{
	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);

	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);
		}
	}
}

/**
 * font_glyph_rotate_270 - Rotate a glyph pattern by 270° in clockwise direction
 * @glyph: The glyph to rotate

Annotation

Implementation Notes