From a267bdfbe3de58a56fa01aa4410163ca619f9e0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Jan 2016 02:39:08 +0100 Subject: [PATCH] MOve gfx/image/image.c to gfx/video_texture_image.c --- Makefile.common | 2 +- gfx/common/gl_common.c | 4 +- gfx/{image/image.c => video_texture_image.c} | 68 ++++++++++---------- griffin/griffin.c | 2 +- input/input_overlay.c | 4 +- libretro-common/include/formats/image.h | 8 +-- menu/drivers/materialui.c | 4 +- menu/drivers/xmb.c | 13 ++-- menu/menu_display.c | 4 +- tasks/task_file_transfer.c | 4 +- tasks/task_overlay.c | 2 +- 11 files changed, 57 insertions(+), 58 deletions(-) rename gfx/{image/image.c => video_texture_image.c} (85%) diff --git a/Makefile.common b/Makefile.common index 46c9d7bf67..9e34050698 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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 diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 9fb0d72b22..820922c98c 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -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); diff --git a/gfx/image/image.c b/gfx/video_texture_image.c similarity index 85% rename from gfx/image/image.c rename to gfx/video_texture_image.c index f585aac662..da814f1b3b 100644 --- a/gfx/image/image.c +++ b/gfx/video_texture_image.c @@ -14,26 +14,26 @@ * If not, see . */ +#include +#include +#include +#include + #ifdef HAVE_CONFIG_H #include "../../config.h" #endif +#include #include #ifdef HAVE_RPNG #include #endif #include -#include "../../file_ops.h" -#include "../../verbosity.h" -#include -#include -#include -#include -#include -#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; } diff --git a/griffin/griffin.c b/griffin/griffin.c index 1bf08ac69c..fe393f2510 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -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" diff --git a/input/input_overlay.c b/input/input_overlay.c index c78c65c5c5..749da62b64 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -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) diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index fc5dfa2ef8..9ca5cd1412 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -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 } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 8ddf397836..2ad41f27aa 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -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); } } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index e66b5e07a5..095db20744 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -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; diff --git a/menu/menu_display.c b/menu/menu_display.c index 16370141c0..c88b0876c7 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -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); } diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index c5b48c1111..5e15dbf37b 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -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; diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index c6775b8d24..6887625b82 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -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;