From 7e36dcb27f45ec816b059e551dec3b3679dffc2b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 May 2016 12:57:44 +0200 Subject: [PATCH] move video_texture_image to libretro-common and rename it to image_texture.c --- Makefile.common | 2 +- Makefile.ctr | 2 +- gfx/drivers/gl.c | 4 +- gfx/video_driver.c | 4 +- griffin/griffin.c | 2 +- input/input_overlay.c | 4 +- .../formats/image_texture.c | 76 ++++++++++--------- libretro-common/formats/image_transfer.c | 22 ++++++ libretro-common/formats/tga/rtga.c | 4 +- libretro-common/include/formats/image.h | 12 +-- menu/drivers/materialui.c | 5 +- menu/drivers/nuklear.c | 4 +- menu/drivers/xmb.c | 14 ++-- menu/menu_display.c | 2 +- tasks/task_image.c | 4 +- tasks/task_overlay.c | 2 +- 16 files changed, 94 insertions(+), 69 deletions(-) rename gfx/video_texture_image.c => libretro-common/formats/image_texture.c (70%) diff --git a/Makefile.common b/Makefile.common index 5f3fc542b5..01f7bed0d9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -222,7 +222,7 @@ ifneq ($(HAVE_STRL), 1) OBJ += libretro-common/compat/compat_strl.o endif -OBJ += gfx/video_texture_image.o +OBJ += libretro-common/formats/image_texture.o ifeq ($(HAVE_IMAGEVIEWER), 1) DEFINES += -DHAVE_IMAGEVIEWER diff --git a/Makefile.ctr b/Makefile.ctr index 4964026029..b0b899b870 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -61,7 +61,7 @@ else OBJS += libretro-common/hash/rhash.o OBJS += gfx/video_context_driver.o OBJS += gfx/drivers_context/gfx_null_ctx.o - OBJS += gfx/video_texture_image.o + OBJS += libretro-common/formats/image_texture.o OBJS += libretro-common/formats/tga/rtga.o OBJS += libretro-common/formats/png/rpng.o OBJS += libretro-common/formats/png/rpng_encode.o diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 1a2d0824ff..e0093f7827 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3383,7 +3383,7 @@ bool gl_load_luts(const struct video_shader *shader, RARCH_LOG("Loading texture image from: \"%s\" ...\n", shader->lut[i].path); - if (!video_texture_image_load(&img, shader->lut[i].path)) + if (!image_texture_load(&img, shader->lut[i].path)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", shader->lut[i].path); @@ -3406,7 +3406,7 @@ bool gl_load_luts(const struct video_shader *shader, filter_type, 4, img.width, img.height, img.pixels, sizeof(uint32_t)); - video_texture_image_free(&img); + image_texture_free(&img); } glBindTexture(GL_TEXTURE_2D, 0); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f9742a987d..894170e637 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1489,7 +1489,7 @@ void video_driver_set_rgba(void) { video_driver_lock(); video_driver_use_rgba = true; - video_texture_image_set_rgba(); + image_texture_set_rgba(); video_driver_unlock(); } @@ -1497,7 +1497,7 @@ void video_driver_unset_rgba(void) { video_driver_lock(); video_driver_use_rgba = false; - video_texture_image_unset_rgba(); + image_texture_unset_rgba(); video_driver_unlock(); } diff --git a/griffin/griffin.c b/griffin/griffin.c index 27ce3d6c7d..3ab33aa930 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -226,7 +226,7 @@ VIDEO SHADERS VIDEO IMAGE ============================================================ */ -#include "../gfx/video_texture_image.c" +#include "../libretro-common/formats/image_texture.c" #ifdef HAVE_RTGA #include "../libretro-common/formats/tga/rtga.c" diff --git a/input/input_overlay.c b/input/input_overlay.c index 93cbbe2f1a..8e3458911a 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -177,7 +177,7 @@ void input_overlay_free_overlay(struct overlay *overlay) return; for (i = 0; i < overlay->size; i++) - video_texture_image_free(&overlay->descs[i].image); + image_texture_free(&overlay->descs[i].image); if (overlay->load_images) free(overlay->load_images); @@ -185,7 +185,7 @@ void input_overlay_free_overlay(struct overlay *overlay) if (overlay->descs) free(overlay->descs); overlay->descs = NULL; - video_texture_image_free(&overlay->image); + image_texture_free(&overlay->image); } static void input_overlay_free_overlays(input_overlay_t *ol) diff --git a/gfx/video_texture_image.c b/libretro-common/formats/image_texture.c similarity index 70% rename from gfx/video_texture_image.c rename to libretro-common/formats/image_texture.c index bc632de5f7..d0ac0ffd2d 100644 --- a/gfx/video_texture_image.c +++ b/libretro-common/formats/image_texture.c @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2016 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2016 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (image_texture.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include @@ -19,10 +25,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "../../config.h" -#endif - #include #include #include @@ -36,19 +38,19 @@ enum video_image_format IMAGE_FORMAT_BMP }; -static bool video_texture_image_supports_rgba = false; +static bool image_texture_supports_rgba = false; -void video_texture_image_set_rgba(void) +void image_texture_set_rgba(void) { - video_texture_image_supports_rgba = true; + image_texture_supports_rgba = true; } -void video_texture_image_unset_rgba(void) +void image_texture_unset_rgba(void) { - video_texture_image_supports_rgba = false; + image_texture_supports_rgba = false; } -bool video_texture_image_set_color_shifts( +bool image_texture_set_color_shifts( unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *a_shift) { @@ -57,7 +59,7 @@ bool video_texture_image_set_color_shifts( *g_shift = 8; *b_shift = 0; - if (video_texture_image_supports_rgba) + if (image_texture_supports_rgba) { *r_shift = 0; *b_shift = 16; @@ -67,7 +69,7 @@ bool video_texture_image_set_color_shifts( return false; } -bool video_texture_image_color_convert(unsigned r_shift, +bool image_texture_color_convert(unsigned r_shift, unsigned g_shift, unsigned b_shift, unsigned a_shift, struct texture_image *out_img) { @@ -116,7 +118,7 @@ bool video_texture_image_color_convert(unsigned r_shift, src += tmp_pitch; \ } -static bool video_texture_image_internal_gx_convert_texture32( +static bool image_texture_internal_gx_convert_texture32( struct texture_image *image) { unsigned tmp_pitch, width2, i; @@ -155,7 +157,7 @@ static bool video_texture_image_internal_gx_convert_texture32( } #endif -static bool video_texture_image_load_internal( +static bool image_texture_load_internal( enum image_type_enum type, void *ptr, struct texture_image *out_img, @@ -189,13 +191,13 @@ static bool video_texture_image_load_internal( if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END) goto end; - video_texture_image_color_convert(r_shift, g_shift, b_shift, + image_texture_color_convert(r_shift, g_shift, b_shift, a_shift, out_img); #ifdef GEKKO - if (!video_texture_image_internal_gx_convert_texture32(out_img)) + if (!image_texture_internal_gx_convert_texture32(out_img)) { - video_texture_image_free(out_img); + image_texture_free(out_img); goto end; } #endif @@ -210,7 +212,7 @@ end: } -void video_texture_image_free(struct texture_image *img) +void image_texture_free(struct texture_image *img) { if (!img) return; @@ -220,7 +222,7 @@ void video_texture_image_free(struct texture_image *img) memset(img, 0, sizeof(*img)); } -static enum video_image_format video_texture_image_get_type(const char *path) +static enum video_image_format image_texture_get_type(const char *path) { #ifdef HAVE_RTGA if (strstr(path, ".tga")) @@ -239,7 +241,7 @@ static enum video_image_format video_texture_image_get_type(const char *path) return IMAGE_FORMAT_NONE; } -static enum image_type_enum video_texture_image_convert_fmt_to_type(enum video_image_format fmt) +static enum image_type_enum image_texture_convert_fmt_to_type(enum video_image_format fmt) { switch (fmt) { @@ -265,16 +267,16 @@ static enum image_type_enum video_texture_image_convert_fmt_to_type(enum video_i return IMAGE_TYPE_NONE; } -bool video_texture_image_load(struct texture_image *out_img, +bool image_texture_load(struct texture_image *out_img, const char *path) { unsigned r_shift, g_shift, b_shift, a_shift; size_t file_len = 0; struct nbio_t *handle = NULL; void *ptr = NULL; - enum video_image_format fmt = video_texture_image_get_type(path); + enum video_image_format fmt = image_texture_get_type(path); - video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, + image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); if (fmt != IMAGE_FORMAT_NONE) @@ -291,8 +293,8 @@ bool video_texture_image_load(struct texture_image *out_img, if (!ptr) goto error; - if (video_texture_image_load_internal( - video_texture_image_convert_fmt_to_type(fmt), + if (image_texture_load_internal( + image_texture_convert_fmt_to_type(fmt), ptr,out_img, a_shift, r_shift, g_shift, b_shift)) goto success; diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index 360bb469df..f1245c3373 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -1,3 +1,25 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (image_transfer.c). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #include #include #include diff --git a/libretro-common/formats/tga/rtga.c b/libretro-common/formats/tga/rtga.c index 7699065991..f2fd3d2581 100644 --- a/libretro-common/formats/tga/rtga.c +++ b/libretro-common/formats/tga/rtga.c @@ -427,17 +427,19 @@ int rtga_process_image(rtga_t *rtga, void **buf_data, size_t size, unsigned *width, unsigned *height) { int comp; +#if 0 unsigned size_tex = 0; +#endif if (!rtga) return IMAGE_PROCESS_ERROR; rtga->output_image = (uint32_t*)rtga_load_from_memory(rtga->buff_data, size, width, height, &comp, 4); *buf_data = rtga->output_image; +#if 0 size_tex = (*width) * (*height); printf("GETS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); -#if 0 /* Convert RGBA to ARGB */ do { diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 8f9d0e091f..458a923b43 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -49,17 +49,17 @@ enum image_type_enum IMAGE_TYPE_TGA }; -bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift, +bool image_texture_set_color_shifts(unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *a_shift); -bool video_texture_image_color_convert(unsigned r_shift, +bool image_texture_color_convert(unsigned r_shift, unsigned g_shift, unsigned b_shift, unsigned a_shift, struct texture_image *out_img); -bool video_texture_image_load(struct texture_image *img, const char *path); -void video_texture_image_free(struct texture_image *img); -void video_texture_image_set_rgba(void); -void video_texture_image_unset_rgba(void); +bool image_texture_load(struct texture_image *img, const char *path); +void image_texture_free(struct texture_image *img); +void image_texture_set_rgba(void); +void image_texture_unset_rgba(void); /* Image transfer */ diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 49c88ed897..ff4fc4b72c 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -159,11 +159,10 @@ static void mui_context_reset_textures(mui_handle_t *mui, if (string_is_empty(path) || !path_file_exists(path)) continue; - video_texture_image_load(&ti, path); + image_texture_load(&ti, path); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &mui->textures.list[i]); - - video_texture_image_free(&ti); + image_texture_free(&ti); } } diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index b2974ac275..6883a51286 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -143,11 +143,11 @@ static void nk_menu_context_reset_textures(nk_menu_handle_t *nk, if (string_is_empty(path) || !path_file_exists(path)) continue; - video_texture_image_load(&ti, path); + image_texture_load(&ti, path); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &nk->textures.list[i]); - video_texture_image_free(&ti); + image_texture_load(&ti); } } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1b4c5a5bb2..ad05290231 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -739,7 +739,7 @@ static void menu_display_handle_thumbnail_upload(void *task_data, menu_driver_ctl(RARCH_MENU_CTL_LOAD_IMAGE, &load_image_info); - video_texture_image_free(img); + image_texture_free(img); free(img); } @@ -1402,19 +1402,19 @@ static void xmb_context_reset_horizontal_list( strlcat(content_texturepath, "-content.png", sizeof(content_texturepath)); - video_texture_image_load(&ti, texturepath); + image_texture_load(&ti, texturepath); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &node->icon); - video_texture_image_free(&ti); + image_texture_free(&ti); - video_texture_image_load(&ti, content_texturepath); + image_texture_load(&ti, content_texturepath); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &node->content_icon); - video_texture_image_free(&ti); + image_texture_free(&ti); } xmb_toggle_horizontal_list(xmb); @@ -2767,13 +2767,13 @@ static void xmb_context_reset_textures( if (string_is_empty(path) || !path_file_exists(path)) continue; - video_texture_image_load(&ti, path); + image_texture_load(&ti, path); video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_LINEAR, &xmb->textures.list[i]); - video_texture_image_free(&ti); + image_texture_free(&ti); } menu_display_allocate_white_texture(); diff --git a/menu/menu_display.c b/menu/menu_display.c index 0a863183be..688c13f7ce 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -548,7 +548,7 @@ void menu_display_handle_wallpaper_upload(void *task_data, load_image_info.type = MENU_IMAGE_WALLPAPER; menu_driver_ctl(RARCH_MENU_CTL_LOAD_IMAGE, &load_image_info); - video_texture_image_free(img); + image_texture_free(img); free(img); } diff --git a/tasks/task_image.c b/tasks/task_image.c index 0f7f4ebc63..87fda1bd09 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -70,10 +70,10 @@ static int cb_image_menu_upload_generic(void *data, size_t len) image->processing_final_state == IMAGE_PROCESS_ERROR_END) return -1; - video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, + image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); - video_texture_image_color_convert(r_shift, g_shift, b_shift, + image_texture_color_convert(r_shift, g_shift, b_shift, a_shift, &image->ti); image->is_blocking_on_processing = false; diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index 4427038171..27bbbe66e2 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 (!video_texture_image_load(image, path)) + if (!image_texture_load(image, path)) return false; overlay->load_images[overlay->load_images_size++] = *image;