mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-19 08:46:57 +00:00
Untested: Rewrite omap_gfx font rendering.
This commit is contained in:
parent
f118817fae
commit
9a861fba6d
@ -708,7 +708,8 @@ static void omap_gfx_free(void *data) {
|
||||
static void omap_init_font(omap_video_t *vid, const char *font_path, unsigned font_size) {
|
||||
if (!g_settings.video.font_enable) return;
|
||||
|
||||
if (font_renderer_create_default(&vid->font_driver, &vid->font)) {
|
||||
if (font_renderer_create_default(&vid->font_driver, &vid->font,
|
||||
*g_settings.video.font_path ? g_settings.video.font_path : NULL, g_settings.video.font_size)) {
|
||||
int r = g_settings.video.msg_color_r * 255;
|
||||
int g = g_settings.video.msg_color_g * 255;
|
||||
int b = g_settings.video.msg_color_b * 255;
|
||||
@ -726,18 +727,19 @@ static void omap_init_font(omap_video_t *vid, const char *font_path, unsigned fo
|
||||
}
|
||||
|
||||
static void omap_render_msg(omap_video_t *vid, const char *msg) {
|
||||
struct font_output_list out;
|
||||
struct font_output *head;
|
||||
|
||||
const int msg_base_x = g_settings.video.msg_pos_x * vid->width;
|
||||
const int msg_base_y = (1.0 - g_settings.video.msg_pos_y) * vid->height;
|
||||
int msg_base_x = g_settings.video.msg_pos_x * vid->width;
|
||||
int msg_base_y = (1.0 - g_settings.video.msg_pos_y) * vid->height;
|
||||
|
||||
if (vid->font == NULL) return;
|
||||
vid->font_driver->render_msg(vid->font, msg, &out);
|
||||
|
||||
for (head = out.head; head; head = head->next) {
|
||||
int base_x = msg_base_x + head->off_x;
|
||||
int base_y = msg_base_y - head->off_y - head->height;
|
||||
const struct font_atlas *atlas = vid->font_driver->get_atlas(vid->font);
|
||||
|
||||
for (; *msg; msg++) {
|
||||
const struct font_glyph *glyph = vid->font_driver->get_glyph(vid->font, (uint8_t)*msg);
|
||||
if (!glyph) continue;
|
||||
|
||||
int base_x = msg_base_x + glyph->draw_offset_x;
|
||||
int base_y = msg_base_y + glyph->draw_offset_y;
|
||||
|
||||
const int max_width = vid->width - base_x;
|
||||
const int max_height = vid->height - base_y;
|
||||
@ -745,7 +747,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) {
|
||||
int glyph_width = head->width;
|
||||
int glyph_height = head->height;
|
||||
|
||||
const uint8_t *src = head->output;
|
||||
const uint8_t *src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width;
|
||||
|
||||
if (base_x < 0) {
|
||||
src -= base_x;
|
||||
@ -754,7 +756,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) {
|
||||
}
|
||||
|
||||
if (base_y < 0) {
|
||||
src -= base_y * (int)head->pitch;
|
||||
src -= base_y * (int)atlas->width;
|
||||
glyph_height += base_y;
|
||||
base_y = 0;
|
||||
}
|
||||
@ -767,15 +769,16 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) {
|
||||
if (vid->bytes_per_pixel == 2) {
|
||||
omapfb_blend_glyph_rgb565(vid->omap, src, vid->font_rgb,
|
||||
glyph_width, glyph_height,
|
||||
head->pitch, base_x, base_y);
|
||||
atlas->width, base_x, base_y);
|
||||
} else {
|
||||
omapfb_blend_glyph_argb8888(vid->omap, src, vid->font_rgb,
|
||||
glyph_width, glyph_height,
|
||||
head->pitch, base_x, base_y);
|
||||
atlas->width, base_x, base_y);
|
||||
}
|
||||
}
|
||||
|
||||
vid->font_driver->free_output(vid->font, &out);
|
||||
msg_base_x += glyph->advance_x;
|
||||
msg_base_y += glyph->advance_y;
|
||||
}
|
||||
}
|
||||
|
||||
static void *omap_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) {
|
||||
|
Loading…
Reference in New Issue
Block a user