From 444d9d9b38f94973f965e335719c6c46265f70ef Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sat, 26 Mar 2022 17:16:41 +0300 Subject: add double buffering --- UefiMonitorTest/UefiMonitorTest.c | 21 ++++++++++++++++++++- UefiMonitorTest/UefiMonitorTest.h | 10 +++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'UefiMonitorTest') diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 2d27013..8dda9b7 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -23,7 +23,10 @@ PrepareGraphicsInfo ( ASSERT (Gop != NULL); Graphics->Gop = Gop; - Graphics->Base = (UINT8 *)Gop->Mode->FrameBufferBase; + Graphics->FrontBuffer = (UINT8 *)Gop->Mode->FrameBufferBase; + Graphics->BufferSize = Gop->Mode->FrameBufferSize; + Graphics->BackBuffer = AllocateCopyPool (Graphics->BufferSize, Graphics->FrontBuffer); + ASSERT (Graphics->BackBuffer != NULL); Graphics->Width = Gop->Mode->Info->HorizontalResolution; Graphics->Height = Gop->Mode->Info->VerticalResolution; Graphics->PixelWidth = 4; // A pixel is 32-bits @@ -44,6 +47,18 @@ PrepareGraphicsInfo ( } STATIC +VOID +ForgetGraphicsInfo ( + IN GRAPHICS_CONTEXT *Graphics + ) +{ + ASSERT (Graphics != NULL); + + // Should we zero all the data structure? + + FreePool (Graphics->BackBuffer); +} + EFI_GRAPHICS_OUTPUT_PROTOCOL * GetGraphicsOutputProtocol ( VOID @@ -100,5 +115,9 @@ UefiMain ( PrepareGraphicsInfo (&Graphics, Gop); + + + ForgetGraphicsInfo (&Graphics); + return EFI_SUCCESS; } diff --git a/UefiMonitorTest/UefiMonitorTest.h b/UefiMonitorTest/UefiMonitorTest.h index d6306bc..97ada85 100644 --- a/UefiMonitorTest/UefiMonitorTest.h +++ b/UefiMonitorTest/UefiMonitorTest.h @@ -10,7 +10,15 @@ typedef struct { /// Base address of graphics linear frame buffer. /// Starts from the upper left pixel. /// - UINT8 *Base; + UINT8 *FrontBuffer; + /// + /// Pointer to allocated memory. Secondary linear buffer. + /// + UINT8 *BackBuffer; + /// + /// Amount of frame buffer needed to support the active mode. + /// + UINTN BufferSize; /// /// The size of video screen in pixels in the X dimension. /// -- cgit v1.2.3-18-g5258