cleanup screenshot memory management. fixes preview image not displaying

on gamecube
This commit is contained in:
Daryl Borth 2019-03-02 16:38:41 -07:00
parent f016b19cab
commit 6e1a197edd
3 changed files with 13 additions and 13 deletions

View File

@ -60,15 +60,9 @@ static GuiImageData * pointer[4];
#define MEM_ALLOC(A) (u8*)mem2_malloc(A)
#define MEM_DEALLOC(A) mem2_free(A)
#else
#ifdef USE_VM
#include "vmalloc.h"
#define MEM_ALLOC(A) (u8*)vm_malloc(A)
#define MEM_DEALLOC(A) vm_free(A)
#else
#define MEM_ALLOC(A) (u8*)memalign(32, A)
#define MEM_DEALLOC(A) free(A)
#endif
#endif
static GuiTrigger * trigA = NULL;
static GuiTrigger * trig2 = NULL;
@ -1562,8 +1556,7 @@ static int MenuGame()
delete gameScreenImg;
delete gameScreen;
gameScreen = NULL;
free(gameScreenPng);
gameScreenPng = NULL;
ClearScreenshot();
if(GCSettings.AutoloadGame) {
ExitApp();
}
@ -4400,11 +4393,7 @@ MainMenu (int menu)
if(gameScreen)
delete gameScreen;
if(gameScreenPng)
{
free(gameScreenPng);
gameScreenPng = NULL;
}
ClearScreenshot();
// wait for keys to be depressed
while(MenuRequested())

View File

@ -907,6 +907,16 @@ void TakeScreenshot()
}
}
void ClearScreenshot()
{
if(gameScreenPng)
{
gameScreenPngSize = 0;
free(gameScreenPng);
gameScreenPng = NULL;
}
}
/****************************************************************************
* ResetVideo_Menu
*

View File

@ -25,6 +25,7 @@ void setGFX();
void update_video (int width, int height);
void ResetVideo_Menu();
void TakeScreenshot();
void ClearScreenshot();
void Menu_Render();
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);