mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(gfx/image) Cleanups
This commit is contained in:
parent
f861a10c44
commit
a1959a83c8
@ -182,14 +182,13 @@ error:
|
||||
|
||||
static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
{
|
||||
size_t img_size;
|
||||
#ifndef __PSL1GHT__
|
||||
#ifdef __PSL1GHT__
|
||||
uint64_t output_bytes_per_line;
|
||||
#else
|
||||
CtrlMallocArg MallocArg;
|
||||
CtrlFreeArg FreeArg;
|
||||
CellPngDecDataCtrlParam dCtrlParam;
|
||||
#endif
|
||||
CellPngDecMainHandle mHandle = PTR_NULL;
|
||||
CellPngDecSubHandle sHandle = PTR_NULL;
|
||||
CellPngDecThreadInParam InParam;
|
||||
CellPngDecThreadOutParam OutParam;
|
||||
CellPngDecSrc src;
|
||||
@ -198,6 +197,10 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
CellPngDecInParam inParam;
|
||||
CellPngDecOutParam outParam;
|
||||
CellPngDecDataOutInfo dOutInfo;
|
||||
size_t img_size;
|
||||
int ret_png, ret = -1;
|
||||
CellPngDecMainHandle mHandle = PTR_NULL;
|
||||
CellPngDecSubHandle sHandle = PTR_NULL;
|
||||
|
||||
InParam.spu_enable = CELL_PNGDEC_SPU_THREAD_ENABLE;
|
||||
InParam.ppu_prio = 512;
|
||||
@ -216,13 +219,13 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
InParam.free_arg = &FreeArg;
|
||||
#endif
|
||||
|
||||
int ret_png, ret = -1;
|
||||
ret_png = cellPngDecCreate(&mHandle, &InParam, &OutParam);
|
||||
|
||||
if (ret_png != CELL_OK)
|
||||
goto error;
|
||||
|
||||
memset(&src, 0, sizeof(CellPngDecSrc));
|
||||
|
||||
src.stream_select = CELL_PNGDEC_FILE;
|
||||
#ifdef __PSL1GHT__
|
||||
src.file_name = __get_addr32(path);
|
||||
@ -233,7 +236,6 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
src.file_size = 0;
|
||||
src.stream_ptr = 0;
|
||||
src.stream_size = 0;
|
||||
|
||||
src.spu_enable = CELL_PNGDEC_SPU_THREAD_ENABLE;
|
||||
|
||||
ret = cellPngDecOpen(mHandle, &sHandle, &src, &opnInfo);
|
||||
@ -252,6 +254,7 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
inParam.bit_depth = 8;
|
||||
inParam.pack_flag = CELL_PNGDEC_1BYTE_PER_1PIXEL;
|
||||
inParam.alpha_select = CELL_PNGDEC_STREAM_ALPHA;
|
||||
|
||||
ret = cellPngDecSetParameter(mHandle, sHandle, &inParam, &outParam);
|
||||
|
||||
if (ret != CELL_OK)
|
||||
@ -263,7 +266,7 @@ static bool ps3_load_png(const char *path, struct texture_image *out_img)
|
||||
memset(out_img->pixels, 0, img_size);
|
||||
|
||||
#ifdef __PSL1GHT__
|
||||
uint64_t output_bytes_per_line = outParam.output_width * 4;
|
||||
output_bytes_per_line = outParam.output_width * 4;
|
||||
ret = cellPngDecDecodeData(mHandle, sHandle, (uint8_t*)
|
||||
out_img->pixels, &output_bytes_per_line, &dOutInfo);
|
||||
#else
|
||||
@ -305,11 +308,9 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
if (!ps3_load_png(path, out_img))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (!ps3_load_jpeg(path, out_img))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -108,17 +108,11 @@ static bool rpng_image_load_tga_shift(const char *path,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
static bool rpng_image_load_argb_shift(const char *path,
|
||||
struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift,
|
||||
unsigned g_shift, unsigned b_shift)
|
||||
{
|
||||
if (strstr(path, ".tga"))
|
||||
return rpng_image_load_tga_shift(path, out_img,
|
||||
a_shift, r_shift, g_shift, b_shift);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (strstr(path, ".png"))
|
||||
{
|
||||
bool ret = rpng_load_image_argb(path,
|
||||
&out_img->pixels, &out_img->width, &out_img->height);
|
||||
@ -149,9 +143,6 @@ static bool rpng_image_load_argb_shift(const char *path,
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef GEKKO
|
||||
|
||||
#define GX_BLIT_LINE_32(off) \
|
||||
@ -226,9 +217,21 @@ void texture_image_free(struct texture_image *img)
|
||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
/* This interface "leak" is very ugly. FIXME: Fix this properly ... */
|
||||
bool ret = false;
|
||||
bool use_rgba = driver.gfx_use_rgba;
|
||||
bool ret = rpng_image_load_argb_shift(path, out_img, 24,
|
||||
use_rgba ? 0 : 16, 8, use_rgba ? 16 : 0);
|
||||
unsigned a_shift = 24;
|
||||
unsigned r_shift = use_rgba ? 0 : 16;
|
||||
unsigned g_shift = 8;
|
||||
unsigned b_shift = use_rgba ? 16 : 0;
|
||||
|
||||
if (strstr(path, ".tga"))
|
||||
ret = rpng_image_load_tga_shift(path, out_img,
|
||||
a_shift, r_shift, g_shift, b_shift);
|
||||
#ifdef HAVE_ZLIB
|
||||
else if (strstr(path, ".png"))
|
||||
ret = rpng_image_load_argb_shift(path, out_img,
|
||||
a_shift, r_shift, g_shift, b_shift);
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
if (ret)
|
||||
|
@ -19,9 +19,8 @@
|
||||
|
||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||
|
||||
D3DXIMAGE_INFO m_imageInfo;
|
||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||
|
||||
out_img->vertex_buf = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user