diff options
author | Joursoir <chat@joursoir.net> | 2022-03-27 10:14:27 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-03-27 10:14:32 +0300 |
commit | 507d749384846c2302c4749729ad2cc156d8cc12 (patch) | |
tree | d77a793920b37bc8d14c2aac091f9e6c473b8292 /UefiMonitorTest/UefiMonitorTest.c | |
parent | e32e65f7f87e75482c037e88c28ed7391461c25f (diff) | |
download | umt-507d749384846c2302c4749729ad2cc156d8cc12.tar.gz umt-507d749384846c2302c4749729ad2cc156d8cc12.tar.bz2 umt-507d749384846c2302c4749729ad2cc156d8cc12.zip |
main: make ParseGraphicsPixelFormat()
Diffstat (limited to 'UefiMonitorTest/UefiMonitorTest.c')
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 084a8b9..f84c00a 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -22,6 +22,51 @@ CONST EFI_PIXEL_BITMASK mBgrPixelMasks = { STATIC VOID +ParseGraphicsPixelFormat ( + IN CONST EFI_PIXEL_BITMASK *BitMask, + OUT UINT32 *PixelWidth, + OUT INT8 *PixelShl, + OUT INT8 *PixelShr + ) +{ + UINT8 Index; + UINT32 *Masks; + UINT32 MergedMasks; + + MergedMasks = 0; + Masks = (UINT32 *)BitMask; + for (Index = 0; Index < 3; Index++) { + ASSERT ((MergedMasks & Masks[Index]) == 0); + + PixelShl[Index] = (INT8)HighBitSet32 (Masks[Index]) - 23 + (Index * 8); + if (PixelShl[Index] < 0) { + PixelShr[Index] = -PixelShl[Index]; + PixelShl[Index] = 0; + } else { + PixelShr[Index] = 0; + } + + DEBUG (( + DEBUG_INFO, + "Index %d: shl:%d shr:%d mask:%08x\n", + Index, + PixelShl[Index], + PixelShr[Index], + Masks[Index] + )); + + MergedMasks = (UINT32)(MergedMasks | Masks[Index]); + } + + MergedMasks = (UINT32)(MergedMasks | Masks[3]); + + ASSERT (MergedMasks != 0); + *PixelWidth = (UINT32)((HighBitSet32 (MergedMasks) + 7) / 8); + DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *PixelWidth)); +} + +STATIC +VOID PrepareGraphicsInfo ( IN GRAPHICS_CONTEXT *Graphics, IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop |