(gfx/drivers_font) Style nits

This commit is contained in:
twinaphex 2017-01-12 10:26:12 +01:00
parent b2ad5274b3
commit 52ad8fb125
7 changed files with 109 additions and 109 deletions

View File

@ -77,11 +77,10 @@ static const struct font_glyph *caca_font_get_glyph(
static void caca_render_msg(void *data, const char *msg,
const void *userdata)
{
caca_raster_t *font = (caca_raster_t*)data;
float x, y;
unsigned width, height;
unsigned newX, newY;
settings_t *settings = config_get_ptr();
caca_raster_t *font = (caca_raster_t*)data;
const struct font_params *params = (const struct font_params*)userdata;
if (!font || string_is_empty(msg))
@ -94,6 +93,8 @@ static void caca_render_msg(void *data, const char *msg,
}
else
{
settings_t *settings = config_get_ptr();
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
}
@ -102,11 +103,11 @@ static void caca_render_msg(void *data, const char *msg,
!*font->caca->caca_cv || !*font->caca->caca_display)
return;
width = caca_get_canvas_width(*font->caca->caca_cv);
height = caca_get_canvas_height(*font->caca->caca_cv);
width = caca_get_canvas_width(*font->caca->caca_cv);
height = caca_get_canvas_height(*font->caca->caca_cv);
newX = x * width;
newY = height - (y * height);
newX = x * width;
newY = height - (y * height);
if (strlen(msg) + newX > width)
newX -= strlen(msg) + newX - width;

View File

@ -341,13 +341,12 @@ static void ctr_font_render_msg(void* data, const char* msg,
const void* userdata)
{
float x, y, scale, drop_mod, drop_alpha;
unsigned color, color_dark, r, g, b, alpha, r_dark, g_dark, b_dark, alpha_dark;
unsigned width, height;
int drop_x, drop_y;
unsigned max_glyphs;
enum text_alignment text_align;
settings_t* settings = config_get_ptr();
ctr_font_t* font = (ctr_font_t*)data;
unsigned color, color_dark, r, g, b, alpha, r_dark, g_dark, b_dark, alpha_dark;
ctr_font_t * font = (ctr_font_t*)data;
const struct font_params* params = (const struct font_params*)userdata;
if (!font || !msg || !*msg)
@ -357,53 +356,53 @@ static void ctr_font_render_msg(void* data, const char* msg,
if (params)
{
// printf("%s\n", msg);
x = params->x;
y = params->y;
scale = params->scale;
text_align = params->text_align;
drop_x = params->drop_x;
drop_y = params->drop_y;
drop_mod = params->drop_mod;
drop_alpha = params->drop_alpha;
x = params->x;
y = params->y;
scale = params->scale;
text_align = params->text_align;
drop_x = params->drop_x;
drop_y = params->drop_y;
drop_mod = params->drop_mod;
drop_alpha = params->drop_alpha;
r = FONT_COLOR_GET_RED(params->color);
g = FONT_COLOR_GET_GREEN(params->color);
b = FONT_COLOR_GET_BLUE(params->color);
alpha = FONT_COLOR_GET_ALPHA(params->color);
color = params->color;
// color = COLOR_ABGR(r, g, b, alpha);
}
else
{
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
scale = 1.0f;
text_align = TEXT_ALIGN_LEFT;
settings_t* settings = config_get_ptr();
r = (settings->video.msg_color_r * 255);
g = (settings->video.msg_color_g * 255);
b = (settings->video.msg_color_b * 255);
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
scale = 1.0f;
text_align = TEXT_ALIGN_LEFT;
r = (settings->video.msg_color_r * 255);
g = (settings->video.msg_color_g * 255);
b = (settings->video.msg_color_b * 255);
alpha = 255;
color = COLOR_ABGR(r, g, b, alpha);
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
}
max_glyphs = strlen(msg);
max_glyphs = strlen(msg);
if (drop_x || drop_y)
max_glyphs *= 2;
max_glyphs *= 2;
if (drop_x || drop_y)
{
r_dark = r * drop_mod;
g_dark = g * drop_mod;
b_dark = b * drop_mod;
r_dark = r * drop_mod;
g_dark = g * drop_mod;
b_dark = b * drop_mod;
alpha_dark = alpha * drop_alpha;
color_dark = COLOR_ABGR(r_dark, g_dark, b_dark, alpha_dark);
color_dark = COLOR_ABGR(r_dark, g_dark, b_dark, alpha_dark);
ctr_font_render_message(font, msg, scale, color_dark,
x + scale * drop_x / width, y +

View File

@ -68,7 +68,6 @@ static void libdbg_font_render_msg(void *data, const char *msg,
{
float x, y, scale;
unsigned color;
settings_t *settings = config_get_ptr();
const struct font_params *params = (const struct font_params*)userdata;
(void)data;
@ -82,10 +81,11 @@ static void libdbg_font_render_msg(void *data, const char *msg,
}
else
{
x = settings->video.msg_pos_x;
y = 0.90f;
scale = 1.04f;
color = SILVER;
settings_t *settings = config_get_ptr();
x = settings->video.msg_pos_x;
y = 0.90f;
scale = 1.04f;
color = SILVER;
}
DbgFontPrint(x, y, scale, color, msg);

View File

@ -20,6 +20,8 @@
#include "../font_driver.h"
#include "../../configuration.h"
typedef struct
{
vita_video_t *vita;
@ -27,17 +29,15 @@ typedef struct
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
} vita_font_t;
static void *vita2d_font_init_font(void *data, const char *font_path, float font_size)
{
unsigned int stride, pitch, j, k;
const uint8_t *frame32 = NULL;
uint8_t *tex32 = NULL;
const struct font_atlas *atlas = NULL;
vita_font_t *font = (vita_font_t*)calloc(1, sizeof(*font));
vita_font_t *font = (vita_font_t*)calloc(1, sizeof(*font));
if (!font)
return NULL;
@ -48,8 +48,8 @@ static void *vita2d_font_init_font(void *data, const char *font_path, float font
&font->font_data, font_path, font_size))
goto error;
font->atlas = font->font_driver->get_atlas(font->font_data);
atlas = font->atlas;
font->atlas = font->font_driver->get_atlas(font->font_data);
atlas = font->atlas;
if (!atlas)
goto error;
@ -114,6 +114,7 @@ static int vita2d_font_get_message_width(void *data, const char *msg,
for (i = 0; i < msg_len; i++)
{
const struct font_glyph *glyph = NULL;
const char *msg_tmp = &msg[i];
unsigned code = utf8_walk(&msg_tmp);
unsigned skip = msg_tmp - &msg[i];
@ -121,8 +122,8 @@ static int vita2d_font_get_message_width(void *data, const char *msg,
if (skip > 1)
i += skip - 1;
const struct font_glyph *glyph =
font->font_driver->get_glyph(font->font_data, code);
glyph = font->font_driver->get_glyph(font->font_data, code);
if (!glyph) /* Do something smarter here ... */
glyph = font->font_driver->get_glyph(font->font_data, '?');
@ -165,6 +166,7 @@ static void vita2d_font_render_line(
{
int off_x, off_y, tex_x, tex_y, width, height;
unsigned int stride, pitch, j, k;
const struct font_glyph *glyph = NULL;
const uint8_t *frame32 = NULL;
uint8_t *tex32 = NULL;
const char *msg_tmp = &msg[i];
@ -174,11 +176,11 @@ static void vita2d_font_render_line(
if (skip > 1)
i += skip - 1;
const struct font_glyph *glyph =
font->font_driver->get_glyph(font->font_data, code);
glyph = font->font_driver->get_glyph(font->font_data, code);
if (!glyph) /* Do something smarter here ... */
glyph = font->font_driver->get_glyph(font->font_data, '?');
if (!glyph)
continue;
@ -221,8 +223,8 @@ static void vita2d_font_render_message(
const unsigned int color, float pos_x, float pos_y,
unsigned text_align)
{
int lines = 0;
float line_height;
int lines = 0;
if (!msg || !*msg)
return;
@ -241,25 +243,18 @@ static void vita2d_font_render_message(
for (;;)
{
const char *delim = strchr(msg, '\n');
unsigned msg_len = (delim) ? (delim - msg) : strlen(msg);
vita2d_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
/* Draw the line */
if (delim)
{
unsigned msg_len = delim - msg;
vita2d_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
msg += msg_len + 1;
lines++;
}
else
{
unsigned msg_len = strlen(msg);
vita2d_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
text_align);
if (!delim)
break;
}
msg += msg_len + 1;
lines++;
}
}
@ -267,13 +262,12 @@ static void vita2d_font_render_msg(void *data, const char *msg,
const void *userdata)
{
float x, y, scale, drop_mod, drop_alpha;
unsigned color, color_dark, r, g, b, alpha, r_dark, g_dark, b_dark, alpha_dark;
unsigned width, height;
int drop_x, drop_y;
unsigned max_glyphs;
enum text_alignment text_align;
settings_t *settings = config_get_ptr();
vita_font_t *font = (vita_font_t *)data;
unsigned color, color_dark, r, g, b, alpha, r_dark, g_dark, b_dark, alpha_dark;
vita_font_t *font = (vita_font_t *)data;
const struct font_params *params = (const struct font_params*)userdata;
if (!font || !msg || !*msg)
@ -283,14 +277,14 @@ static void vita2d_font_render_msg(void *data, const char *msg,
if (params)
{
x = params->x;
y = params->y;
scale = params->scale;
text_align = params->text_align;
drop_x = params->drop_x;
drop_y = params->drop_y;
drop_mod = params->drop_mod;
drop_alpha = params->drop_alpha;
x = params->x;
y = params->y;
scale = params->scale;
text_align = params->text_align;
drop_x = params->drop_x;
drop_y = params->drop_y;
drop_mod = params->drop_mod;
drop_alpha = params->drop_alpha;
r = FONT_COLOR_GET_RED(params->color);
g = FONT_COLOR_GET_GREEN(params->color);
b = FONT_COLOR_GET_BLUE(params->color);
@ -299,34 +293,37 @@ static void vita2d_font_render_msg(void *data, const char *msg,
}
else
{
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
scale = 1.0f;
text_align = TEXT_ALIGN_LEFT;
settings_t *settings = config_get_ptr();
r = (settings->video.msg_color_r * 255);
g = (settings->video.msg_color_g * 255);
b = (settings->video.msg_color_b * 255);
alpha = 255;
color = RGBA8(r,g,b,alpha);
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
scale = 1.0f;
text_align = TEXT_ALIGN_LEFT;
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
r = (settings->video.msg_color_r * 255);
g = (settings->video.msg_color_g * 255);
b = (settings->video.msg_color_b * 255);
alpha = 255;
color = RGBA8(r,g,b,alpha);
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
}
max_glyphs = strlen(msg);
max_glyphs = strlen(msg);
if (drop_x || drop_y)
max_glyphs *= 2;
max_glyphs *= 2;
if (drop_x || drop_y)
{
r_dark = r * drop_mod;
g_dark = g * drop_mod;
b_dark = b * drop_mod;
r_dark = r * drop_mod;
g_dark = g * drop_mod;
b_dark = b * drop_mod;
alpha_dark = alpha * drop_alpha;
color_dark = RGBA8(r_dark,g_dark,b_dark,alpha_dark);
color_dark = RGBA8(r_dark,g_dark,b_dark,alpha_dark);
vita2d_font_render_message(font, msg, scale, color_dark,
x + scale * drop_x / width, y +

View File

@ -261,21 +261,20 @@ static void vulkan_raster_font_flush(vulkan_raster_t *font)
static void vulkan_raster_font_render_msg(void *data, const char *msg,
const void *userdata)
{
float x, y, scale, drop_mod, drop_alpha;
float color[4], color_dark[4];
int drop_x, drop_y;
bool full_screen;
unsigned max_glyphs;
enum text_alignment text_align;
float x, y, scale, drop_mod, drop_alpha;
vk_t *vk = NULL;
vulkan_raster_t *font = (vulkan_raster_t*)data;
settings_t *settings = config_get_ptr();
const struct font_params *params = (const struct font_params*)userdata;
if (!font || !msg || !*msg)
return;
vk = font->vk;
vk = font->vk;
if (params)
{
@ -300,6 +299,8 @@ static void vulkan_raster_font_render_msg(void *data, const char *msg,
}
else
{
settings_t *settings = config_get_ptr();
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
scale = 1.0f;
@ -309,12 +310,12 @@ static void vulkan_raster_font_render_msg(void *data, const char *msg,
color[0] = settings->video.msg_color_r;
color[1] = settings->video.msg_color_g;
color[2] = settings->video.msg_color_b;
color[3] = 1.0f;
color[3] = 1.0f;
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
}
vulkan_raster_font_setup_viewport(font, full_screen);
@ -327,8 +328,8 @@ static void vulkan_raster_font_render_msg(void *data, const char *msg,
6 * sizeof(struct vk_vertex) * max_glyphs, &font->range))
return;
font->vertices = 0;
font->pv = (struct vk_vertex*)font->range.data;
font->vertices = 0;
font->pv = (struct vk_vertex*)font->range.data;
if (drop_x || drop_y)
{

View File

@ -68,7 +68,6 @@ static void xfonts_render_msg(void *data, const char *msg,
{
wchar_t str[PATH_MAX_LENGTH];
float x, y;
settings_t *settings = config_get_ptr();
const struct font_params *params = (const struct font_params*)userdata;
xfonts_t *xfonts = (xfonts_t*)data;
@ -79,6 +78,8 @@ static void xfonts_render_msg(void *data, const char *msg,
}
else
{
settings_t *settings = config_get_ptr();
x = settings->video.msg_pos_x;
y = settings->video.msg_pos_y;
}

View File

@ -20,9 +20,10 @@
#include <boolean.h>
#include "../font_driver.h"
#include "bitmap.h"
#include "../font_driver.h"
#define BMP_ATLAS_COLS 16
#define BMP_ATLAS_ROWS 16
#define BMP_ATLAS_SIZE (BMP_ATLAS_COLS * BMP_ATLAS_ROWS)