move video_texture_image to libretro-common and rename it to image_texture.c

This commit is contained in:
twinaphex 2016-05-18 12:57:44 +02:00
parent 4fd3a4743a
commit 7e36dcb27f
16 changed files with 94 additions and 69 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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();
}

View File

@ -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"

View File

@ -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)

View File

@ -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 <http://www.gnu.org/licenses/>.
* 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 <stdint.h>
@ -19,10 +25,6 @@
#include <string.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include <boolean.h>
#include <formats/image.h>
#include <file/nbio.h>
@ -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;

View File

@ -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 <stdint.h>
#include <string.h>
#include <errno.h>

View File

@ -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
{

View File

@ -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 */

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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;

View File

@ -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;