Skip to content

Commit

Permalink
libtrx: improve image loading performance
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Aug 31, 2024
1 parent 4359a9c commit cb5d71e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
15 changes: 6 additions & 9 deletions src/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/specific/s_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion subprojects/libtrx

0 comments on commit cb5d71e

Please sign in to comment.