mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 20:43:10 +00:00
Split up image transfer code to separate file
This commit is contained in:
parent
6daf6e2270
commit
13f49e1d9a
@ -911,7 +911,8 @@ ifeq ($(HAVE_RJPEG), 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
OBJ += libretro-common/formats/bmp/rbmp_encode.o \
|
OBJ += libretro-common/formats/bmp/rbmp_encode.o \
|
||||||
libretro-common/formats/json/jsonsax.o
|
libretro-common/formats/json/jsonsax.o \
|
||||||
|
libretro-common/formats/image_transfer.o
|
||||||
|
|
||||||
ifeq ($(HAVE_RTGA), 1)
|
ifeq ($(HAVE_RTGA), 1)
|
||||||
OBJ += libretro-common/formats/tga/rtga.o
|
OBJ += libretro-common/formats/tga/rtga.o
|
||||||
|
@ -230,6 +230,7 @@ VIDEO IMAGE
|
|||||||
#include "../cores/libretro-imageviewer/image_core.c"
|
#include "../cores/libretro-imageviewer/image_core.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../libretro-common/formats/image_transfer.c"
|
||||||
#ifdef HAVE_RPNG
|
#ifdef HAVE_RPNG
|
||||||
#include "../libretro-common/formats/png/rpng.c"
|
#include "../libretro-common/formats/png/rpng.c"
|
||||||
#include "../libretro-common/formats/png/rpng_encode.c"
|
#include "../libretro-common/formats/png/rpng_encode.c"
|
||||||
|
131
libretro-common/formats/image_transfer.c
Normal file
131
libretro-common/formats/image_transfer.c
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
#include <formats/rpng.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#include <formats/rjpeg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <formats/image.h>
|
||||||
|
|
||||||
|
void image_transfer_free(void *data, enum image_type_enum type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
rpng_nbio_load_image_free((rpng_t*)data);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *image_transfer_new(enum image_type_enum type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
return rpng_alloc();
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool image_transfer_start(void *data, enum image_type_enum type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
if (!rpng_nbio_load_image_argb_start((rpng_t*)data))
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void image_transfer_set_buffer_ptr(
|
||||||
|
void *data,
|
||||||
|
enum image_type_enum type,
|
||||||
|
void *ptr)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int image_transfer_process(
|
||||||
|
void *data,
|
||||||
|
enum image_type_enum type,
|
||||||
|
uint32_t **buf,
|
||||||
|
unsigned *width, unsigned *height)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
if (!rpng_is_valid((rpng_t*)data))
|
||||||
|
return IMAGE_PROCESS_ERROR;
|
||||||
|
|
||||||
|
return rpng_nbio_load_image_argb_process(
|
||||||
|
(rpng_t*)data,
|
||||||
|
buf,
|
||||||
|
width, height);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool image_transfer_iterate(void *data, enum image_type_enum type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case IMAGE_TYPE_PNG:
|
||||||
|
#ifdef HAVE_RPNG
|
||||||
|
if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data))
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IMAGE_TYPE_JPEG:
|
||||||
|
#ifdef HAVE_RJPEG
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
@ -40,6 +40,12 @@ struct texture_image
|
|||||||
uint32_t *pixels;
|
uint32_t *pixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum image_type_enum
|
||||||
|
{
|
||||||
|
IMAGE_TYPE_PNG = 0,
|
||||||
|
IMAGE_TYPE_JPEG
|
||||||
|
};
|
||||||
|
|
||||||
bool video_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);
|
unsigned *b_shift, unsigned *a_shift);
|
||||||
|
|
||||||
@ -50,6 +56,27 @@ bool video_texture_image_color_convert(unsigned r_shift,
|
|||||||
bool video_texture_image_load(struct texture_image *img, const char *path);
|
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_free(struct texture_image *img);
|
||||||
|
|
||||||
|
/* Image transfer */
|
||||||
|
|
||||||
|
void image_transfer_free(void *data, enum image_type_enum type);
|
||||||
|
|
||||||
|
void *image_transfer_new(enum image_type_enum type);
|
||||||
|
|
||||||
|
bool image_transfer_start(void *data, enum image_type_enum type);
|
||||||
|
|
||||||
|
void image_transfer_set_buffer_ptr(
|
||||||
|
void *data,
|
||||||
|
enum image_type_enum type,
|
||||||
|
void *ptr);
|
||||||
|
|
||||||
|
int image_transfer_process(
|
||||||
|
void *data,
|
||||||
|
enum image_type_enum type,
|
||||||
|
uint32_t **buf,
|
||||||
|
unsigned *width, unsigned *height);
|
||||||
|
|
||||||
|
bool image_transfer_iterate(void *data, enum image_type_enum type);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <lists/string_list.h>
|
#include <lists/string_list.h>
|
||||||
#include <rhash.h>
|
#include <rhash.h>
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
#include <formats/rpng.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#include <formats/rjpeg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
#include "../menu/menu_driver.h"
|
#include "../menu/menu_driver.h"
|
||||||
@ -99,132 +93,13 @@ static int cb_nbio_default(void *data, size_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_transfer_free(void *data, enum image_type_enum type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
rpng_nbio_load_image_free((rpng_t*)data);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void *image_transfer_new(enum image_type_enum type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
return rpng_alloc();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool image_transfer_start(void *data, enum image_type_enum type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
if (!rpng_nbio_load_image_argb_start((rpng_t*)data))
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void image_transfer_set_buffer_ptr(
|
|
||||||
void *data,
|
|
||||||
enum image_type_enum type,
|
|
||||||
void *ptr)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int image_transfer_process(
|
|
||||||
void *data,
|
|
||||||
enum image_type_enum type,
|
|
||||||
uint32_t **buf,
|
|
||||||
unsigned *width, unsigned *height)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
if (!rpng_is_valid((rpng_t*)data))
|
|
||||||
return IMAGE_PROCESS_ERROR;
|
|
||||||
|
|
||||||
return rpng_nbio_load_image_argb_process(
|
|
||||||
(rpng_t*)data,
|
|
||||||
buf,
|
|
||||||
width, height);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool image_transfer_iterate(void *data, enum image_type_enum type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case IMAGE_TYPE_PNG:
|
|
||||||
#ifdef HAVE_RPNG
|
|
||||||
if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data))
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case IMAGE_TYPE_JPEG:
|
|
||||||
#ifdef HAVE_RJPEG
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rarch_main_data_image_process(
|
static int rarch_main_data_image_process(
|
||||||
nbio_handle_t *nbio,
|
nbio_handle_t *nbio,
|
||||||
unsigned *width,
|
unsigned *width,
|
||||||
unsigned *height)
|
unsigned *height)
|
||||||
{
|
{
|
||||||
int retval = image_transfer_process(
|
int retval = image_transfer_process(
|
||||||
(rpng_t*)nbio->image.handle,
|
nbio->image.handle,
|
||||||
nbio->image_type,
|
nbio->image_type,
|
||||||
&nbio->image.ti.pixels, width, height);
|
&nbio->image.ti.pixels, width, height);
|
||||||
|
|
||||||
|
@ -40,12 +40,6 @@ enum nbio_status_enum
|
|||||||
NBIO_STATUS_TRANSFER_PARSE_FREE
|
NBIO_STATUS_TRANSFER_PARSE_FREE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum image_type_enum
|
|
||||||
{
|
|
||||||
IMAGE_TYPE_PNG = 0,
|
|
||||||
IMAGE_TYPE_JPEG
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user