mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-17 07:58:55 +00:00
Kill SDL_image with fire.
This commit is contained in:
parent
e1387a7b0b
commit
731e44ba60
6
Makefile
6
Makefile
@ -319,12 +319,6 @@ ifeq ($(HAVE_FREETYPE), 1)
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(HAVE_SDL_IMAGE), 1)
|
||||
#OBJ += gfx/image/image_sdl.o
|
||||
#LIBS += $(SDL_IMAGE_LIBS)
|
||||
#DEFINES += $(SDL_IMAGE_CFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_ZLIB), 1)
|
||||
OBJ += gfx/rpng/rpng.o file_extract.o
|
||||
LIBS += $(ZLIB_LIBS)
|
||||
|
@ -87,7 +87,6 @@ HAVE_WINXINPUT = 1
|
||||
|
||||
ifeq ($(SLIM),)
|
||||
HAVE_SDL = 1
|
||||
HAVE_SDL_IMAGE = 1
|
||||
HAVE_LIBXML2 = 1
|
||||
HAVE_FREETYPE = 1
|
||||
HAVE_ZLIB = 1
|
||||
@ -146,12 +145,6 @@ ifeq ($(HAVE_OPENGL), 1)
|
||||
LIBS += -lopengl32 -lgdi32 -lcomdlg32
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SDL_IMAGE), 1)
|
||||
OBJ += gfx/image/image_sdl.o
|
||||
LIBS += -lSDL_image
|
||||
DEFINES += -DHAVE_SDL_IMAGE
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_CG), 1)
|
||||
OBJ += gfx/shader_cg.o
|
||||
LIBS += -lcg -lcgGL
|
||||
|
@ -1,131 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* FIXME - Fix this, it appears to be broken */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "image.h"
|
||||
#include "../../file.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include "../../general.h"
|
||||
#include "../rpng/rpng.h"
|
||||
|
||||
#include "SDL_image.h"
|
||||
|
||||
static bool sdl_load_argb_shift(const char *path, struct texture_image *out_img,
|
||||
unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift)
|
||||
{
|
||||
int y, x;
|
||||
size_t size;
|
||||
SDL_PixelFormat *fmt;
|
||||
SDL_Surface *img = (SDL_Surface*)IMG_Load(path);
|
||||
if (!img)
|
||||
return false;
|
||||
|
||||
out_img->width = img->w;
|
||||
out_img->height = img->h;
|
||||
|
||||
size = out_img->width * out_img->height * sizeof(uint32_t);
|
||||
out_img->pixels = (uint32_t*)malloc(size);
|
||||
|
||||
if (!out_img->pixels)
|
||||
{
|
||||
SDL_FreeSurface(img);
|
||||
return false;
|
||||
}
|
||||
|
||||
fmt = (SDL_PixelFormat*)img->format;
|
||||
|
||||
RARCH_LOG("SDL_image: %dx%d @ %d bpp\n", img->w, img->h, img->format->BitsPerPixel);
|
||||
|
||||
if (img->format->BitsPerPixel == 32)
|
||||
{
|
||||
for (y = 0; y < img->h; y++)
|
||||
{
|
||||
uint32_t *dst = (uint32_t*)(out_img->pixels + y * img->w);
|
||||
const uint32_t *src = (const uint32_t*)(img->pixels + y * img->pitch / sizeof(uint32_t));
|
||||
|
||||
for (x = 0; x < img->w; x++)
|
||||
{
|
||||
uint32_t r = (src[x] & fmt->Rmask) >> fmt->Rshift;
|
||||
uint32_t g = (src[x] & fmt->Gmask) >> fmt->Gshift;
|
||||
uint32_t b = (src[x] & fmt->Bmask) >> fmt->Bshift;
|
||||
uint32_t a = (src[x] & fmt->Amask) >> fmt->Ashift;
|
||||
dst[x] = (a << a_shift) | (r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (img->format->BitsPerPixel == 24)
|
||||
{
|
||||
for (y = 0; y < img->h; y++)
|
||||
{
|
||||
uint32_t *dst = (uint32_t*)(out_img->pixels + y * img->w);
|
||||
const uint8_t *src = (const uint8_t*)(img->pixels + y * img->pitch);
|
||||
|
||||
for (x = 0; x < img->w; x++)
|
||||
{
|
||||
// Correct?
|
||||
uint32_t color,r, g, b;
|
||||
color = 0;
|
||||
color |= src[3 * x + 0] << 0;
|
||||
color |= src[3 * x + 1] << 8;
|
||||
color |= src[3 * x + 2] << 16;
|
||||
r = (color & fmt->Rmask) >> fmt->Rshift;
|
||||
g = (color & fmt->Gmask) >> fmt->Gshift;
|
||||
b = (color & fmt->Bmask) >> fmt->Bshift;
|
||||
dst[x] = (0xff << a_shift) | (r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("8-bit and 16-bit image support are not implemented.\n");
|
||||
SDL_FreeSurface(img);
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_FreeSurface(img);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool texture_image_load(void *data, const char *path, void *image_data)
|
||||
{
|
||||
bool ret;
|
||||
(void)data;
|
||||
struct texture_image *out_img = (struct texture_image*)image_data;
|
||||
|
||||
// This interface "leak" is very ugly. FIXME: Fix this properly ...
|
||||
|
||||
if (driver.gfx_use_rgba)
|
||||
ret = sdl_load_argb_shift(path, out_img, 24, 0, 8, 16);
|
||||
else
|
||||
ret = sdl_load_argb_shift(path, out_img, 24, 16, 8, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void texture_image_free(void *data, void *image_data)
|
||||
{
|
||||
struct texture_image *img = (struct texture_image*)image_data;
|
||||
free(img->pixels);
|
||||
memset(img, 0, sizeof(*img));
|
||||
}
|
@ -165,12 +165,6 @@ else
|
||||
HAVE_CG='no'
|
||||
fi
|
||||
|
||||
if [ "$HAVE_SDL" = "no" ]; then
|
||||
echo "SDL is disabled. Disabling SDL_image."
|
||||
HAVE_SDL_IMAGE=no
|
||||
fi
|
||||
check_pkgconf SDL_IMAGE SDL_image
|
||||
|
||||
check_pkgconf ZLIB zlib
|
||||
|
||||
if [ "$HAVE_LIMA" = "yes" ]; then
|
||||
@ -274,6 +268,6 @@ add_define_make OS "$OS"
|
||||
|
||||
# Creates config.mk and config.h.
|
||||
add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR"
|
||||
VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 SDL_IMAGE ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT"
|
||||
VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT"
|
||||
create_config_make config.mk $VARS
|
||||
create_config_header config.h $VARS
|
||||
|
Loading…
x
Reference in New Issue
Block a user