From 7b98735878e8ee4412ffe292550f18e14ab51962 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 24 Mar 2022 21:44:16 +0000 Subject: [PATCH] Revert "An option to RLE-compress masked art" This reverts commit c884f1a354f53fd989a9fd3363fb770c116b5e62. Superceded by `DEVILUTIONX_CONVERT_FONTS_TO_CEL`, which offers the same RAM reduction but without slowdown. --- CMake/Definitions.cmake | 1 - CMakeLists.txt | 2 -- Source/DiabloUI/art.cpp | 17 ++--------------- Source/utils/sdl_compat.h | 9 +++++++++ 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CMake/Definitions.cmake b/CMake/Definitions.cmake index b3584929f..87b66400a 100644 --- a/CMake/Definitions.cmake +++ b/CMake/Definitions.cmake @@ -15,7 +15,6 @@ foreach( GPERF_HEAP_FIRST_GAME_ITERATION STREAM_ALL_AUDIO PACKET_ENCRYPTION - DEVILUTIONX_MASKED_ART_RLE DEVILUTIONX_CONVERT_FONTS_TO_CEL ) if(${def_name}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f311ddc..4b8a2c2d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,8 +59,6 @@ mark_as_advanced(DISABLE_STREAMING_SOUNDS) option(STREAM_ALL_AUDIO "Stream all the audio. For extremely RAM-constrained platforms.") mark_as_advanced(STREAM_ALL_AUDIO) -option(DEVILUTIONX_MASKED_ART_RLE "RLE-compress masked art in memory (e.g. fonts). Slightly lower RAM usage at a significant performance cost." OFF) - option(DEVILUTIONX_CONVERT_FONTS_TO_CEL "Convert PCX font files to CEL in memory.") if(TSAN) diff --git a/Source/DiabloUI/art.cpp b/Source/DiabloUI/art.cpp index 71cb41aaf..3cc5feca4 100644 --- a/Source/DiabloUI/art.cpp +++ b/Source/DiabloUI/art.cpp @@ -76,21 +76,8 @@ void LoadArt(const char *pszFile, Art *art, int frames, SDL_Color *pPalette, con void LoadMaskedArt(const char *pszFile, Art *art, int frames, int mask, const std::array *colorMapping) { LoadArt(pszFile, art, frames, nullptr, colorMapping); - if (art->surface == nullptr) - return; - SDL_Surface *surface = art->surface.get(); -#if SDL_VERSION_ATLEAST(2, 0, 0) -#ifdef DEVILUTIONX_MASKED_ART_RLE - SDL_SetSurfaceRLE(surface, 1); -#endif - SDL_SetColorKey(surface, SDL_TRUE, mask); -#else - int flags = SDL_SRCCOLORKEY; -#ifdef DEVILUTIONX_MASKED_ART_RLE - flags |= SDL_RLEACCEL; -#endif - SDL_SetColorKey(surface, flags, mask); -#endif + if (art->surface != nullptr) + SDLC_SetColorKey(art->surface.get(), mask); } void LoadArt(Art *art, const std::uint8_t *artData, int w, int h, int frames) diff --git a/Source/utils/sdl_compat.h b/Source/utils/sdl_compat.h index 4704f164d..bf1d79d4f 100644 --- a/Source/utils/sdl_compat.h +++ b/Source/utils/sdl_compat.h @@ -35,6 +35,15 @@ inline const Uint8 *SDLC_GetKeyState() #endif } +inline int SDLC_SetColorKey(SDL_Surface *surface, Uint32 key) +{ +#ifdef USE_SDL1 + return SDL_SetColorKey(surface, SDL_SRCCOLORKEY, key); +#else + return SDL_SetColorKey(surface, SDL_TRUE, key); +#endif +} + // Copies the colors into the surface's palette. inline int SDLC_SetSurfaceColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors) {