mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 00:40:09 +00:00
(drivers_font) Cut down on unnecessary strlen calls within a for loop
- precompute once for function duration
This commit is contained in:
parent
198df77c29
commit
3e9d0b8758
@ -89,6 +89,7 @@ static void caca_render_msg(
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_msg_pos_x = settings->floats.video_msg_pos_x;
|
||||
float video_msg_pos_y = settings->floats.video_msg_pos_y;
|
||||
size_t _msg_len = strlen(msg);
|
||||
|
||||
if (!font || string_is_empty(msg))
|
||||
return;
|
||||
@ -119,10 +120,10 @@ static void caca_render_msg(
|
||||
switch (align)
|
||||
{
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
newX = (x * width * scale) - strlen(msg);
|
||||
newX = (x * width * scale) - _msg_len;
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
newX = (x * width * scale) - (strlen(msg) / 2);
|
||||
newX = (x * width * scale) - (_msg_len / 2);
|
||||
break;
|
||||
case TEXT_ALIGN_LEFT:
|
||||
default:
|
||||
|
@ -312,9 +312,10 @@ static void ctr_font_render_message(
|
||||
const unsigned int color, float pos_x, float pos_y,
|
||||
unsigned width, unsigned height, unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = strlen(msg);
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
@ -323,7 +324,7 @@ static void ctr_font_render_message(
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
ctr_font_render_line(ctr, font, msg, strlen(msg),
|
||||
ctr_font_render_line(ctr, font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y,
|
||||
width, height, text_align);
|
||||
return;
|
||||
@ -347,7 +348,7 @@ static void ctr_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = (unsigned)_msg_len;
|
||||
ctr_font_render_line(ctr, font, msg, msg_len,
|
||||
scale, color, pos_x, pos_y - (float)lines * line_height,
|
||||
width, height, text_align);
|
||||
|
@ -237,19 +237,22 @@ static void d3d10_font_render_message(
|
||||
unsigned height,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
d3d10_font_render_line(d3d10,
|
||||
font, msg, strlen(msg), scale, color, pos_x, pos_y,
|
||||
font, msg, (unsigned)_msg_len, scale, color, pos_x, pos_y,
|
||||
width, height, text_align);
|
||||
return;
|
||||
}
|
||||
@ -273,7 +276,7 @@ static void d3d10_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = (unsigned)_msg_len;
|
||||
d3d10_font_render_line(d3d10,
|
||||
font, msg, msg_len, scale, color, pos_x,
|
||||
pos_y - (float)lines * line_height,
|
||||
|
@ -234,19 +234,22 @@ static void d3d11_font_render_message(
|
||||
unsigned height,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
d3d11_font_render_line(d3d11,
|
||||
font, msg, strlen(msg), scale, color, pos_x, pos_y,
|
||||
font, msg, (unsigned)_msg_len, scale, color, pos_x, pos_y,
|
||||
width, height, text_align);
|
||||
return;
|
||||
}
|
||||
@ -270,7 +273,7 @@ static void d3d11_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = (unsigned)_msg_len;
|
||||
d3d11_font_render_line(d3d11,
|
||||
font, msg, msg_len, scale, color, pos_x,
|
||||
pos_y - (float)lines * line_height,
|
||||
|
@ -248,19 +248,22 @@ static void d3d12_font_render_message(
|
||||
unsigned height,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
d3d12_font_render_line(d3d12,
|
||||
font, msg, strlen(msg),
|
||||
font, msg, _msg_len,
|
||||
scale, color, pos_x, pos_y, width, height, text_align);
|
||||
return;
|
||||
}
|
||||
@ -283,7 +286,7 @@ static void d3d12_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = (unsigned)_msg_len;
|
||||
d3d12_font_render_line(d3d12,
|
||||
font, msg, msg_len, scale, color, pos_x,
|
||||
pos_y - (float)lines * line_height, width, height, text_align);
|
||||
|
@ -120,7 +120,7 @@ static int d3dfonts_w32_get_message_width(void* data, const char* msg,
|
||||
return 0;
|
||||
|
||||
d3d9x_font_draw_text(d3dfonts->font, NULL, (void*)msg,
|
||||
msg_len? msg_len : -1, &box, DT_CALCRECT, 0);
|
||||
msg_len ? msg_len : -1, &box, DT_CALCRECT, 0);
|
||||
|
||||
return box.right - box.left;
|
||||
}
|
||||
|
@ -90,12 +90,13 @@ static void gdi_render_msg(
|
||||
const struct font_params *params)
|
||||
{
|
||||
float x, y, scale, drop_mod, drop_alpha;
|
||||
int drop_x, drop_y, msg_strlen;
|
||||
int drop_x, drop_y;
|
||||
unsigned i;
|
||||
unsigned newX, newY, newDropX, newDropY;
|
||||
unsigned align;
|
||||
unsigned red, green, blue;
|
||||
unsigned drop_red, drop_green, drop_blue;
|
||||
size_t _msg_len = 0;
|
||||
gdi_t *gdi = (gdi_t*)userdata;
|
||||
gdi_raster_t *font = (gdi_raster_t*)data;
|
||||
unsigned width = gdi->video_width;
|
||||
@ -142,9 +143,9 @@ static void gdi_render_msg(
|
||||
blue = video_msg_color_b * 255.0f;
|
||||
}
|
||||
|
||||
msg_strlen = strlen(msg);
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
GetTextExtentPoint32(font->gdi->memDC, msg, msg_strlen, &textSize);
|
||||
GetTextExtentPoint32(font->gdi->memDC, msg, (int)_msg_len, &textSize);
|
||||
|
||||
switch (align)
|
||||
{
|
||||
@ -166,21 +167,21 @@ static void gdi_render_msg(
|
||||
break;
|
||||
}
|
||||
|
||||
newY = height - (y * height * scale) - textSize.cy;
|
||||
newDropY = height - (drop_y * height * scale) - textSize.cy;
|
||||
newY = height - (y * height * scale) - textSize.cy;
|
||||
newDropY = height - (drop_y * height * scale) - textSize.cy;
|
||||
|
||||
font->gdi->bmp_old = (HBITMAP)SelectObject(font->gdi->memDC, font->gdi->bmp);
|
||||
|
||||
SetBkMode(font->gdi->memDC, TRANSPARENT);
|
||||
|
||||
msg_list = string_split(msg, "\n");
|
||||
msg_list = string_split(msg, "\n");
|
||||
|
||||
if (drop_x || drop_y)
|
||||
{
|
||||
float dark_alpha = drop_alpha;
|
||||
drop_red = red * drop_mod * dark_alpha;
|
||||
drop_green = green * drop_mod * dark_alpha;
|
||||
drop_blue = blue * drop_mod * dark_alpha;
|
||||
drop_red = red * drop_mod * dark_alpha;
|
||||
drop_green = green * drop_mod * dark_alpha;
|
||||
drop_blue = blue * drop_mod * dark_alpha;
|
||||
|
||||
SetTextColor(font->gdi->memDC, RGB(drop_red, drop_green, drop_blue));
|
||||
|
||||
|
@ -382,16 +382,22 @@ static void gl1_raster_font_render_message(
|
||||
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
gl1_raster_font_render_line(font,
|
||||
msg, (unsigned)strlen(msg), scale, color, pos_x,
|
||||
msg, (unsigned)_msg_len, scale, color, pos_x,
|
||||
pos_y, text_align);
|
||||
return;
|
||||
}
|
||||
@ -402,7 +408,7 @@ static void gl1_raster_font_render_message(
|
||||
{
|
||||
const char *delim = strchr(msg, '\n');
|
||||
unsigned msg_len = delim
|
||||
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
|
||||
? (unsigned)(delim - msg) : (unsigned)_msg_len;
|
||||
|
||||
/* Draw the line */
|
||||
gl1_raster_font_render_line(font,
|
||||
|
@ -293,16 +293,22 @@ static void gl_core_raster_font_render_message(
|
||||
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
gl_core_raster_font_render_line(font,
|
||||
msg, (unsigned)strlen(msg), scale, color, pos_x,
|
||||
msg, _msg_len, scale, color, pos_x,
|
||||
pos_y, text_align);
|
||||
return;
|
||||
}
|
||||
@ -313,7 +319,7 @@ static void gl_core_raster_font_render_message(
|
||||
{
|
||||
const char *delim = strchr(msg, '\n');
|
||||
unsigned msg_len = delim
|
||||
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
|
||||
? (unsigned)(delim - msg) : _msg_len;
|
||||
|
||||
/* Draw the line */
|
||||
gl_core_raster_font_render_line(font,
|
||||
|
@ -362,16 +362,22 @@ static void gl_raster_font_render_message(
|
||||
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
gl_raster_font_render_line(font,
|
||||
msg, (unsigned)strlen(msg), scale, color, pos_x,
|
||||
msg, (unsigned)_msg_len, scale, color, pos_x,
|
||||
pos_y, text_align);
|
||||
return;
|
||||
}
|
||||
@ -382,7 +388,7 @@ static void gl_raster_font_render_message(
|
||||
{
|
||||
const char *delim = strchr(msg, '\n');
|
||||
unsigned msg_len = delim
|
||||
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
|
||||
? (unsigned)(delim - msg) : (unsigned)_msg_len;
|
||||
|
||||
/* Draw the line */
|
||||
gl_raster_font_render_line(font,
|
||||
|
@ -350,18 +350,25 @@ static INLINE void write_quad6(SpriteVertex *pv,
|
||||
posY:(float)posY
|
||||
aligned:(unsigned)aligned
|
||||
{
|
||||
float line_height;
|
||||
int lines = 0;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!_font_driver->get_line_metrics ||
|
||||
!_font_driver->get_line_metrics(_font_data, &line_metrics))
|
||||
{
|
||||
[self _renderLine:msg length:strlen(msg) scale:scale color:color posX:posX posY:posY aligned:aligned];
|
||||
[self _renderLine:msg length:(unsigned)_msg_len scale:scale color:color posX:posX posY:posY aligned:aligned];
|
||||
return;
|
||||
}
|
||||
|
||||
int lines = 0;
|
||||
float line_height = line_metrics->height * scale / height;
|
||||
line_height = line_metrics->height * scale / height;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -383,7 +390,7 @@ static INLINE void write_quad6(SpriteVertex *pv,
|
||||
}
|
||||
else
|
||||
{
|
||||
NSUInteger msg_len = strlen(msg);
|
||||
NSUInteger msg_len = (NSUInteger)_msg_len;
|
||||
[self _renderLine:msg
|
||||
length:msg_len
|
||||
scale:scale
|
||||
|
@ -83,17 +83,20 @@ static void sixel_render_msg(
|
||||
{
|
||||
float x, y, scale;
|
||||
unsigned width, height;
|
||||
unsigned newX, newY;
|
||||
unsigned new_x, new_y;
|
||||
unsigned align;
|
||||
sixel_raster_t *font = (sixel_raster_t*)data;
|
||||
const struct font_params *params = (const struct font_params*)_params;
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_msg_pos_x = settings->floats.video_msg_pos_x;
|
||||
float video_msg_pos_y = settings->floats.video_msg_pos_y;
|
||||
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!font || string_is_empty(msg))
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
if (params)
|
||||
{
|
||||
x = params->x;
|
||||
@ -114,19 +117,19 @@ static void sixel_render_msg(
|
||||
|
||||
width = font->sixel->screen_width;
|
||||
height = font->sixel->screen_height;
|
||||
newY = height - (y * height * scale);
|
||||
new_y = height - (y * height * scale);
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
newX = (x * width * scale) - strlen(msg);
|
||||
new_x = (x * width * scale) - _msg_len;
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
newX = (x * width * scale) - (strlen(msg) / 2);
|
||||
new_x = (x * width * scale) - (_msg_len / 2);
|
||||
break;
|
||||
case TEXT_ALIGN_LEFT:
|
||||
default:
|
||||
newX = x * width * scale;
|
||||
new_x = x * width * scale;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -193,22 +193,24 @@ static void switch_font_render_message(
|
||||
const unsigned int color, float pos_x, float pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
int msgLen = strlen(msg);
|
||||
if (msgLen <= AVG_GLPYH_LIMIT)
|
||||
if (_msg_len <= AVG_GLPYH_LIMIT)
|
||||
{
|
||||
if (sw)
|
||||
switch_font_render_line(sw, font, msg, strlen(msg),
|
||||
switch_font_render_line(sw, font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y, text_align);
|
||||
}
|
||||
return;
|
||||
@ -235,11 +237,10 @@ static void switch_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
if (msg_len <= AVG_GLPYH_LIMIT)
|
||||
if (_msg_len <= AVG_GLPYH_LIMIT)
|
||||
{
|
||||
if (sw)
|
||||
switch_font_render_line(sw, font, msg, msg_len,
|
||||
switch_font_render_line(sw, font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y - (float)lines * line_height,
|
||||
text_align);
|
||||
}
|
||||
|
@ -89,10 +89,13 @@ static void vga_render_msg(
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_msg_pos_x = settings->floats.video_msg_pos_x;
|
||||
float video_msg_pos_y = settings->floats.video_msg_pos_y;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!font || string_is_empty(msg))
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
if (params)
|
||||
{
|
||||
x = params->x;
|
||||
@ -121,10 +124,10 @@ static void vga_render_msg(
|
||||
new_x = x * width * scale;
|
||||
break;
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
new_x = (x * width * scale) - strlen(msg);
|
||||
new_x = (x * width * scale) - _msg_len;
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
new_x = (x * width * scale) - (strlen(msg) / 2);
|
||||
new_x = (x * width * scale) - (_msg_len / 2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -225,18 +225,21 @@ static void vita2d_font_render_message(
|
||||
const unsigned int color, float pos_x, float pos_y,
|
||||
unsigned width, unsigned height, unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
vita2d_font_render_line(font, msg, strlen(msg),
|
||||
vita2d_font_render_line(font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y, width, height, text_align);
|
||||
return;
|
||||
}
|
||||
@ -246,7 +249,7 @@ static void vita2d_font_render_message(
|
||||
for (;;)
|
||||
{
|
||||
const char *delim = strchr(msg, '\n');
|
||||
unsigned msg_len = (delim) ? (delim - msg) : strlen(msg);
|
||||
unsigned msg_len = (delim) ? (delim - msg) : (unsigned)_msg_len;
|
||||
|
||||
vita2d_font_render_line(font, msg, msg_len,
|
||||
scale, color, pos_x, pos_y - (float)lines * line_height,
|
||||
|
@ -233,19 +233,22 @@ static void vulkan_raster_font_render_message(
|
||||
const float color[4], float pos_x, float pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg || !font->vk)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
if (font->vk)
|
||||
vulkan_raster_font_render_line(font, msg, strlen(msg),
|
||||
vulkan_raster_font_render_line(font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y, text_align);
|
||||
return;
|
||||
}
|
||||
@ -269,7 +272,7 @@ static void vulkan_raster_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = _msg_len;
|
||||
if (font->vk)
|
||||
vulkan_raster_font_render_line(font, msg, msg_len,
|
||||
scale, color, pos_x, pos_y - (float)lines * line_height,
|
||||
|
@ -109,7 +109,7 @@ static void wiiu_font_free_font(void* data, bool is_threaded)
|
||||
}
|
||||
|
||||
static int wiiu_font_get_message_width(void* data, const char* msg,
|
||||
unsigned msg_len, float scale)
|
||||
unsigned msg_len, float scale)
|
||||
{
|
||||
wiiu_font_t* font = (wiiu_font_t*)data;
|
||||
|
||||
@ -150,7 +150,9 @@ static void wiiu_font_render_line(
|
||||
float pos_y,
|
||||
unsigned width, unsigned height, unsigned text_align)
|
||||
{
|
||||
int count;
|
||||
unsigned i;
|
||||
sprite_vertex_t *v = NULL;
|
||||
int x = roundf(pos_x * width);
|
||||
int y = roundf((1.0 - pos_y) * height);
|
||||
|
||||
@ -169,7 +171,7 @@ static void wiiu_font_render_line(
|
||||
break;
|
||||
}
|
||||
|
||||
sprite_vertex_t* v = wiiu->vertex_cache.v + wiiu->vertex_cache.current;
|
||||
v = wiiu->vertex_cache.v + wiiu->vertex_cache.current;
|
||||
|
||||
for (i = 0; i < msg_len; i++)
|
||||
{
|
||||
@ -207,7 +209,7 @@ static void wiiu_font_render_line(
|
||||
y += glyph->advance_y * scale;
|
||||
}
|
||||
|
||||
int count = v - wiiu->vertex_cache.v - wiiu->vertex_cache.current;
|
||||
count = v - wiiu->vertex_cache.v - wiiu->vertex_cache.current;
|
||||
|
||||
if (!count)
|
||||
return;
|
||||
@ -241,18 +243,21 @@ static void wiiu_font_render_message(
|
||||
const unsigned int color, float pos_x, float pos_y,
|
||||
unsigned width, unsigned height, unsigned text_align)
|
||||
{
|
||||
float line_height;
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
size_t _msg_len = 0;
|
||||
|
||||
if (!msg || !*msg)
|
||||
return;
|
||||
|
||||
_msg_len = strlen(msg);
|
||||
|
||||
/* If font line metrics are not supported just draw as usual */
|
||||
if (!font->font_driver->get_line_metrics ||
|
||||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
|
||||
{
|
||||
wiiu_font_render_line(wiiu, font, msg, strlen(msg),
|
||||
wiiu_font_render_line(wiiu, font, msg, (unsigned)_msg_len,
|
||||
scale, color, pos_x, pos_y,
|
||||
width, height, text_align);
|
||||
return;
|
||||
@ -276,7 +281,7 @@ static void wiiu_font_render_message(
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned msg_len = strlen(msg);
|
||||
unsigned msg_len = (unsigned)_msg_len;
|
||||
wiiu_font_render_line(wiiu, font, msg, msg_len,
|
||||
scale, color, pos_x, pos_y - (float)lines * line_height,
|
||||
width, height, text_align);
|
||||
|
Loading…
x
Reference in New Issue
Block a user