[FREELDR:UI] Clean-up when uninitializing the UI.

- If the started OS loader failed and we are back to the OS selection
  menu, re-initialize the UI as the loader may have messed up the display
  in the meantime.

- Tear down allocated off-screen back-buffer when uninitializing the TUI.
- Clear up the screen when initializing the direct-UI.
This commit is contained in:
Hermès Bélusca-Maïto 2022-02-06 20:29:05 +01:00
parent e2daca3f60
commit 313e6b6cbb
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 30 additions and 6 deletions

View file

@ -401,6 +401,13 @@ VOID RunLoader(VOID)
/* Load the chosen operating system */
LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]);
/* If we get there, the OS loader failed. As it may have
* messed up the display, re-initialize the UI. */
#ifndef _M_ARM
UiVtbl.UnInitialize();
#endif
UiInitialize(TRUE);
}
Reboot:

View file

@ -19,7 +19,9 @@ typedef struct _PALETTE_ENTRY
// extern PVOID VideoOffScreenBuffer;
PVOID VideoAllocateOffScreenBuffer(VOID); // Returns a pointer to an off-screen buffer sufficient for the current video mode
VOID VideoCopyOffScreenBufferToVRAM(VOID);
VOID VideoFreeOffScreenBuffer(VOID);
VOID VideoCopyOffScreenBufferToVRAM(VOID);
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);

View file

@ -34,6 +34,9 @@ UiInitialize(IN BOOLEAN ShowUi)
/* Set mode and query size */
MachVideoSetDisplayMode(NULL, TRUE);
MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth);
/* Clear the screen */
UiDrawBackdrop();
return TRUE;
}

View file

@ -210,6 +210,10 @@ BOOLEAN TuiInitialize(VOID)
VOID TuiUnInitialize(VOID)
{
/* Do nothing if already uninitialized */
if (!TextVideoBuffer)
return;
if (UiUseSpecialEffects)
{
TuiFadeOut();
@ -219,6 +223,9 @@ VOID TuiUnInitialize(VOID)
MachVideoSetDisplayMode(NULL, FALSE);
}
VideoFreeOffScreenBuffer();
TextVideoBuffer = NULL;
MachVideoClearScreen(ATTR(COLOR_GRAY, COLOR_BLACK));
MachVideoSetTextCursorPosition(0, 0);
MachVideoHideShowTextCursor(TRUE);

View file

@ -18,11 +18,7 @@ PVOID VideoAllocateOffScreenBuffer(VOID)
{
ULONG BufferSize;
if (VideoOffScreenBuffer != NULL)
{
MmFreeMemory(VideoOffScreenBuffer);
VideoOffScreenBuffer = NULL;
}
VideoFreeOffScreenBuffer();
BufferSize = MachVideoGetBufferSize();
@ -31,6 +27,15 @@ PVOID VideoAllocateOffScreenBuffer(VOID)
return VideoOffScreenBuffer;
}
VOID VideoFreeOffScreenBuffer(VOID)
{
if (!VideoOffScreenBuffer)
return;
MmFreeMemory(VideoOffScreenBuffer);
VideoOffScreenBuffer = NULL;
}
VOID VideoCopyOffScreenBufferToVRAM(VOID)
{
MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer);