mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Add texture_image_free().
Cleans up deinit code for textures.
This commit is contained in:
parent
132c3c46f7
commit
0d3428ad15
@ -423,25 +423,7 @@ static void *rmenu_init(void)
|
||||
|
||||
static void rmenu_free_assets(void *data)
|
||||
{
|
||||
#ifdef _XBOX1
|
||||
if (menu_texture->vertex_buf)
|
||||
{
|
||||
menu_texture->vertex_buf->Release();
|
||||
menu_texture->vertex_buf = NULL;
|
||||
}
|
||||
if (menu_texture->pixels)
|
||||
{
|
||||
menu_texture->pixels->Release();
|
||||
menu_texture->pixels = NULL;
|
||||
}
|
||||
#else
|
||||
if (menu_texture->pixels)
|
||||
{
|
||||
free(menu_texture->pixels);
|
||||
menu_texture->pixels = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
texture_image_free(&menu_texture);
|
||||
menu_texture_inited = false;
|
||||
}
|
||||
|
||||
|
@ -233,3 +233,9 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
return texture_image_load_argb_shift(path, out_img, 24, 16, 8, 0);
|
||||
}
|
||||
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
free(img->pixels);
|
||||
memset(img, 0, sizeof(*img));
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ struct texture_image
|
||||
};
|
||||
|
||||
bool texture_image_load(const char *path, struct texture_image* img);
|
||||
void texture_image_free(struct texture_image *img);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -511,8 +511,6 @@ static void load_texture_data(GLuint obj, const struct texture_image *img, bool
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, img->width, img->height,
|
||||
0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels);
|
||||
|
||||
free(img->pixels);
|
||||
}
|
||||
|
||||
static bool load_textures(void)
|
||||
@ -528,7 +526,7 @@ static bool load_textures(void)
|
||||
RARCH_LOG("Loading image from: \"%s\".\n",
|
||||
cg_shader->lut[i].path);
|
||||
|
||||
struct texture_image img;
|
||||
struct texture_image img = {0};
|
||||
if (!texture_image_load(cg_shader->lut[i].path, &img))
|
||||
{
|
||||
RARCH_ERR("Failed to load picture ...\n");
|
||||
@ -538,6 +536,7 @@ static bool load_textures(void)
|
||||
load_texture_data(lut_textures[i], &img,
|
||||
cg_shader->lut[i].filter != RARCH_FILTER_NEAREST,
|
||||
gl_wrap_type_to_enum(cg_shader->lut[i].wrap));
|
||||
texture_image_free(&img);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -324,7 +324,7 @@ static bool load_luts(void)
|
||||
RARCH_GL_FORMAT32, img.pixels);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
free(img.pixels);
|
||||
texture_image_free(&img);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -239,10 +239,10 @@ static void input_overlay_free_overlay(struct overlay *overlay)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < overlay->size; i++)
|
||||
free(overlay->descs[i].image.pixels);
|
||||
texture_image_free(&overlay->descs[i].image);
|
||||
free(overlay->load_images);
|
||||
free(overlay->descs);
|
||||
free(overlay->image.pixels);
|
||||
texture_image_free(&overlay->image);
|
||||
}
|
||||
|
||||
static void input_overlay_free_overlays(input_overlay_t *ol)
|
||||
|
@ -314,3 +314,10 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
free(img->pixels);
|
||||
memset(img, 0, sizeof(*img));
|
||||
}
|
||||
|
||||
|
10
xdk/image.c
10
xdk/image.c
@ -53,3 +53,13 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void texture_image_free(struct texture_image *img)
|
||||
{
|
||||
if (img->vertex_buf)
|
||||
img->vertex_buf->Release();
|
||||
if (img->pixels)
|
||||
img->pixels->Release();
|
||||
memset(img, 0, sizeof(*img));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user