Skip to content

Commit

Permalink
move video_texture_image to libretro-common and rename it to image_te…
Browse files Browse the repository at this point in the history
…xture.c
  • Loading branch information
inactive123 committed May 18, 2016
1 parent 4fd3a47 commit 7e36dcb
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile.ctr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,15 +1489,15 @@ 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();
}

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

Expand Down
2 changes: 1 addition & 1 deletion griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions input/input_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ 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);
overlay->load_images = NULL;
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
/* 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>
#include <stdlib.h>
#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>
Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -210,7 +212,7 @@ static bool video_texture_image_load_internal(
}


void video_texture_image_free(struct texture_image *img)
void image_texture_free(struct texture_image *img)
{
if (!img)
return;
Expand All @@ -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"))
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions libretro-common/formats/image_transfer.c
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 3 additions & 1 deletion libretro-common/formats/tga/rtga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 6 additions & 6 deletions libretro-common/include/formats/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
5 changes: 2 additions & 3 deletions menu/drivers/materialui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions menu/drivers/nuklear.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading

0 comments on commit 7e36dcb

Please sign in to comment.