Skip to content

Commit

Permalink
Get rid of font_driver_flush
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jun 15, 2023
1 parent 3861e6e commit 0c51321
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
16 changes: 5 additions & 11 deletions gfx/font_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, siz
: buffer;
unsigned char *dst = (unsigned char*)dst_buffer;


while (*src || reverse)
{
if (reverse)
Expand All @@ -696,7 +697,7 @@ static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, siz
else if (replacement < 0x800)
{
*dst++ = 0xC0 | (replacement >> 6);
*dst++ = 0x80 | (replacement & 0x3F);
*dst++ = 0x80 | (replacement & 0x3F);
}
else if (replacement < 0x10000)
{
Expand All @@ -705,14 +706,14 @@ static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, siz
src -= 2;

*dst++ = 0xE0 | ( replacement >> 12);
*dst++ = 0x80 | ((replacement >> 6) & 0x3F);
*dst++ = 0x80 | ( replacement & 0x3F);
*dst++ = 0x80 | ((replacement >> 6) & 0x3F);
*dst++ = 0x80 | ( replacement & 0x3F);
}
else
{
*dst++ = 0xF0 | (replacement >> 18);
*dst++ = 0x80 | ((replacement >> 12) & 0x3F);
*dst++ = 0x80 | ((replacement >> 6) & 0x3F);
*dst++ = 0x80 | ((replacement >> 6) & 0x3F);
*dst++ = 0x80 | ( replacement & 0x3F);
}

Expand Down Expand Up @@ -792,13 +793,6 @@ void font_driver_bind_block(void *font_data, void *block)
font->renderer->bind_block(font->renderer_data, block);
}

void font_driver_flush(unsigned width, unsigned height, void *font_data)
{
font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver);
if (font && font->renderer && font->renderer->flush)
font->renderer->flush(width, height, font->renderer_data);
}

int font_driver_get_message_width(void *font_data,
const char *msg, size_t len, float scale)
{
Expand Down
2 changes: 0 additions & 2 deletions gfx/font_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ void font_driver_bind_block(void *font_data, void *block);

int font_driver_get_message_width(void *font_data, const char *msg, size_t len, float scale);

void font_driver_flush(unsigned width, unsigned height, void *font_data);

void font_driver_free(font_data_t *font);

font_data_t *font_driver_init_first(
Expand Down
3 changes: 2 additions & 1 deletion gfx/gfx_widgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ void gfx_widgets_flush_text(
if (!font_data || (font_data->usage_count == 0))
return;

font_driver_flush(video_width, video_height, font_data->font);
if (font_data->font && font_data->font->renderer && font_data->font->renderer->flush)
font_data->font->renderer->flush(video_width, video_height, font_data->font->renderer_data);
font_data->raster_block.carr.coords.vertices = 0;
font_data->usage_count = 0;
}
Expand Down
5 changes: 3 additions & 2 deletions menu/drivers/materialui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2206,13 +2206,14 @@ static void INLINE materialui_font_unbind(materialui_font_data_t *font_data)

/* Flushing is slow - only do it if font
* has actually been used */
void materialui_font_flush(
static void materialui_font_flush(
unsigned video_width, unsigned video_height,
materialui_font_data_t *font_data)
{
if (font_data->raster_block.carr.coords.vertices == 0)
return;
font_driver_flush(video_width, video_height, font_data->font);
if (font_data->font && font_data->font->renderer && font_data->font->renderer->flush)
font_data->font->renderer->flush(video_width, video_height, font_data->font->renderer_data);
font_data->raster_block.carr.coords.vertices = 0;
}

Expand Down
7 changes: 4 additions & 3 deletions menu/drivers/ozone.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ typedef struct
{
font_data_t *font;
video_font_raster_block_t raster_block; /* ptr alignment */
int glyph_width;
int wideglyph_width;
unsigned glyph_width;
unsigned wideglyph_width;
int line_height;
int line_ascender;
int line_centre_offset;
Expand Down Expand Up @@ -2844,7 +2844,8 @@ static void ozone_font_flush(
{
if (font_data->raster_block.carr.coords.vertices == 0)
return;
font_driver_flush(video_width, video_height, font_data->font);
if (font_data->font && font_data->font->renderer && font_data->font->renderer->flush)
font_data->font->renderer->flush(video_width, video_height, font_data->font->renderer_data);
font_data->raster_block.carr.coords.vertices = 0;
}

Expand Down
6 changes: 4 additions & 2 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6336,8 +6336,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
if (dispctx && dispctx->blend_end)
dispctx->blend_end(userdata);

font_driver_flush(video_width, video_height, xmb->font);
font_driver_flush(video_width, video_height, xmb->font2);
if (xmb->font && xmb->font->renderer && xmb->font->renderer->flush)
xmb->font->renderer->flush(video_width, video_height, xmb->font->renderer_data);
if (xmb->font2 && xmb->font2->renderer && xmb->font2->renderer->flush)
xmb->font2->renderer->flush(video_width, video_height, xmb->font2->renderer_data);
font_driver_bind_block(xmb->font, NULL);
font_driver_bind_block(xmb->font2, NULL);

Expand Down
19 changes: 10 additions & 9 deletions menu/menu_screensaver.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,14 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
unsigned video_height;
video_driver_state_t *video_st = video_state_get_ptr();
void *userdata = NULL;

font_data_t *font = NULL;
if (!screensaver)
return;

video_width = video_info->width;
video_height = video_info->height;
userdata = video_info->userdata;
font = screensaver->font_data.font;
video_width = video_info->width;
video_height = video_info->height;
userdata = video_info->userdata;

/* Set viewport */
if (video_st->current_video && video_st->current_video->set_viewport)
Expand All @@ -779,11 +780,10 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
NULL);

/* Draw particle effect, if required */
if ((screensaver->effect != MENU_SCREENSAVER_BLANK) &&
screensaver->font_data.font &&
screensaver->particles)
if ( (screensaver->effect != MENU_SCREENSAVER_BLANK)
&& font
&& screensaver->particles)
{
font_data_t *font = screensaver->font_data.font;
float y_centre_offset = screensaver->font_data.y_centre_offset;
float particle_scale = screensaver->particle_scale;
size_t i;
Expand Down Expand Up @@ -812,7 +812,8 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
/* Flush text and unbind font */
if (screensaver->font_data.raster_block.carr.coords.vertices != 0)
{
font_driver_flush(video_width, video_height, font);
if (font->renderer && font->renderer->flush)
font->renderer->flush(video_width, video_height, font->renderer_data);
screensaver->font_data.raster_block.carr.coords.vertices = 0;
}
font_driver_bind_block(font, NULL);
Expand Down

0 comments on commit 0c51321

Please sign in to comment.