mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Fix texture_image_load/free.
This commit is contained in:
parent
1c92ea3c5a
commit
15c35d7e44
@ -465,7 +465,7 @@ static void rmenu_context_reset(void *data)
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
texture_image_load(driver.video_data, g_extern.menu_texture_path, menu_texture);
|
||||
texture_image_load(menu_texture, g_extern.menu_texture_path);
|
||||
menu->width = menu_texture->width;
|
||||
menu->height = menu_texture->height;
|
||||
|
||||
@ -485,7 +485,7 @@ static void *rmenu_init(void)
|
||||
|
||||
static void rmenu_context_destroy(void *data)
|
||||
{
|
||||
texture_image_free(driver.video_data, menu_texture);
|
||||
texture_image_free(menu_texture);
|
||||
}
|
||||
|
||||
static void rmenu_free(void *data)
|
||||
|
@ -38,22 +38,7 @@ struct texture_image
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct image_ctx_driver
|
||||
{
|
||||
bool (*load)(void*, const char*, void *);
|
||||
void (*free)(void *, void *);
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
} image_ctx_driver_t;
|
||||
|
||||
#if 0
|
||||
extern const image_ctx_driver_t image_ctx_xdk1;
|
||||
extern const image_ctx_driver_t image_ctx_ps3;
|
||||
extern const image_ctx_driver_t image_ctx_sdl;
|
||||
extern const image_ctx_driver_t image_ctx_rpng;
|
||||
#endif
|
||||
|
||||
bool texture_image_load(void *data, const char *path, void *img);
|
||||
void texture_image_free(void *data, void *img);
|
||||
bool texture_image_load(struct texture_image *img, const char *path);
|
||||
void texture_image_free(struct texture_image *img);
|
||||
|
||||
#endif
|
||||
|
@ -304,15 +304,12 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
(void)data;
|
||||
struct texture_image *out_img = (struct texture_image*)image_data;
|
||||
|
||||
if (!out_img)
|
||||
return false;
|
||||
|
||||
if(strstr(path, ".PNG") != NULL || strstr(path, ".png") != NULL)
|
||||
if (strstr(path, ".PNG") != NULL || strstr(path, ".png") != NULL)
|
||||
{
|
||||
if (!ps3_load_png(path, out_img))
|
||||
return false;
|
||||
@ -326,9 +323,8 @@ bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void texture_image_free(void *data, void *image_data)
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
struct texture_image *img = (struct texture_image*)image_data;
|
||||
if (!img)
|
||||
return;
|
||||
|
||||
|
@ -199,19 +199,15 @@ static bool rpng_gx_convert_texture32(struct texture_image *image)
|
||||
|
||||
#endif
|
||||
|
||||
void texture_image_free(void *data, void *image_data)
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
struct texture_image *img = (struct texture_image*)image_data;
|
||||
|
||||
free(img->pixels);
|
||||
memset(img, 0, sizeof(*img));
|
||||
}
|
||||
|
||||
bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
(void)data;
|
||||
bool ret;
|
||||
struct texture_image *out_img = (struct texture_image*)image_data;
|
||||
|
||||
// This interface "leak" is very ugly. FIXME: Fix this properly ...
|
||||
if (driver.gfx_use_rgba)
|
||||
@ -224,7 +220,7 @@ bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
{
|
||||
if (!rpng_gx_convert_texture32(out_img))
|
||||
{
|
||||
texture_image_free(data, out_img);
|
||||
texture_image_free(out_img);
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,16 @@
|
||||
#include "image.h"
|
||||
#include "../../xdk/xdk_d3d.h"
|
||||
|
||||
bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
struct texture_image *out_img = (struct texture_image*)image_data;
|
||||
|
||||
D3DXIMAGE_INFO m_imageInfo;
|
||||
|
||||
out_img->pixels = NULL;
|
||||
out_img->vertex_buf = NULL;
|
||||
|
||||
if(FAILED(D3DXCreateTextureFromFileExA(d3d->dev,
|
||||
if (FAILED(D3DXCreateTextureFromFileExA(d3d->dev,
|
||||
path, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &m_imageInfo, NULL,
|
||||
&out_img->pixels)))
|
||||
@ -50,10 +49,8 @@ bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void texture_image_free(void *data, void *image_data)
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
struct texture_image *img = (struct texture_image*)image_data;
|
||||
|
||||
if (!img)
|
||||
return;
|
||||
|
||||
|
@ -64,7 +64,7 @@ bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures)
|
||||
RARCH_LOG("Loading texture image from: \"%s\" ...\n",
|
||||
generic_shader->lut[i].path);
|
||||
|
||||
if (!texture_image_load(driver.video_data, generic_shader->lut[i].path, &img))
|
||||
if (!texture_image_load(&img, generic_shader->lut[i].path))
|
||||
{
|
||||
RARCH_ERR("Failed to load texture image from: \"%s\"\n", generic_shader->lut[i].path);
|
||||
return false;
|
||||
@ -74,7 +74,7 @@ bool gl_load_luts(const struct gfx_shader *generic_shader, GLuint *lut_textures)
|
||||
gl_wrap_type_to_enum(generic_shader->lut[i].wrap),
|
||||
generic_shader->lut[i].filter != RARCH_FILTER_NEAREST,
|
||||
generic_shader->lut[i].mipmap);
|
||||
texture_image_free(driver.video_data, &img);
|
||||
texture_image_free(&img);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -164,11 +164,11 @@ static void input_overlay_free_overlay(struct overlay *overlay)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < overlay->size; i++)
|
||||
texture_image_free(driver.video_data, &overlay->descs[i].image);
|
||||
texture_image_free(&overlay->descs[i].image);
|
||||
|
||||
free(overlay->load_images);
|
||||
free(overlay->descs);
|
||||
texture_image_free(driver.video_data, &overlay->image);
|
||||
texture_image_free(&overlay->image);
|
||||
}
|
||||
|
||||
static void input_overlay_free_overlays(input_overlay_t *ol)
|
||||
@ -199,7 +199,7 @@ static bool input_overlay_load_desc(input_overlay_t *ol, config_file_t *conf, st
|
||||
fill_pathname_resolve_relative(path, ol->overlay_path, image_path, sizeof(path));
|
||||
|
||||
struct texture_image img = {0};
|
||||
if (texture_image_load(driver.video_data, path, &img))
|
||||
if (texture_image_load(&img, path))
|
||||
desc->image = img;
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, config_file_t *conf,
|
||||
fill_pathname_resolve_relative(overlay_resolved_path, config_path,
|
||||
overlay_path, sizeof(overlay_resolved_path));
|
||||
|
||||
if (texture_image_load(driver.video_data, overlay_resolved_path, &img))
|
||||
if (texture_image_load(&img, overlay_resolved_path))
|
||||
overlay->image = img;
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user