diff options
author | Joursoir <chat@joursoir.net> | 2022-03-27 10:12:24 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-03-27 10:13:51 +0300 |
commit | e32e65f7f87e75482c037e88c28ed7391461c25f (patch) | |
tree | 9eb7ca68c1a74856c12273bbd1b5c7b716200447 /UefiMonitorTest/UefiMonitorTest.c | |
parent | 444d9d9b38f94973f965e335719c6c46265f70ef (diff) | |
download | umt-e32e65f7f87e75482c037e88c28ed7391461c25f.tar.gz umt-e32e65f7f87e75482c037e88c28ed7391461c25f.tar.bz2 umt-e32e65f7f87e75482c037e88c28ed7391461c25f.zip |
main: support different pixel formats
Diffstat (limited to 'UefiMonitorTest/UefiMonitorTest.c')
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 8dda9b7..084a8b9 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -12,6 +12,14 @@ #include "UefiMonitorTest.h" +CONST EFI_PIXEL_BITMASK mRgbPixelMasks = { + 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 +}; + +CONST EFI_PIXEL_BITMASK mBgrPixelMasks = { + 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 +}; + STATIC VOID PrepareGraphicsInfo ( @@ -19,31 +27,61 @@ PrepareGraphicsInfo ( IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop ) { + CONST EFI_PIXEL_BITMASK *BitMask; + UINT32 PixelWidth; + INT8 PixelShl[4]; + INT8 PixelShr[4]; + ASSERT (Graphics != NULL); ASSERT (Gop != NULL); - Graphics->Gop = Gop; - 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 - Graphics->Pitch = Graphics->PixelWidth * Gop->Mode->Info->PixelsPerScanLine; + switch (Gop->Mode->Info->PixelFormat) { + case PixelRedGreenBlueReserved8BitPerColor: + BitMask = &mRgbPixelMasks; + break; + + case PixelBlueGreenRedReserved8BitPerColor: + BitMask = &mBgrPixelMasks; + break; + + case PixelBitMask: + BitMask = &Gop->Mode->Info->PixelInformation; + break; + + case PixelBltOnly: + ASSERT (FALSE); + //return RETURN_UNSUPPORTED; + + default: + ASSERT (FALSE); + // return RETURN_INVALID_PARAMETER; + } DEBUG (( DEBUG_INFO, "GOP information:\n" "Mode: %d\n" - "Support a physical frame buffer: %s\n" "Framebuffer address, size: %x, %d\n" "Screen width x height: %d x %d\n", Gop->Mode->Mode, - (Gop->Mode->Info->PixelFormat == PixelBltOnly) ? L"NO" : L"YES", Gop->Mode->FrameBufferBase, Gop->Mode->FrameBufferSize, Gop->Mode->Info->HorizontalResolution, Gop->Mode->Info->VerticalResolution )); + + ParseGraphicsPixelFormat (BitMask, &PixelWidth, PixelShl, PixelShr); + + Graphics->Gop = Gop; + 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; + CopyMem (&Graphics->PixelMasks, BitMask, sizeof (*BitMask)); + CopyMem (Graphics->PixelShl, PixelShl, sizeof (PixelShl)); + CopyMem (Graphics->PixelShr, PixelShr, sizeof (PixelShr)); + Graphics->PixelWidth = PixelWidth; + Graphics->Pitch = Graphics->PixelWidth * Gop->Mode->Info->PixelsPerScanLine; } STATIC |