mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +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__
|
||||
CtrlMallocArg MallocArg;
|
||||
CtrlFreeArg FreeArg;
|
||||
#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,15 +197,19 @@ 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;
|
||||
InParam.spu_prio = 200;
|
||||
#ifdef __PSL1GHT__
|
||||
InParam.malloc_func = __get_addr32(__get_opd32(img_malloc));
|
||||
InParam.free_func = __get_addr32(__get_opd32(img_free));
|
||||
InParam.malloc_arg = 0;
|
||||
InParam.free_arg = 0;
|
||||
InParam.malloc_func = __get_addr32(__get_opd32(img_malloc));
|
||||
InParam.free_func = __get_addr32(__get_opd32(img_free));
|
||||
InParam.malloc_arg = 0;
|
||||
InParam.free_arg = 0;
|
||||
#else
|
||||
MallocArg.mallocCallCounts = 0;
|
||||
FreeArg.freeCallCounts = 0;
|
||||
@ -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,8 +236,7 @@ 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;
|
||||
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;
|
||||
}
|
||||
|
||||
if (!ps3_load_jpeg(path, out_img))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -108,49 +108,40 @@ 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);
|
||||
bool ret = rpng_load_image_argb(path,
|
||||
&out_img->pixels, &out_img->width, &out_img->height);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (strstr(path, ".png"))
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
/* This is quite uncommon. */
|
||||
if (a_shift != 24 || r_shift != 16 || g_shift != 8 || b_shift != 0)
|
||||
{
|
||||
bool ret = rpng_load_image_argb(path,
|
||||
&out_img->pixels, &out_img->width, &out_img->height);
|
||||
uint32_t i;
|
||||
uint32_t num_pixels = out_img->width * out_img->height;
|
||||
uint32_t *pixels = (uint32_t*)out_img->pixels;
|
||||
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
/* This is quite uncommon. */
|
||||
if (a_shift != 24 || r_shift != 16 || g_shift != 8 || b_shift != 0)
|
||||
for (i = 0; i < num_pixels; i++)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t num_pixels = out_img->width * out_img->height;
|
||||
uint32_t *pixels = (uint32_t*)out_img->pixels;
|
||||
|
||||
for (i = 0; i < num_pixels; i++)
|
||||
{
|
||||
uint32_t col = pixels[i];
|
||||
uint8_t a = (uint8_t)(col >> 24);
|
||||
uint8_t r = (uint8_t)(col >> 16);
|
||||
uint8_t g = (uint8_t)(col >> 8);
|
||||
uint8_t b = (uint8_t)(col >> 0);
|
||||
pixels[i] = (a << a_shift) |
|
||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
uint32_t col = pixels[i];
|
||||
uint8_t a = (uint8_t)(col >> 24);
|
||||
uint8_t r = (uint8_t)(col >> 16);
|
||||
uint8_t g = (uint8_t)(col >> 8);
|
||||
uint8_t b = (uint8_t)(col >> 0);
|
||||
pixels[i] = (a << a_shift) |
|
||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
|
||||
@ -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 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);
|
||||
bool ret = false;
|
||||
bool use_rgba = driver.gfx_use_rgba;
|
||||
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