From cb5d71ee036b1aa1fa850cf908ee0aa990b7409f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 31 Aug 2024 14:56:00 +0200 Subject: [PATCH] libtrx: improve image loading performance --- src/game/output.c | 15 ++++++--------- src/specific/s_output.c | 6 +++--- subprojects/libtrx | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/game/output.c b/src/game/output.c index 82907395a..161566085 100644 --- a/src/game/output.c +++ b/src/game/output.c @@ -957,15 +957,12 @@ void Output_LoadBackdropImage(const char *filename) m_BackdropImagePath = File_GuessExtension(filename, m_ImageExtensions); Memory_FreePointer(&old_path); - IMAGE *orig_img = Image_CreateFromFile(m_BackdropImagePath); - if (orig_img) { - IMAGE *scaled_img = Image_ScaleSmart( - orig_img, Viewport_GetWidth(), Viewport_GetHeight()); - if (scaled_img) { - S_Output_DownloadBackdropSurface(scaled_img); - Image_Free(scaled_img); - } - Image_Free(orig_img); + IMAGE *img = Image_CreateFromFileInto( + m_BackdropImagePath, Viewport_GetWidth(), Viewport_GetHeight(), + IMAGE_FIT_SMART); + if (img != NULL) { + S_Output_DownloadBackdropSurface(img); + Image_Free(img); } } diff --git a/src/specific/s_output.c b/src/specific/s_output.c index bb15e07a7..e84d49745 100644 --- a/src/specific/s_output.c +++ b/src/specific/s_output.c @@ -477,8 +477,8 @@ void S_Output_DrawBackdropSurface(void) void S_Output_DownloadBackdropSurface(const IMAGE *const image) { - if (!image) { - if (m_PictureSurface) { + if (image == NULL) { + if (m_PictureSurface != NULL) { bool result = GFX_2D_Surface_Clear(m_PictureSurface); S_Output_CheckError(result); } @@ -515,7 +515,7 @@ void S_Output_DownloadBackdropSurface(const IMAGE *const image) S_Output_CheckError(result); } - if (!m_PictureSurface) { + if (m_PictureSurface == NULL) { GFX_2D_SurfaceDesc surface_desc = { .width = m_SurfaceWidth, .height = m_SurfaceHeight, diff --git a/subprojects/libtrx b/subprojects/libtrx index 5553faeff..34009d4f1 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 5553faeffe4917913d92d7892f36a4792add8ada +Subproject commit 34009d4f16d78677e8f574dc64047343626b0763