Change msg_len of font driver to size_t - avoids all the type

casting/conversion
This commit is contained in:
LibretroAdmin 2022-09-02 01:10:28 +02:00
parent 77e83a4e60
commit 0ffdd14940
33 changed files with 138 additions and 134 deletions

View File

@ -367,7 +367,7 @@
{
float r, g, b, a;
int msg_width =
font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f);
font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f);
float font_size = settings->floats.video_font_size;
unsigned bgcolor_red
= settings->uints.video_msg_bgcolor_red;

View File

@ -2318,7 +2318,7 @@ static void gl2_render_osd_background(gl2_t *gl, const char *msg)
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
int msg_width =
font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f);
font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f);
/* shader driver expects vertex coords as 0..1 */
float x = settings->floats.video_msg_pos_x;

View File

@ -72,7 +72,7 @@ static void caca_font_free(void *data, bool is_threaded)
}
static int caca_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
return 0;
}

View File

@ -122,9 +122,9 @@ static void ctr_font_free(void* data, bool is_threaded)
}
static int ctr_font_get_message_width(void* data, const char* msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
unsigned i;
int i;
int delta_x = 0;
const struct font_glyph* glyph_q = NULL;
ctr_font_t* font = (ctr_font_t*)data;
@ -159,7 +159,7 @@ static int ctr_font_get_message_width(void* data, const char* msg,
static void ctr_font_render_line(
ctr_video_t *ctr,
ctr_font_t* font, const char* msg, unsigned msg_len,
ctr_font_t* font, const char* msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y,
unsigned width, unsigned height, unsigned text_align)
@ -309,7 +309,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))
{
unsigned msg_len = strlen(msg);
size_t msg_len = strlen(msg);
ctr_font_render_line(ctr, font, msg, msg_len,
scale, color, pos_x, pos_y,
width, height, text_align);
@ -321,8 +321,8 @@ static void ctr_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
ctr_font_render_line(ctr, font, msg, msg_len,

View File

@ -85,9 +85,9 @@ static void d3d10_font_free(void* data, bool is_threaded)
free(font);
}
static int d3d10_font_get_message_width(void* data, const char* msg, unsigned msg_len, float scale)
static int d3d10_font_get_message_width(void* data, const char* msg, size_t msg_len, float scale)
{
unsigned i;
int i;
int delta_x = 0;
const struct font_glyph* glyph_q = NULL;
d3d10_font_t* font = (d3d10_font_t*)data;
@ -122,7 +122,7 @@ static void d3d10_font_render_line(
d3d10_video_t *d3d10,
d3d10_font_t* font,
const char* msg,
unsigned msg_len,
size_t msg_len,
float scale,
const unsigned int color,
float pos_x,
@ -250,7 +250,7 @@ static void d3d10_font_render_message(
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
unsigned msg_len = strlen(msg);
size_t msg_len = strlen(msg);
if (msg_len <= (unsigned)d3d10->sprites.capacity)
d3d10_font_render_line(d3d10,
font, msg, msg_len, scale, color, pos_x, pos_y,
@ -263,8 +263,8 @@ static void d3d10_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
if (msg_len <= (unsigned)d3d10->sprites.capacity)

View File

@ -83,14 +83,13 @@ static void d3d11_font_free(void* data, bool is_threaded)
free(font);
}
static int d3d11_font_get_message_width(void* data, const char* msg, unsigned msg_len, float scale)
static int d3d11_font_get_message_width(void* data, const char* msg, size_t msg_len, float scale)
{
int i;
int delta_x = 0;
const struct font_glyph* glyph_q = NULL;
d3d11_font_t* font = (d3d11_font_t*)data;
unsigned i;
int delta_x = 0;
if (!font)
return 0;
@ -121,7 +120,7 @@ static void d3d11_font_render_line(
d3d11_video_t* d3d11,
d3d11_font_t* font,
const char* msg,
unsigned msg_len,
size_t msg_len,
float scale,
const unsigned int color,
float pos_x,
@ -130,7 +129,8 @@ static void d3d11_font_render_line(
unsigned height,
unsigned text_align)
{
unsigned i, count;
int i;
unsigned count;
D3D11_MAPPED_SUBRESOURCE mapped_vbo;
d3d11_sprite_t *v = NULL;
const struct font_glyph* glyph_q = NULL;
@ -254,7 +254,7 @@ static void d3d11_font_render_message(
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
unsigned msg_len = strlen(msg);
size_t msg_len = strlen(msg);
if (msg_len <= (unsigned)d3d11->sprites.capacity)
d3d11_font_render_line(d3d11,
font, msg, msg_len, scale, color, pos_x, pos_y,
@ -267,8 +267,8 @@ static void d3d11_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
if (msg_len <= (unsigned)d3d11->sprites.capacity)

View File

@ -85,10 +85,9 @@ static void d3d12_font_free(void* data, bool is_threaded)
}
static int d3d12_font_get_message_width(void* data,
const char* msg, unsigned msg_len, float scale)
const char* msg, size_t msg_len, float scale)
{
unsigned i;
int delta_x = 0;
int i, delta_x = 0;
const struct font_glyph* glyph_q = NULL;
d3d12_font_t* font = (d3d12_font_t*)data;
@ -122,7 +121,7 @@ static void d3d12_font_render_line(
d3d12_video_t *d3d12,
d3d12_font_t* font,
const char* msg,
unsigned msg_len,
size_t msg_len,
float scale,
const unsigned int color,
float pos_x,
@ -131,8 +130,9 @@ static void d3d12_font_render_line(
unsigned height,
unsigned text_align)
{
int i;
D3D12_RANGE range;
unsigned i, count;
unsigned count;
const struct font_glyph* glyph_q = NULL;
void* mapped_vbo = NULL;
d3d12_sprite_t* v = NULL;
@ -256,8 +256,8 @@ static void d3d12_font_render_message(
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
unsigned msg_len = strlen(msg);
if (msg_len <= (unsigned)d3d12->sprites.capacity)
size_t msg_len = strlen(msg);
if (msg_len <= d3d12->sprites.capacity)
d3d12_font_render_line(d3d12,
font, msg, msg_len,
scale, color, pos_x, pos_y, width, height, text_align);
@ -269,11 +269,11 @@ static void d3d12_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
if (msg_len <= (unsigned)d3d12->sprites.capacity)
if (msg_len <= d3d12->sprites.capacity)
d3d12_font_render_line(d3d12,
font, msg, msg_len, scale, color, pos_x,
pos_y - (float)lines * line_height, width, height, text_align);

View File

@ -111,7 +111,7 @@ static void d3d_win32_font_free(void *data, bool is_threaded)
}
static int d3d_win32_font_get_message_width(void* data, const char* msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
RECT box = {0,0,0,0};
d3dfonts_t *d3dfonts = (d3dfonts_t*)data;
@ -120,7 +120,7 @@ static int d3d_win32_font_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;
}

View File

@ -83,10 +83,11 @@ static void gdi_font_render_msg(
const char *msg,
const struct font_params *params)
{
int i;
char* msg_local;
size_t msg_len;
float x, y, scale, drop_mod, drop_alpha;
int drop_x, drop_y, msg_strlen;
unsigned i;
int drop_x, drop_y;
unsigned new_x, new_y, new_drop_x, new_drop_y;
unsigned align;
unsigned red, green, blue;
@ -137,9 +138,9 @@ static void gdi_font_render_msg(
}
msg_local = utf8_to_local_string_alloc(msg);
msg_strlen = strlen(msg_local);
msg_len = strlen(msg_local);
GetTextExtentPoint32(font->gdi->memDC, msg_local, msg_strlen, &text_size);
GetTextExtentPoint32(font->gdi->memDC, msg_local, (int)msg_len, &text_size);
switch (align)
{

View File

@ -174,10 +174,10 @@ error:
}
static int gl1_raster_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
const struct font_glyph* glyph_q = NULL;
gl1_raster_t *font = (gl1_raster_t*)data;
gl1_raster_t *font = (gl1_raster_t*)data;
const char* msg_end = msg + msg_len;
int delta_x = 0;
@ -264,11 +264,11 @@ static void gl1_raster_font_draw_vertices(gl1_raster_t *font,
}
static void gl1_raster_font_render_line(gl1_t *gl,
gl1_raster_t *font, const char *msg, unsigned msg_len,
gl1_raster_t *font, const char *msg, size_t msg_len,
GLfloat scale, const GLfloat color[4], GLfloat pos_x,
GLfloat pos_y, unsigned text_align)
{
unsigned i;
int i;
struct video_coords coords;
const struct font_glyph* glyph_q = NULL;
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
@ -370,8 +370,8 @@ static void gl1_raster_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
size_t msg_len = delim
? (delim - msg) : strlen(msg);
/* Draw the line */
gl1_raster_font_render_line(font->gl, font,

View File

@ -85,7 +85,7 @@ static void gl2_raster_font_free(void *data,
static bool gl2_raster_font_upload_atlas(gl2_raster_t *font)
{
unsigned i, j;
int i, j;
GLint gl_internal = GL_LUMINANCE_ALPHA;
GLenum gl_format = GL_LUMINANCE_ALPHA;
size_t ncomponents = 2;
@ -178,7 +178,7 @@ error:
}
static int gl2_raster_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
const struct font_glyph* glyph_q = NULL;
gl2_raster_t *font = (gl2_raster_t*)data;
@ -230,11 +230,11 @@ static void gl2_raster_font_draw_vertices(gl2_raster_t *font,
}
static void gl2_raster_font_render_line(gl2_t *gl,
gl2_raster_t *font, const char *msg, unsigned msg_len,
gl2_raster_t *font, const char *msg, size_t msg_len,
GLfloat scale, const GLfloat color[4], GLfloat pos_x,
GLfloat pos_y, unsigned text_align)
{
unsigned i;
int i;
struct video_coords coords;
const struct font_glyph* glyph_q = NULL;
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
@ -326,7 +326,7 @@ static void gl2_raster_font_render_message(
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
gl2_raster_font_render_line(font->gl, font,
msg, (unsigned)strlen(msg), scale, color, pos_x,
msg, strlen(msg), scale, color, pos_x,
pos_y, text_align);
return;
}
@ -336,8 +336,8 @@ static void gl2_raster_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
size_t msg_len = delim
? (delim - msg) : strlen(msg);
/* Draw the line */
gl2_raster_font_render_line(font->gl, font,

View File

@ -137,7 +137,7 @@ error:
}
static int gl3_raster_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
const struct font_glyph* glyph_q = NULL;
gl3_raster_t *font = (gl3_raster_t*)data;
@ -208,11 +208,11 @@ static void gl3_raster_font_draw_vertices(gl3_raster_t *font,
}
static void gl3_raster_font_render_line(gl3_t *gl,
gl3_raster_t *font, const char *msg, unsigned msg_len,
gl3_raster_t *font, const char *msg, size_t msg_len,
GLfloat scale, const GLfloat color[4], GLfloat pos_x,
GLfloat pos_y, unsigned text_align)
{
unsigned i;
int i;
struct video_coords coords;
const struct font_glyph* glyph_q = NULL;
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
@ -303,7 +303,7 @@ static void gl3_raster_font_render_message(
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
gl3_raster_font_render_line(font->gl, font,
msg, (unsigned)strlen(msg), scale, color, pos_x,
msg, strlen(msg), scale, color, pos_x,
pos_y, text_align);
return;
}
@ -313,8 +313,8 @@ static void gl3_raster_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
size_t msg_len = delim
? (delim - msg) : strlen(msg);
/* Draw the line */
gl3_raster_font_render_line(font->gl, font,

View File

@ -101,11 +101,12 @@
}
else
{
int i;
_buffer = [_context.device newBufferWithLength:(NSUInteger)(_stride * _atlas->height)
options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
void *dst = _buffer.contents;
void *src = _atlas->buffer;
for (unsigned i = 0; i < _atlas->height; i++)
for (i = 0; i < _atlas->height; i++)
{
memcpy(dst, src, _atlas->width);
dst += _stride;
@ -242,7 +243,7 @@ static INLINE void write_quad6(SpriteVertex *pv,
float tex_x, float tex_y, float tex_width, float tex_height,
const vector_float4 *color)
{
unsigned i;
int i;
static const float strip[2 * 6] = {
0.0f, 0.0f,
0.0f, 1.0f,
@ -526,10 +527,10 @@ static void metal_raster_font_free(void *data, bool is_threaded)
}
static int metal_raster_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
MetalRaster *r = (__bridge MetalRaster *)data;
return [r getWidthForMessage:msg length:msg_len scale:scale];
return [r getWidthForMessage:msg length:(unsigned)msg_len scale:scale];
}
static void metal_raster_font_render_msg(

View File

@ -104,10 +104,10 @@ static void ps2_font_free(void* data, bool is_threaded)
}
static int ps2_font_get_message_width(void* data, const char* msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
int i;
const struct font_glyph* glyph_q = NULL;
unsigned i;
int delta_x = 0;
ps2_font_t* font = (ps2_font_t*)data;
@ -140,12 +140,12 @@ static int ps2_font_get_message_width(void* data, const char* msg,
static void ps2_font_render_line(
ps2_video_t *ps2,
ps2_font_t* font, const char* msg, unsigned msg_len,
ps2_font_t* font, const char* msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y,
unsigned width, unsigned height, unsigned text_align)
{
unsigned i;
int i;
const struct font_glyph* glyph_q = NULL;
int x = roundf(pos_x * width);
int y = roundf((1.0f - pos_y) * height);
@ -258,8 +258,8 @@ static void ps2_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
ps2_font_render_line(ps2, font, msg, msg_len,

View File

@ -201,7 +201,7 @@ error:
}
static int rsx_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
const struct font_glyph* glyph_q = NULL;
rsx_font_t *font = (rsx_font_t*)data;
@ -236,7 +236,7 @@ static int rsx_font_get_message_width(void *data, const char *msg,
static void rsx_font_draw_vertices(rsx_font_t *font,
const video_coords_t *coords)
{
unsigned i;
int i;
const float *vertex = coords->vertex;
const float *tex_coord = coords->tex_coord;
const float *color = coords->color;
@ -270,17 +270,17 @@ static void rsx_font_draw_vertices(rsx_font_t *font,
}
static void rsx_font_render_line(
rsx_font_t *font, const char *msg, unsigned msg_len,
rsx_font_t *font, const char *msg, size_t msg_len,
float scale, const float color[4], float pos_x,
float pos_y,unsigned text_align)
{
unsigned i;
int i;
struct video_coords coords;
const struct font_glyph* glyph_q = NULL;
float font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
float font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
float font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
rsx_t *rsx = font->rsx;
rsx_t *rsx = font->rsx;
const char* msg_end = msg + msg_len;
int x = roundf(pos_x * rsx->vp.width);
int y = roundf(pos_y * rsx->vp.height);
@ -376,8 +376,8 @@ static void rsx_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
size_t msg_len = delim
? (delim - msg) : strlen(msg);
/* Draw the line */
rsx_font_render_line(font,

View File

@ -70,7 +70,7 @@ static void sixel_font_free(void *data, bool is_threaded)
}
static int sixel_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale) { return 0; }
size_t msg_len, float scale) { return 0; }
static const struct font_glyph *sixel_font_get_glyph(
void *data, uint32_t code) { return NULL; }

View File

@ -75,9 +75,9 @@ static void switch_font_free(void *data, bool is_threaded)
}
static int switch_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
unsigned i;
int i;
const struct font_glyph* glyph_q = NULL;
int delta_x = 0;
switch_font_t *font = (switch_font_t *)data;
@ -111,11 +111,11 @@ static int switch_font_get_message_width(void *data, const char *msg,
static void switch_font_render_line(
switch_video_t *sw,
switch_font_t *font, const char *msg, unsigned msg_len,
switch_font_t *font, const char *msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y, unsigned text_align)
{
unsigned i;
int i;
const struct font_glyph* glyph_q = NULL;
int delta_x = 0;
int delta_y = 0;
@ -201,7 +201,7 @@ static void switch_font_render_message(
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
int msg_len = strlen(msg);
size_t msg_len = strlen(msg);
if (msg_len <= AVG_GLPYH_LIMIT)
switch_font_render_line(sw, font, msg, msg_len,
scale, color, pos_x, pos_y, text_align);
@ -213,8 +213,8 @@ static void switch_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
if (msg_len <= AVG_GLPYH_LIMIT)

View File

@ -72,7 +72,7 @@ static void vga_font_render_free(void *data, bool is_threaded)
}
static int vga_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale) { return 0; }
size_t msg_len, float scale) { return 0; }
static const struct font_glyph *vga_font_get_glyph(
void *data, uint32_t code) { return NULL; }

View File

@ -107,9 +107,9 @@ static void vita2d_font_free(void *data, bool is_threaded)
}
static int vita2d_font_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
unsigned i;
int i;
const struct font_glyph* glyph_q = NULL;
int delta_x = 0;
vita_font_t *font = (vita_font_t*)data;
@ -141,12 +141,12 @@ static int vita2d_font_get_message_width(void *data, const char *msg,
}
static void vita2d_font_render_line(
vita_font_t *font, const char *msg, unsigned msg_len,
vita_font_t *font, const char *msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y,
unsigned width, unsigned height, unsigned text_align)
{
unsigned i;
int i;
const struct font_glyph* glyph_q = NULL;
int x = roundf(pos_x * width);
int y = roundf((1.0f - pos_y) * height);
@ -244,8 +244,8 @@ static void vita2d_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = (delim) ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = (delim) ?
(delim - msg) : strlen(msg);
/* Draw the line */
vita2d_font_render_line(font, msg, msg_len,

View File

@ -110,7 +110,7 @@ static void *vulkan_font_init(void *data,
}
static int vulkan_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
const struct font_glyph* glyph_q = NULL;
vulkan_raster_t *font = (vulkan_raster_t*)data;
@ -149,7 +149,7 @@ static int vulkan_get_message_width(void *data, const char *msg,
}
static void vulkan_font_render_line(vk_t *vk,
vulkan_raster_t *font, const char *msg, unsigned msg_len,
vulkan_raster_t *font, const char *msg, size_t msg_len,
float scale, const float color[4], float pos_x,
float pos_y, unsigned text_align)
{
@ -258,8 +258,8 @@ static void vulkan_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = delim
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
size_t msg_len = delim
? (delim - msg) : strlen(msg);
/* Draw the line */
vulkan_font_render_line(font->vk, font, msg, msg_len,

View File

@ -112,9 +112,9 @@ static void wiiu_font_free(void* data, bool is_threaded)
}
static int wiiu_font_get_message_width(void* data, const char* msg,
unsigned msg_len, float scale)
size_t msg_len, float scale)
{
unsigned i;
int i;
int delta_x = 0;
const struct font_glyph* glyph_q = NULL;
wiiu_font_t *font = (wiiu_font_t*)data;
@ -148,12 +148,12 @@ static int wiiu_font_get_message_width(void* data, const char* msg,
static void wiiu_font_render_line(
wiiu_video_t *wiiu,
wiiu_font_t* font, const char* msg, unsigned msg_len,
wiiu_font_t* font, const char* msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y,
unsigned width, unsigned height, unsigned text_align)
{
unsigned i;
int i;
int count;
sprite_vertex_t *v;
const struct font_glyph* glyph_q = NULL;
@ -259,7 +259,7 @@ static void wiiu_font_render_message(
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
unsigned msg_len = strlen(msg);
size_t msg_len = strlen(msg);
if (wiiu->vertex_cache.current + (msg_len * 4) <= wiiu->vertex_cache.size)
wiiu_font_render_line(wiiu, font, msg, msg_len,
scale, color, pos_x, pos_y,
@ -272,8 +272,8 @@ static void wiiu_font_render_message(
for (;;)
{
const char* delim = strchr(msg, '\n');
unsigned msg_len = delim ?
(unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ?
(delim - msg) : strlen(msg);
/* Draw the line */
if (wiiu->vertex_cache.current + (msg_len * 4) <= wiiu->vertex_cache.size)

View File

@ -1014,7 +1014,7 @@ int font_driver_get_message_width(void *font_data,
if (len == 0 && msg)
len = strlen(msg);
if (font && font->renderer && font->renderer->get_message_width)
return font->renderer->get_message_width(font->renderer_data, msg, (unsigned)len, scale);
return font->renderer->get_message_width(font->renderer_data, msg, len, scale);
return -1;
}

View File

@ -106,7 +106,7 @@ typedef struct font_renderer
void (*bind_block)(void *data, void *block);
void (*flush)(unsigned width, unsigned height, void *data);
int (*get_message_width)(void *data, const char *msg, unsigned msg_len_full, float scale);
int (*get_message_width)(void *data, const char *msg, size_t msg_len, float scale);
bool (*get_line_metrics)(void* data, struct font_line_metrics **metrics);
} font_renderer_t;

View File

@ -260,7 +260,7 @@ void gfx_widgets_msg_queue_push(
{
title = msg_widget->msg = strdup(task->title);
msg_widget->msg_new = strdup(title);
msg_widget->msg_len = (unsigned)strlen(title);
msg_widget->msg_len = strlen(title);
msg_widget->task_error = !string_is_empty(task->error);
msg_widget->task_cancelled = task->cancelled;
@ -286,7 +286,7 @@ void gfx_widgets_msg_queue_push(
/* Compute rect width, wrap if necessary */
/* Single line text > two lines text > two lines
* text with expanded width */
unsigned title_length = (unsigned)strlen(title);
size_t title_length = strlen(title);
char *msg = NULL;
size_t msg_len = 0;
unsigned width = menu_is_alive
@ -346,7 +346,8 @@ void gfx_widgets_msg_queue_push(
if (!string_is_equal(task->title, msg_widget->msg_new))
{
unsigned len, new_width;
size_t len;
unsigned new_width;
if (msg_widget->msg_new)
{
@ -356,7 +357,7 @@ void gfx_widgets_msg_queue_push(
title = msg_widget->msg_new = strdup(task->title);
len = (unsigned)strlen(title);
len = strlen(title);
new_width = font_driver_get_message_width(
p_dispwidget->gfx_widget_fonts.msg_queue.font,
title,
@ -1110,7 +1111,7 @@ static int gfx_widgets_draw_indicator(
width = font_driver_get_message_width(
p_dispwidget->gfx_widget_fonts.regular.font,
txt,
(unsigned)strlen(txt), 1.0f)
strlen(txt), 1.0f)
+ p_dispwidget->simple_widget_padding * 2;
gfx_display_draw_quad(
@ -1630,7 +1631,7 @@ void gfx_widgets_frame(void *data)
int text_width = font_driver_get_message_width(
p_dispwidget->gfx_widget_fonts.regular.font,
text,
(unsigned)strlen(text), 1.0f);
strlen(text), 1.0f);
int total_width = text_width
+ p_dispwidget->simple_widget_padding * 2;

View File

@ -117,7 +117,7 @@ typedef struct disp_widget_msg
retro_task_t *task_ptr;
uint32_t task_ident;
unsigned msg_len;
size_t msg_len;
unsigned duration;
unsigned text_height;
unsigned width;

View File

@ -178,7 +178,7 @@ void gfx_widget_set_generic_message(
/* Get background width */
text_width = font_driver_get_message_width(
font_msg_queue->font, state->message,
(unsigned)strlen(state->message), 1.0f);
strlen(state->message), 1.0f);
if (text_width < 0)
text_width = 0;
state->bg_width = (state->text_padding * 2) + (unsigned)text_width;
@ -272,7 +272,7 @@ static void gfx_widget_generic_message_layout(
{
text_width = font_driver_get_message_width(
font_msg_queue->font, state->message,
(unsigned)strlen(state->message), 1.0f);
strlen(state->message), 1.0f);
if (text_width < 0)
text_width = 0;

View File

@ -172,7 +172,7 @@ void gfx_widget_set_libretro_message(
state->bg_width = (state->text_padding * 2) +
font_driver_get_message_width(
font_msg_queue->font, state->message,
(unsigned)strlen(state->message), 1.0f);
strlen(state->message), 1.0f);
/* If a 'slide in' animation is already in
* progress, no further action is required;
@ -236,7 +236,7 @@ static void gfx_widget_libretro_message_layout(
if (!string_is_empty(state->message))
state->bg_width += font_driver_get_message_width(
font_msg_queue->font, state->message,
(unsigned)strlen(state->message), 1.0f);
strlen(state->message), 1.0f);
}
/* Widget iterate() */

View File

@ -598,10 +598,10 @@ static void gfx_widget_load_content_animation_iterate(void *user_data,
/* Get overall text width */
content_name_width = font_driver_get_message_width(
font_bold->font, state->content_name,
(unsigned)strlen(state->content_name), 1.0f);
strlen(state->content_name), 1.0f);
system_name_width = font_driver_get_message_width(
font_regular->font, state->system_name,
(unsigned)strlen(state->system_name), 1.0f);
strlen(state->system_name), 1.0f);
state->content_name_width = (content_name_width > 0) ?
(unsigned)content_name_width : 0;

View File

@ -151,7 +151,7 @@ void gfx_widget_set_progress_message(
state->text_width = font_driver_get_message_width(
font_regular->font,
state->message,
(unsigned)strlen(state->message),
strlen(state->message),
1.0f);
/* Kill any existing timer/animation */

View File

@ -2665,7 +2665,7 @@ static void materialui_render_messagebox(
if (!string_is_empty(line))
{
int width = font_driver_get_message_width(
mui->font_data.list.font, line, (unsigned)strlen(line), 1.0f);
mui->font_data.list.font, line, strlen(line), 1.0f);
longest_width = (width > longest_width) ?
width : longest_width;
}
@ -5662,7 +5662,7 @@ static void materialui_render_header(
font_driver_get_message_width(
mui->font_data.hint.font,
mui->sys_bar_cache.battery_percent_str,
(unsigned)strlen(mui->sys_bar_cache.battery_percent_str),
strlen(mui->sys_bar_cache.battery_percent_str),
1.0f);
}
@ -5755,7 +5755,7 @@ static void materialui_render_header(
= font_driver_get_message_width(
mui->font_data.hint.font,
mui->sys_bar_cache.timedate_str,
(unsigned)strlen(mui->sys_bar_cache.timedate_str),
strlen(mui->sys_bar_cache.timedate_str),
1.0f);
}
@ -7821,7 +7821,7 @@ static void materialui_init_font(
if (wideglyph_str)
{
int wideglyph_width =
font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1.0f);
font_driver_get_message_width(font_data->font, wideglyph_str, strlen(wideglyph_str), 1.0f);
if (wideglyph_width > 0 && char_width > 0)
font_data->wideglyph_width = wideglyph_width * 100 / char_width;

View File

@ -5374,7 +5374,7 @@ border_iterate:
{
/* Note: This entry can never be selected, so ticker_x_offset
* is irrelevant here (i.e. this text will never scroll) */
unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, (unsigned)strlen(rich_label), 1.0f);
unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, strlen(rich_label), 1.0f);
x_offset = (video_info_width - (unsigned)
ozone->dimensions_sidebar_width - entry_padding * 2)
/ 2 - text_width / 2 - 60 * scale_factor;
@ -6379,7 +6379,7 @@ static void ozone_draw_osk(ozone_handle_t *ozone,
? 0
: font_driver_get_message_width(
ozone->fonts.entries_label.font, msg,
(unsigned)strlen(msg), 1.0f);
strlen(msg), 1.0f);
gfx_display_draw_quad(
p_disp,
userdata,
@ -6491,7 +6491,7 @@ static void ozone_draw_messagebox(
if (!string_is_empty(msg))
{
int width = font_driver_get_message_width(
ozone->fonts.footer.font, msg, (unsigned)strlen(msg), 1.0f);
ozone->fonts.footer.font, msg, strlen(msg), 1.0f);
if (width > longest_width)
longest_width = width;
@ -8167,7 +8167,7 @@ static bool ozone_init_font(
if (wideglyph_str)
{
int wideglyph_width =
font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1.0f);
font_driver_get_message_width(font_data->font, wideglyph_str, strlen(wideglyph_str), 1.0f);
if (wideglyph_width > 0 && glyph_width > 0)
font_data->wideglyph_width = wideglyph_width * 100 / glyph_width;
@ -8185,7 +8185,7 @@ static void ozone_cache_footer_label(ozone_handle_t *ozone,
{
const char *str = msg_hash_to_str(enum_idx);
/* Determine pixel width */
unsigned length = (unsigned)strlen(str);
size_t length = strlen(str);
/* Assign string */
label->str = str;

View File

@ -1036,7 +1036,7 @@ static void xmb_render_messagebox_internal(
if (!string_is_empty(msg))
{
int width = font_driver_get_message_width(
xmb->font, msg, (unsigned)strlen(msg), 1);
xmb->font, msg, strlen(msg), 1);
if (width > longest_width)
longest_width = width;
}
@ -5676,7 +5676,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
percent_width = (unsigned)
font_driver_get_message_width(
xmb->font, msg, (unsigned)strlen(msg), 1);
xmb->font, msg, strlen(msg), 1);
xmb_draw_text(xmb_shadows_enable, xmb, settings, msg,
video_width - xmb->margins_title_left - x_pos,
@ -6920,7 +6920,7 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb,
int char_width =
font_driver_get_message_width(xmb->font, "a", 1, 1);
int wideglyph_width =
font_driver_get_message_width(xmb->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1);
font_driver_get_message_width(xmb->font, wideglyph_str, strlen(wideglyph_str), 1);
if (wideglyph_width > 0 && char_width > 0)
xmb->wideglyph_width = wideglyph_width * 100 / char_width;

View File

@ -9198,7 +9198,7 @@ static void gfx_widget_netplay_chat_frame(void *data, void *userdata)
size_t i;
char formatted_nick[NETPLAY_CHAT_MAX_SIZE];
char formatted_msg[NETPLAY_CHAT_MAX_SIZE];
int formatted_nick_len;
size_t formatted_nick_len;
int formatted_nick_width;
video_frame_info_t *video_info = (video_frame_info_t*)data;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata;
@ -9222,7 +9222,7 @@ static void gfx_widget_netplay_chat_frame(void *data, void *userdata)
continue;
/* Truncate the message, if necessary. */
formatted_nick_len = snprintf(formatted_nick, sizeof(formatted_nick),
formatted_nick_len = (size_t)snprintf(formatted_nick, sizeof(formatted_nick),
"%s: ", nick);
strlcpy(formatted_msg, msg, sizeof(formatted_msg) - formatted_nick_len);
@ -9299,7 +9299,7 @@ static void gfx_widget_netplay_ping_frame(void *data, void *userdata)
if (ping >= 0)
{
char ping_str[16];
int ping_len;
size_t ping_len;
int ping_width, total_width;
video_frame_info_t *video_info = (video_frame_info_t*)data;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata;
@ -9312,7 +9312,8 @@ static void gfx_widget_netplay_ping_frame(void *data, void *userdata)
if (ping > 999)
ping = 999;
ping_len = snprintf(ping_str, sizeof(ping_str), "PING: %d", ping);
ping_len = (size_t)snprintf(ping_str,
sizeof(ping_str), "PING: %d", ping);
ping_width = font_driver_get_message_width(
font->font, ping_str, ping_len, 1.0f);