MOve gfx/image/image.c to gfx/video_texture_image.c

This commit is contained in:
twinaphex 2016-01-30 02:39:08 +01:00
parent e91b325d9d
commit a267bdfbe3
11 changed files with 57 additions and 58 deletions

View File

@ -215,7 +215,7 @@ ifneq ($(HAVE_STRL), 1)
OBJ += libretro-common/compat/compat_strl.o
endif
OBJ += gfx/image/image.o
OBJ += gfx/video_texture_image.o
ifeq ($(HAVE_IMAGEVIEWER), 1)
DEFINES += -DHAVE_IMAGEVIEWER

View File

@ -67,7 +67,7 @@ bool gl_load_luts(const struct video_shader *shader,
RARCH_LOG("Loading texture image from: \"%s\" ...\n",
shader->lut[i].path);
if (!texture_image_load(&img, shader->lut[i].path))
if (!video_texture_image_load(&img, shader->lut[i].path))
{
RARCH_ERR("Failed to load texture image from: \"%s\"\n",
shader->lut[i].path);
@ -90,7 +90,7 @@ bool gl_load_luts(const struct video_shader *shader,
filter_type, 4,
img.width, img.height,
img.pixels, sizeof(uint32_t));
texture_image_free(&img);
video_texture_image_free(&img);
}
glBindTexture(GL_TEXTURE_2D, 0);

View File

@ -14,26 +14,26 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include <boolean.h>
#include <formats/image.h>
#ifdef HAVE_RPNG
#include <formats/rpng.h>
#endif
#include <formats/tga.h>
#include "../../file_ops.h"
#include "../../verbosity.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <boolean.h>
#include "../../general.h"
#include "../file_ops.h"
#include "../general.h"
bool texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
unsigned *b_shift, unsigned *a_shift)
{
bool use_rgba = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL);
@ -45,7 +45,7 @@ bool texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
return use_rgba;
}
bool texture_image_color_convert(unsigned r_shift,
bool video_texture_image_color_convert(unsigned r_shift,
unsigned g_shift, unsigned b_shift, unsigned a_shift,
struct texture_image *out_img)
{
@ -74,7 +74,8 @@ bool texture_image_color_convert(unsigned r_shift,
}
#ifdef HAVE_RPNG
static bool rpng_image_load_argb_shift(const char *path,
static bool video_texture_image_load_png(
const char *path,
struct texture_image *out_img,
unsigned a_shift, unsigned r_shift,
unsigned g_shift, unsigned b_shift)
@ -89,9 +90,20 @@ static bool rpng_image_load_argb_shift(const char *path,
return false;
}
texture_image_color_convert(r_shift, g_shift, b_shift,
video_texture_image_color_convert(r_shift, g_shift, b_shift,
a_shift, out_img);
#ifdef GEKKO
if (ret)
{
if (!video_texture_image_rpng_gx_convert_texture32(out_img))
{
video_texture_image_free(out_img);
return false;
}
}
#endif
return true;
}
#endif
@ -117,7 +129,7 @@ static bool rpng_image_load_argb_shift(const char *path,
src += tmp_pitch; \
}
static bool rpng_gx_convert_texture32(struct texture_image *image)
static bool video_texture_image_rpng_gx_convert_texture32(struct texture_image *image)
{
unsigned tmp_pitch, width2, i;
const uint16_t *src = NULL;
@ -154,10 +166,9 @@ static bool rpng_gx_convert_texture32(struct texture_image *image)
free(tmp);
return true;
}
#endif
void texture_image_free(struct texture_image *img)
void video_texture_image_free(struct texture_image *img)
{
if (!img)
return;
@ -167,22 +178,19 @@ void texture_image_free(struct texture_image *img)
memset(img, 0, sizeof(*img));
}
bool texture_image_load(struct texture_image *out_img, const char *path)
bool video_texture_image_load(struct texture_image *out_img, const char *path)
{
unsigned r_shift, g_shift, b_shift, a_shift;
bool ret = false;
texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
&a_shift);
(void)ret;
if (strstr(path, ".tga"))
{
ssize_t len;
void *raw_buf = NULL;
uint8_t *buf = NULL;
ret = read_file(path, &raw_buf, &len);
bool ret = read_file(path, &raw_buf, &len);
if (!ret || len < 0)
{
@ -197,26 +205,16 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
if (buf)
free(buf);
return ret;
}
#ifdef HAVE_RPNG
else if (strstr(path, ".png"))
{
ret = rpng_image_load_argb_shift(path, out_img,
return video_texture_image_load_png(path, out_img,
a_shift, r_shift, g_shift, b_shift);
}
#ifdef GEKKO
if (ret)
{
if (!rpng_gx_convert_texture32(out_img))
{
texture_image_free(out_img);
return false;
}
}
#endif
#endif
return ret;
return false;
}

View File

@ -192,7 +192,7 @@ VIDEO SHADERS
VIDEO IMAGE
============================================================ */
#include "../gfx/image/image.c"
#include "../gfx/video_texture_image.c"
#include "../libretro-common/formats/tga/rtga.c"

View File

@ -174,7 +174,7 @@ void input_overlay_free_overlay(struct overlay *overlay)
return;
for (i = 0; i < overlay->size; i++)
texture_image_free(&overlay->descs[i].image);
video_texture_image_free(&overlay->descs[i].image);
if (overlay->load_images)
free(overlay->load_images);
@ -182,7 +182,7 @@ void input_overlay_free_overlay(struct overlay *overlay)
if (overlay->descs)
free(overlay->descs);
overlay->descs = NULL;
texture_image_free(&overlay->image);
video_texture_image_free(&overlay->image);
}
static void input_overlay_free_overlays(input_overlay_t *ol)

View File

@ -39,15 +39,15 @@ struct texture_image
uint32_t *pixels;
};
bool texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
unsigned *b_shift, unsigned *a_shift);
bool texture_image_color_convert(unsigned r_shift,
bool video_texture_image_color_convert(unsigned r_shift,
unsigned g_shift, unsigned b_shift, unsigned a_shift,
struct texture_image *out_img);
bool texture_image_load(struct texture_image *img, const char *path);
void texture_image_free(struct texture_image *img);
bool video_texture_image_load(struct texture_image *img, const char *path);
void video_texture_image_free(struct texture_image *img);
#ifdef __cplusplus
}

View File

@ -158,12 +158,12 @@ static void mui_context_reset_textures(mui_handle_t *mui, const char *iconpath)
if (string_is_empty(path) || !path_file_exists(path))
continue;
texture_image_load(&ti, path);
video_texture_image_load(&ti, path);
mui->textures.list[i].id = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
video_texture_image_free(&ti);
}
}

