From d0ba59f8b505a2124dee2331e8ee50ae4d9aa2ff Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 11 Jun 2011 16:55:53 +0200 Subject: [PATCH] Start moving over to SDL_image rather than imlib2. Imlib2 takes more space, and was a pure bitch to compile for Win32, so I gave up ... ;) --- Makefile | 6 +++--- Makefile.win32 | 10 ++-------- Makefile.win64 | 6 ------ config.features.h | 6 +++--- gfx/image.c | 20 +++++++++----------- qb/config.libs.sh | 4 ++-- qb/config.params.sh | 2 +- ssnes.c | 2 +- 8 files changed, 21 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index f82626a51d..aed7decca2 100644 --- a/Makefile +++ b/Makefile @@ -104,9 +104,9 @@ ifeq ($(HAVE_FREETYPE), 1) DEFINES += $(FREETYPE_CFLAGS) endif -ifeq ($(HAVE_IMLIB), 1) - LIBS += $(IMLIB_LIBS) - DEFINES += $(IMLIB_CFLAGS) +ifeq ($(HAVE_SDL_IMAGE), 1) + LIBS += $(SDL_IMAGE_LIBS) + DEFINES += $(SDL_IMAGE_CFLAGS) endif ifeq ($(HAVE_FFMPEG), 1) diff --git a/Makefile.win32 b/Makefile.win32 index 09494fa371..2e26c7cbdc 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -16,9 +16,8 @@ HAVE_RSOUND = 1 HAVE_DYLIB = 1 HAVE_NETPLAY = 1 HAVE_FBO = 1 -HAVE_CG = 0 -HAVE_IMLIB = 0 -HAVE_PYTHON = 0 +HAVE_CG = 1 +HAVE_PYTHON = 1 libsnes ?= -lsnes LIBS = -lm @@ -95,11 +94,6 @@ ifeq ($(HAVE_DYLIB), 1) OBJ += gfx/ext.o audio/ext.o endif -ifeq ($(HAVE_IMLIB), 1) - LIBS += -lImlib2 - DEFINES += -DHAVE_IMLIB -endif - ifeq ($(HAVE_PYTHON), 1) LIBS += -lpython32 DEFINES += -DHAVE_PYTHON -Ipython diff --git a/Makefile.win64 b/Makefile.win64 index b2df1a6b3a..5d9d08f3d9 100644 --- a/Makefile.win64 +++ b/Makefile.win64 @@ -17,7 +17,6 @@ HAVE_DYLIB = 1 HAVE_NETPLAY = 1 HAVE_FBO = 1 HAVE_CG = 0 -HAVE_IMLIB = 0 HAVE_PYTHON = 0 libsnes ?= -lsnes @@ -95,11 +94,6 @@ ifeq ($(HAVE_DYLIB), 1) OBJ += gfx/ext.o audio/ext.o endif -ifeq ($(HAVE_IMLIB), 1) - LIBS += -lImlib2 - DEFINES += -DHAVE_IMLIB -endif - ifeq ($(HAVE_PYTHON), 1) LIBS += -lpython32 DEFINES += -DHAVE_PYTHON -Ipython diff --git a/config.features.h b/config.features.h index 2152c9a232..d1a8d2d209 100644 --- a/config.features.h +++ b/config.features.h @@ -80,10 +80,10 @@ static const bool _xml_supp = true; static const bool _xml_supp = false; #endif -#ifdef HAVE_IMLIB -static const bool _imlib_supp = true; +#ifdef HAVE_SDL_IMAGE +static const bool _sdl_image_supp = true; #else -static const bool _imlib_supp = false; +static const bool _sdl_image_supp = false; #endif #ifdef HAVE_FBO diff --git a/gfx/image.c b/gfx/image.c index c25ca37869..9c6896fccc 100644 --- a/gfx/image.c +++ b/gfx/image.c @@ -27,35 +27,33 @@ #include #include "general.h" -#ifdef HAVE_IMLIB +#ifdef HAVE_SDL_IMAGE -#include +#include "SDL_image.h" bool texture_image_load(const char *path, struct texture_image *out_img) { - Imlib_Image img; - img = imlib_load_image(path); + SDL_Surface *img = IMG_Load(path); if (!img) return false; - imlib_context_set_image(img); - - out_img->width = imlib_image_get_width(); - out_img->height = imlib_image_get_height(); + out_img->width = img->w; + out_img->height = img->h; size_t size = out_img->width * out_img->height * sizeof(uint32_t); out_img->pixels = malloc(size); if (!out_img->pixels) { - imlib_free_image(); + SDL_FreeSurface(img); return false; } - const uint32_t *read = imlib_image_get_data_for_reading_only(); + const uint32_t *read = img->pixels; // Convert ARGB -> RGBA. for (unsigned i = 0; i < size / sizeof(uint32_t); i++) out_img->pixels[i] = (read[i] >> 24) | (read[i] << 8); - imlib_free_image(); + SDL_FreeSurface(img); + return true; } diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 87d0ddcac9..b9bd99606b 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -43,7 +43,7 @@ check_critical SDL "Cannot find SDL library." check_lib CG -lCg cgCreateContext check_pkgconf XML libxml-2.0 -check_pkgconf IMLIB imlib2 +check_pkgconf SDL_IMAGE SDL_image if [ $HAVE_FFMPEG != no ]; then check_pkgconf AVCODEC libavcodec @@ -67,7 +67,7 @@ check_lib STRL -lc strlcpy check_pkgconf PYTHON python3 # Creates config.mk and config.h. -VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL DYLIB CG XML IMLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY FBO STRL PYTHON" +VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL DYLIB CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY FBO STRL PYTHON" create_config_make config.mk $VARS create_config_header config.h $VARS diff --git a/qb/config.params.sh b/qb/config.params.sh index f1202d4989..beb11d817a 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -26,5 +26,5 @@ add_command_line_enable JACK "Enable JACK support" auto add_command_line_enable PULSE "Enable PulseAudio support" auto add_command_line_enable FREETYPE "Enable FreeType support" auto add_command_line_enable XVIDEO "Enable XVideo support" auto -add_command_line_enable IMLIB "Enable imlib2 support" auto +add_command_line_enable SDL_IMAGE "Enable SDL_image support" auto add_command_line_enable PYTHON "Enable Python 3 support for shaders" no diff --git a/ssnes.c b/ssnes.c index 473ec4e5b4..a94094eee7 100644 --- a/ssnes.c +++ b/ssnes.c @@ -355,7 +355,7 @@ static void print_features(void) _PSUPP(dylib, "External", "External filter and driver support"); _PSUPP(cg, "Cg", "Cg pixel shaders"); _PSUPP(xml, "XML", "bSNES XML pixel shaders"); - _PSUPP(imlib, "Imlib2", "Imlib2 image loading"); + _PSUPP(sdl_image, "SDL_image", "SDL_image image loading"); _PSUPP(fbo, "FBO", "OpenGL render-to-texture (multi-pass shaders)"); _PSUPP(dynamic, "Dynamic", "Dynamic run-time loading of libsnes library"); _PSUPP(ffmpeg, "FFmpeg", "On-the-fly recording of gameplay with libavcodec");