(Caca/GDI/Sixel/VGA) Did not have proper implemented free functions
This commit is contained in:
parent
af71dcb893
commit
3494c0de0a
|
@ -31,8 +31,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const font_renderer_driver_t *caca_font_driver;
|
||||
void *caca_font_data;
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
caca_t *caca;
|
||||
} caca_raster_t;
|
||||
|
||||
|
@ -48,8 +48,8 @@ static void *caca_font_init(void *data,
|
|||
font->caca = (caca_t*)data;
|
||||
|
||||
if (!font_renderer_create_default(
|
||||
&font->caca_font_driver,
|
||||
&font->caca_font_data, font_path, font_size))
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||
return NULL;
|
||||
|
@ -58,7 +58,18 @@ static void *caca_font_init(void *data,
|
|||
return font;
|
||||
}
|
||||
|
||||
static void caca_font_free(void *data, bool is_threaded) { }
|
||||
static void caca_font_free(void *data, bool is_threaded)
|
||||
{
|
||||
caca_raster_t *font = (caca_raster_t*)data;
|
||||
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
if (font->font_driver && font->font_data && font->font_driver->free)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
free(font);
|
||||
}
|
||||
|
||||
static int caca_font_get_message_width(void *data, const char *msg,
|
||||
unsigned msg_len, float scale)
|
||||
|
|
|
@ -43,6 +43,9 @@ typedef struct
|
|||
static void* ctr_font_init(void* data, const char* font_path,
|
||||
float font_size, bool is_threaded)
|
||||
{
|
||||
int i, j;
|
||||
const uint8_t* src = NULL;
|
||||
uint8_t* tmp = NULL;
|
||||
const struct font_atlas* atlas = NULL;
|
||||
ctr_font_t* font = (ctr_font_t*)calloc(1, sizeof(*font));
|
||||
ctr_video_t* ctr = (ctr_video_t*)data;
|
||||
|
@ -50,7 +53,7 @@ static void* ctr_font_init(void* data, const char* font_path,
|
|||
if (!font)
|
||||
return NULL;
|
||||
|
||||
font_size = 10;
|
||||
font_size = 10;
|
||||
if (!font_renderer_create_default(
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
|
@ -60,20 +63,19 @@ static void* ctr_font_init(void* data, const char* font_path,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
atlas = font->font_driver->get_atlas(font->font_data);
|
||||
atlas = font->font_driver->get_atlas(font->font_data);
|
||||
|
||||
font->texture.width = next_pow2(atlas->width);
|
||||
font->texture.width = next_pow2(atlas->width);
|
||||
font->texture.height = next_pow2(atlas->height);
|
||||
#if FONT_TEXTURE_IN_VRAM
|
||||
font->texture.data = vramAlloc(font->texture.width * font->texture.height);
|
||||
uint8_t* tmp = linearAlloc(font->texture.width * font->texture.height);
|
||||
font->texture.data = vramAlloc(font->texture.width * font->texture.height);
|
||||
tmp = linearAlloc(font->texture.width * font->texture.height);
|
||||
#else
|
||||
font->texture.data = linearAlloc(font->texture.width * font->texture.height);
|
||||
uint8_t* tmp = font->texture.data;
|
||||
font->texture.data = linearAlloc(font->texture.width * font->texture.height);
|
||||
tmp = font->texture.data;
|
||||
#endif
|
||||
|
||||
int i, j;
|
||||
const uint8_t* src = atlas->buffer;
|
||||
src = atlas->buffer;
|
||||
|
||||
for (j = 0; (j < atlas->height) && (j < font->texture.height); j++)
|
||||
for (i = 0; (i < atlas->width) && (i < font->texture.width); i++)
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const font_renderer_driver_t *gdi_font_driver;
|
||||
void *gdi_font_data;
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
gdi_t *gdi;
|
||||
} gdi_raster_t;
|
||||
|
||||
|
@ -54,8 +54,8 @@ static void *gdi_font_init(void *data,
|
|||
font->gdi = (gdi_t*)data;
|
||||
|
||||
if (!font_renderer_create_default(
|
||||
&font->gdi_font_driver,
|
||||
&font->gdi_font_data, font_path, font_size))
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||
return NULL;
|
||||
|
@ -64,7 +64,18 @@ static void *gdi_font_init(void *data,
|
|||
return font;
|
||||
}
|
||||
|
||||
static void gdi_font_free(void *data, bool is_threaded) { }
|
||||
static void gdi_font_free(void *data, bool is_threaded)
|
||||
{
|
||||
gdi_raster_t *font = (gdi_raster_t*)data;
|
||||
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
if (font->font_driver && font->font_data && font->font_driver->free)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
free(font);
|
||||
}
|
||||
|
||||
static void gdi_font_render_msg(
|
||||
void *userdata,
|
||||
|
@ -76,7 +87,7 @@ static void gdi_font_render_msg(
|
|||
float x, y, scale, drop_mod, drop_alpha;
|
||||
int drop_x, drop_y, msg_strlen;
|
||||
unsigned i;
|
||||
unsigned newX, newY, newDropX, newDropY;
|
||||
unsigned new_x, new_y, new_drop_x, new_drop_y;
|
||||
unsigned align;
|
||||
unsigned red, green, blue;
|
||||
gdi_t *gdi = (gdi_t*)userdata;
|
||||
|
@ -133,25 +144,25 @@ static void gdi_font_render_msg(
|
|||
switch (align)
|
||||
{
|
||||
case TEXT_ALIGN_LEFT:
|
||||
newX = x * width * scale;
|
||||
newDropX = drop_x * width * scale;
|
||||
new_x = x * width * scale;
|
||||
new_drop_x = drop_x * width * scale;
|
||||
break;
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
newX = (x * width * scale) - text_size.cx;
|
||||
newDropX = (drop_x * width * scale) - text_size.cx;
|
||||
new_x = (x * width * scale) - text_size.cx;
|
||||
new_drop_x = (drop_x * width * scale) - text_size.cx;
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
newX = (x * width * scale) - (text_size.cx / 2);
|
||||
newDropX = (drop_x * width * scale) - (text_size.cx / 2);
|
||||
new_x = (x * width * scale) - (text_size.cx / 2);
|
||||
new_drop_x = (drop_x * width * scale) - (text_size.cx / 2);
|
||||
break;
|
||||
default:
|
||||
newX = 0;
|
||||
newDropX = 0;
|
||||
new_x = 0;
|
||||
new_drop_x = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
newY = height - (y * height * scale) - text_size.cy;
|
||||
newDropY = height - (drop_y * height * scale) - text_size.cy;
|
||||
new_y = height - (y * height * scale) - text_size.cy;
|
||||
new_drop_y = height - (drop_y * height * scale) - text_size.cy;
|
||||
|
||||
font->gdi->bmp_old = (HBITMAP)SelectObject(font->gdi->memDC, font->gdi->bmp);
|
||||
|
||||
|
@ -170,7 +181,8 @@ static void gdi_font_render_msg(
|
|||
SetTextColor(font->gdi->memDC, RGB(drop_red, drop_green, drop_blue));
|
||||
|
||||
for (i = 0; i < msg_list.size; i++)
|
||||
TextOut(font->gdi->memDC, newDropX, newDropY + (text_size.cy * i),
|
||||
TextOut(font->gdi->memDC, new_drop_x,
|
||||
new_drop_y + (text_size.cy * i),
|
||||
msg_list.elems[i].data,
|
||||
strlen(msg_list.elems[i].data));
|
||||
}
|
||||
|
@ -178,7 +190,7 @@ static void gdi_font_render_msg(
|
|||
SetTextColor(font->gdi->memDC, RGB(red, green, blue));
|
||||
|
||||
for (i = 0; i < msg_list.size; i++)
|
||||
TextOut(font->gdi->memDC, newX, newY + (text_size.cy * i),
|
||||
TextOut(font->gdi->memDC, new_x, new_y + (text_size.cy * i),
|
||||
msg_list.elems[i].data,
|
||||
strlen(msg_list.elems[i].data));
|
||||
|
||||
|
|
|
@ -39,8 +39,11 @@ typedef struct
|
|||
static void* ps2_font_init(void* data, const char* font_path,
|
||||
float font_size, bool is_threaded)
|
||||
{
|
||||
const struct font_atlas* atlas = NULL;
|
||||
uint32_t j;
|
||||
int text_size, clut_size;
|
||||
uint8_t *tex8;
|
||||
uint32_t *clut32;
|
||||
const struct font_atlas* atlas = NULL;
|
||||
ps2_font_t* font = (ps2_font_t*)calloc(1, sizeof(*font));
|
||||
|
||||
if (!font)
|
||||
|
@ -55,26 +58,26 @@ static void* ps2_font_init(void* data, const char* font_path,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
atlas = font->font_driver->get_atlas(font->font_data);
|
||||
font->texture = (GSTEXTURE*)calloc(1, sizeof(GSTEXTURE));
|
||||
font->texture->Width = atlas->width;
|
||||
font->texture->Height = atlas->height;
|
||||
font->texture->PSM = GS_PSM_T8;
|
||||
atlas = font->font_driver->get_atlas(font->font_data);
|
||||
font->texture = (GSTEXTURE*)calloc(1, sizeof(GSTEXTURE));
|
||||
font->texture->Width = atlas->width;
|
||||
font->texture->Height = atlas->height;
|
||||
font->texture->PSM = GS_PSM_T8;
|
||||
font->texture->ClutPSM = GS_PSM_CT32;
|
||||
font->texture->Filter = GS_FILTER_NEAREST;
|
||||
font->texture->Filter = GS_FILTER_NEAREST;
|
||||
|
||||
// Convert to 8bit texture
|
||||
int textSize = gsKit_texture_size_ee(atlas->width, atlas->height, GS_PSM_T8);
|
||||
uint8_t *tex8 = malloc(textSize);
|
||||
/* Convert to 8bit texture */
|
||||
text_size = gsKit_texture_size_ee(atlas->width, atlas->height, GS_PSM_T8);
|
||||
tex8 = (uint8_t*)malloc(text_size);
|
||||
for (j = 0; j < atlas->width * atlas->height; j++ )
|
||||
tex8[j] = atlas->buffer[j] & 0x000000FF;
|
||||
font->texture->Mem = (u32 *)tex8;
|
||||
tex8[j] = atlas->buffer[j] & 0x000000FF;
|
||||
font->texture->Mem = (u32 *)tex8;
|
||||
|
||||
// Create 8bit CLUT
|
||||
int clutSize = gsKit_texture_size_ee(16, 16, GS_PSM_CT32);
|
||||
uint32_t *clut32 = malloc(clutSize);
|
||||
for (j = 0; j < 256; j++ )
|
||||
clut32[j] = 0x01010101 * j;
|
||||
/* Create 8bit CLUT */
|
||||
clut_size = gsKit_texture_size_ee(16, 16, GS_PSM_CT32);
|
||||
clut32 = (uint32_t*)malloc(clutSize);
|
||||
for (j = 0; j < 256; j++)
|
||||
clut32[j] = 0x01010101 * j;
|
||||
font->texture->Clut = (u32 *)clut32;
|
||||
|
||||
return font;
|
||||
|
@ -149,10 +152,10 @@ static void ps2_font_render_line(
|
|||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
/* We need to >> 1, because GS_SETREG_RGBAQ expects 0x80 as max color */
|
||||
int colorA = (int)(((color & 0xFF000000) >> 24) >> 2);
|
||||
int colorB = (int)(((color & 0x00FF0000) >> 16) >> 1);
|
||||
int colorG = (int)(((color & 0x0000FF00) >> 8) >> 1);
|
||||
int colorR = (int)(((color & 0x000000FF) >> 0) >> 1);
|
||||
int color_a = (int)(((color & 0xFF000000) >> 24) >> 2);
|
||||
int color_b = (int)(((color & 0x00FF0000) >> 16) >> 1);
|
||||
int color_g = (int)(((color & 0x0000FF00) >> 8) >> 1);
|
||||
int color_r = (int)(((color & 0x000000FF) >> 0) >> 1);
|
||||
|
||||
/* Enable Alpha for font */
|
||||
gsKit_set_primalpha(ps2->gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
|
||||
|
@ -220,7 +223,7 @@ static void ps2_font_render_line(
|
|||
u2, /* U2 */
|
||||
v2, /* V2 */
|
||||
5, /* Z */
|
||||
GS_SETREG_RGBAQ(colorR,colorG,colorB,colorA,0x00));
|
||||
GS_SETREG_RGBAQ(color_r, color_g, color_b, color_a, 0x00));
|
||||
|
||||
delta_x += glyph->advance_x;
|
||||
delta_y += glyph->advance_y;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const font_renderer_driver_t *sixel_font_driver;
|
||||
void *sixel_font_data;
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
sixel_t *sixel;
|
||||
} sixel_raster_t;
|
||||
|
||||
|
@ -47,8 +47,8 @@ static void *sixel_font_init(void *data,
|
|||
font->sixel = (sixel_t*)data;
|
||||
|
||||
if (!font_renderer_create_default(
|
||||
&font->sixel_font_driver,
|
||||
&font->sixel_font_data, font_path, font_size))
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||
return NULL;
|
||||
|
@ -57,7 +57,18 @@ static void *sixel_font_init(void *data,
|
|||
return font;
|
||||
}
|
||||
|
||||
static void sixel_font_free(void *data, bool is_threaded) { }
|
||||
static void sixel_font_free(void *data, bool is_threaded)
|
||||
{
|
||||
sixel_raster_t *font = (sixel_raster_t*)data;
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
if (font->font_driver && font->font_data && font->font_driver->free)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
free(font);
|
||||
}
|
||||
|
||||
static int sixel_font_get_message_width(void *data, const char *msg,
|
||||
unsigned msg_len, float scale) { return 0; }
|
||||
static const struct font_glyph *sixel_font_get_glyph(
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const font_renderer_driver_t *vga_font_driver;
|
||||
void *vga_font_data;
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
vga_t *vga;
|
||||
} vga_raster_t;
|
||||
|
||||
|
@ -48,8 +48,8 @@ static void *vga_font_init(void *data,
|
|||
font_size = 1;
|
||||
|
||||
if (!font_renderer_create_default(
|
||||
&font->vga_font_driver,
|
||||
&font->vga_font_data, font_path, font_size))
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||
return NULL;
|
||||
|
@ -58,7 +58,19 @@ static void *vga_font_init(void *data,
|
|||
return font;
|
||||
}
|
||||
|
||||
static void vga_font_render_free(void *data, bool is_threaded) { }
|
||||
static void vga_font_render_free(void *data, bool is_threaded)
|
||||
{
|
||||
vga_raster_t *font = (vga_raster_t*)data;
|
||||
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
if (font->font_driver && font->font_data && font->font_driver->free)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
free(font);
|
||||
}
|
||||
|
||||
static int vga_font_get_message_width(void *data, const char *msg,
|
||||
unsigned msg_len, float scale) { return 0; }
|
||||
static const struct font_glyph *vga_font_get_glyph(
|
||||
|
|
|
@ -67,10 +67,10 @@ static void xfonts_free(void *data, bool is_threaded)
|
|||
{
|
||||
xfonts_t *font = (xfonts_t*)data;
|
||||
|
||||
if (font)
|
||||
free(font);
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
font = NULL;
|
||||
free(font);
|
||||
}
|
||||
|
||||
static void xfonts_render_msg(
|
||||
|
|
Loading…
Reference in New Issue