View File

@ -1097,18 +1097,19 @@ static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb, const char *the
fill_pathname_join(content_texturepath, iconpath, sysname, sizeof(content_texturepath));
strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));
texture_image_load(&ti, texturepath);
video_texture_image_load(&ti, texturepath);
node->icon = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
texture_image_load(&ti, content_texturepath);
video_texture_image_free(&ti);
video_texture_image_load(&ti, content_texturepath);
node->content_icon = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
video_texture_image_free(&ti);
}
xmb_toggle_horizontal_list(xmb);
@ -2171,12 +2172,12 @@ static void xmb_context_reset_textures(xmb_handle_t *xmb, const char *iconpath)
if (string_is_empty(path) || !path_file_exists(path))
continue;
texture_image_load(&ti, path);
video_texture_image_load(&ti, path);
xmb->textures.list[i].id = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
video_texture_image_free(&ti);
}
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU].id;

View File

@ -645,7 +645,7 @@ void menu_display_handle_wallpaper_upload(void *task_data, void *user_data, cons
{
struct texture_image *img = (struct texture_image*)task_data;
menu_driver_load_image(img, MENU_IMAGE_WALLPAPER);
texture_image_free(img);
video_texture_image_free(img);
free(img);
}
@ -653,6 +653,6 @@ void menu_display_handle_boxart_upload(void *task_data, void *user_data, const c
{
struct texture_image *img = (struct texture_image*)task_data;
menu_driver_load_image(img, MENU_IMAGE_BOXART);
texture_image_free(img);
video_texture_image_free(img);
free(img);
}

View File

@ -96,10 +96,10 @@ static int cb_image_menu_upload_generic(void *data, size_t len)
nbio->image.processing_final_state == IMAGE_PROCESS_ERROR_END)
return -1;
texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
&a_shift);
texture_image_color_convert(r_shift, g_shift, b_shift,
video_texture_image_color_convert(r_shift, g_shift, b_shift,
a_shift, &nbio->image.ti);
nbio->image.is_blocking_on_processing = false;

View File

@ -58,7 +58,7 @@ static bool rarch_task_overlay_load_texture_image(struct overlay *overlay,
{
if (!image)
return false;
if (!texture_image_load(image, path))
if (!video_texture_image_load(image, path))
return false;
overlay->load_images[overlay->load_images_size++] = *image;