@@ -242,19 +242,19 @@ Output1bitPixel (
242242 IN EFI_HII_IMAGE_PALETTE_INFO * PaletteInfo
243243 )
244244{
245- UINT16 Xpos ;
246- UINT16 Ypos ;
247- UINTN OffsetY ;
248- UINT8 Index ;
249- EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BitMapPtr ;
250- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue [2 ];
251- EFI_HII_IMAGE_PALETTE_INFO * Palette ;
252- UINTN PaletteSize ;
253- UINT8 Byte ;
245+ UINT16 Xpos ;
246+ UINT16 Ypos ;
247+ UINTN OffsetY ;
248+ UINT8 Index ;
249+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * BitMapPtr ;
250+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue [2 ];
251+ EFI_HII_IMAGE_PALETTE_INFO * Palette ;
252+ UINTN PaletteSize ;
253+ UINT8 Byte ;
254254
255255 ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL );
256256
257- BitMapPtr = Image -> Bitmap ;
257+ BitMapPtr = ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * ) Image -> Bitmap ;
258258
259259 //
260260 // First entry corresponds to color 0 and second entry corresponds to color 1.
@@ -271,8 +271,8 @@ Output1bitPixel (
271271 CopyMem (Palette , PaletteInfo , PaletteSize );
272272
273273 ZeroMem (PaletteValue , sizeof (PaletteValue ));
274- CopyRgbToGopPixel (& PaletteValue [0 ], & Palette -> PaletteValue [0 ], 1 );
275- CopyRgbToGopPixel (& PaletteValue [1 ], & Palette -> PaletteValue [1 ], 1 );
274+ CopyRgbToGopPixel (& PaletteValue [0 ]. Pixel , & Palette -> PaletteValue [0 ], 1 );
275+ CopyRgbToGopPixel (& PaletteValue [1 ]. Pixel , & Palette -> PaletteValue [1 ], 1 );
276276 FreePool (Palette );
277277 Palette = NULL ; // MU_CHANGE - Make sure to manage this pointer safely.
278278
@@ -288,9 +288,9 @@ Output1bitPixel (
288288 Byte = * (Data + OffsetY + Xpos );
289289 for (Index = 0 ; Index < 8 ; Index ++ ) {
290290 if ((Byte & (1 << Index )) != 0 ) {
291- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 8 + (8 - Index - 1 )], & PaletteValue [1 ], sizeof ( * BitMapPtr )) ;
291+ BitMapPtr [Ypos * Image -> Width + Xpos * 8 + (8 - Index - 1 )]. Raw = PaletteValue [1 ]. Raw ;
292292 } else {
293- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 8 + (8 - Index - 1 )], & PaletteValue [0 ], sizeof ( * BitMapPtr )) ;
293+ BitMapPtr [Ypos * Image -> Width + Xpos * 8 + (8 - Index - 1 )]. Raw = PaletteValue [0 ]. Raw ;
294294 }
295295 }
296296 }
@@ -303,9 +303,9 @@ Output1bitPixel (
303303 for (Index = 0 ; (UINT16 )Index < (UINT16 )(Image -> Width % 8 ); Index ++ ) {
304304 // MU_CHANGE - CodeQL Change - comparison-with-wider-type
305305 if ((Byte & (1 << (8 - Index - 1 ))) != 0 ) {
306- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 8 + Index ], & PaletteValue [1 ], sizeof ( * BitMapPtr )) ;
306+ BitMapPtr [Ypos * Image -> Width + Xpos * 8 + Index ]. Raw = PaletteValue [1 ]. Raw ;
307307 } else {
308- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 8 + Index ], & PaletteValue [0 ], sizeof ( * BitMapPtr )) ;
308+ BitMapPtr [Ypos * Image -> Width + Xpos * 8 + Index ]. Raw = PaletteValue [0 ]. Raw ;
309309 }
310310 }
311311 }
@@ -333,19 +333,19 @@ Output4bitPixel (
333333 IN EFI_HII_IMAGE_PALETTE_INFO * PaletteInfo
334334 )
335335{
336- UINT16 Xpos ;
337- UINT16 Ypos ;
338- UINTN OffsetY ;
339- EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BitMapPtr ;
340- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue [16 ];
341- EFI_HII_IMAGE_PALETTE_INFO * Palette ;
342- UINTN PaletteSize ;
343- UINT16 PaletteNum ;
344- UINT8 Byte ;
336+ UINT16 Xpos ;
337+ UINT16 Ypos ;
338+ UINTN OffsetY ;
339+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * BitMapPtr ;
340+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue [16 ];
341+ EFI_HII_IMAGE_PALETTE_INFO * Palette ;
342+ UINTN PaletteSize ;
343+ UINT16 PaletteNum ;
344+ UINT8 Byte ;
345345
346346 ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL );
347347
348- BitMapPtr = Image -> Bitmap ;
348+ BitMapPtr = ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * ) Image -> Bitmap ;
349349
350350 //
351351 // The bitmap should allocate each color index starting from 0.
@@ -363,7 +363,7 @@ Output4bitPixel (
363363 PaletteNum = (UINT16 )(Palette -> PaletteSize / sizeof (EFI_HII_RGB_PIXEL ));
364364
365365 ZeroMem (PaletteValue , sizeof (PaletteValue ));
366- CopyRgbToGopPixel (PaletteValue , Palette -> PaletteValue , MIN (PaletteNum , ARRAY_SIZE (PaletteValue )));
366+ CopyRgbToGopPixel (& PaletteValue -> Pixel , Palette -> PaletteValue , MIN (PaletteNum , ARRAY_SIZE (PaletteValue )));
367367 FreePool (Palette );
368368 Palette = NULL ; // MU_CHANGE - Make sure to manage this pointer safely.
369369
@@ -376,17 +376,17 @@ Output4bitPixel (
376376 // All bits in these bytes are meaningful
377377 //
378378 for (Xpos = 0 ; Xpos < Image -> Width / 2 ; Xpos ++ ) {
379- Byte = * (Data + OffsetY + Xpos );
380- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 2 ], & PaletteValue [Byte >> 4 ], sizeof ( * BitMapPtr )) ;
381- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 2 + 1 ], & PaletteValue [Byte & 0x0F ], sizeof ( * BitMapPtr )) ;
379+ Byte = * (Data + OffsetY + Xpos );
380+ BitMapPtr [Ypos * Image -> Width + Xpos * 2 ]. Raw = PaletteValue [Byte >> 4 ]. Raw ;
381+ BitMapPtr [Ypos * Image -> Width + Xpos * 2 + 1 ]. Raw = PaletteValue [Byte & 0x0F ]. Raw ;
382382 }
383383
384384 if (Image -> Width % 2 != 0 ) {
385385 //
386386 // Padding bits in this byte should be ignored.
387387 //
388- Byte = * (Data + OffsetY + Xpos );
389- CopyMem ( & BitMapPtr [Ypos * Image -> Width + Xpos * 2 ], & PaletteValue [Byte >> 4 ], sizeof ( * BitMapPtr )) ;
388+ Byte = * (Data + OffsetY + Xpos );
389+ BitMapPtr [Ypos * Image -> Width + Xpos * 2 ]. Raw = PaletteValue [Byte >> 4 ]. Raw ;
390390 }
391391 }
392392}
@@ -412,19 +412,19 @@ Output8bitPixel (
412412 IN EFI_HII_IMAGE_PALETTE_INFO * PaletteInfo
413413 )
414414{
415- UINT16 Xpos ;
416- UINT16 Ypos ;
417- UINTN OffsetY ;
418- EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BitMapPtr ;
419- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue [256 ];
420- EFI_HII_IMAGE_PALETTE_INFO * Palette ;
421- UINTN PaletteSize ;
422- UINT16 PaletteNum ;
423- UINT8 Byte ;
415+ UINT16 Xpos ;
416+ UINT16 Ypos ;
417+ UINTN OffsetY ;
418+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * BitMapPtr ;
419+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue [256 ];
420+ EFI_HII_IMAGE_PALETTE_INFO * Palette ;
421+ UINTN PaletteSize ;
422+ UINT16 PaletteNum ;
423+ UINT8 Byte ;
424424
425425 ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL );
426426
427- BitMapPtr = Image -> Bitmap ;
427+ BitMapPtr = ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * ) Image -> Bitmap ;
428428
429429 //
430430 // The bitmap should allocate each color index starting from 0.
@@ -441,7 +441,7 @@ Output8bitPixel (
441441 CopyMem (Palette , PaletteInfo , PaletteSize );
442442 PaletteNum = (UINT16 )(Palette -> PaletteSize / sizeof (EFI_HII_RGB_PIXEL ));
443443 ZeroMem (PaletteValue , sizeof (PaletteValue ));
444- CopyRgbToGopPixel (PaletteValue , Palette -> PaletteValue , MIN (PaletteNum , ARRAY_SIZE (PaletteValue )));
444+ CopyRgbToGopPixel (& PaletteValue -> Pixel , Palette -> PaletteValue , MIN (PaletteNum , ARRAY_SIZE (PaletteValue )));
445445 FreePool (Palette );
446446 Palette = NULL ; // MU_CHANGE - Make sure to manage this pointer safely.
447447
@@ -454,8 +454,8 @@ Output8bitPixel (
454454 // All bits are meaningful since the bitmap is 8 bits per pixel.
455455 //
456456 for (Xpos = 0 ; Xpos < Image -> Width ; Xpos ++ ) {
457- Byte = * (Data + OffsetY + Xpos );
458- CopyMem ( & BitMapPtr [OffsetY + Xpos ], & PaletteValue [Byte ], sizeof ( * BitMapPtr )) ;
457+ Byte = * (Data + OffsetY + Xpos );
458+ BitMapPtr [OffsetY + Xpos ]. Raw = PaletteValue [Byte ]. Raw ;
459459 }
460460 }
461461}
@@ -525,13 +525,15 @@ ImageToBlt (
525525 IN OUT EFI_IMAGE_OUTPUT * * Blt
526526 )
527527{
528- EFI_IMAGE_OUTPUT * ImageOut ;
529- UINTN Xpos ;
530- UINTN Ypos ;
531- UINTN OffsetY1 ; // src buffer
532- UINTN OffsetY2 ; // dest buffer
533- EFI_GRAPHICS_OUTPUT_BLT_PIXEL SrcPixel ;
534- EFI_GRAPHICS_OUTPUT_BLT_PIXEL ZeroPixel ;
528+ EFI_IMAGE_OUTPUT * ImageOut ;
529+ UINTN Xpos ;
530+ UINTN Ypos ;
531+ UINTN OffsetY1 ; // src buffer
532+ UINTN OffsetY2 ; // dest buffer
533+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION SrcPixel ;
534+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ZeroPixel ;
535+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * BltBufferPixel ;
536+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * ImageBitmap ;
535537
536538 if ((BltBuffer == NULL ) || (Blt == NULL ) || (* Blt == NULL )) {
537539 return EFI_INVALID_PARAMETER ;
@@ -549,17 +551,20 @@ ImageToBlt (
549551
550552 ZeroMem (& ZeroPixel , sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL ));
551553
554+ BltBufferPixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * )BltBuffer ;
555+ ImageBitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION * )ImageOut -> Image .Bitmap ;
556+
552557 for (Ypos = 0 ; Ypos < Height ; Ypos ++ ) {
553558 OffsetY1 = Width * Ypos ;
554559 OffsetY2 = ImageOut -> Width * (BltY + Ypos );
555560 for (Xpos = 0 ; Xpos < Width ; Xpos ++ ) {
556- CopyMem ( & SrcPixel , & BltBuffer [OffsetY1 + Xpos ], sizeof ( SrcPixel )) ;
561+ SrcPixel . Raw = BltBufferPixel [OffsetY1 + Xpos ]. Raw ;
557562 if (Transparent ) {
558- if (CompareMem (& SrcPixel , & ZeroPixel , 3 ) != 0 ) { \
559- CopyMem ( & ImageOut -> Image . Bitmap [OffsetY2 + BltX + Xpos ], & SrcPixel , sizeof ( SrcPixel )) ;
563+ if (CompareMem (& SrcPixel , & ZeroPixel , 3 ) != 0 ) {
564+ ImageBitmap [OffsetY2 + BltX + Xpos ]. Raw = SrcPixel . Raw ;
560565 }
561566 } else {
562- CopyMem ( & ImageOut -> Image . Bitmap [OffsetY2 + BltX + Xpos ], & SrcPixel , sizeof ( SrcPixel )) ;
567+ ImageBitmap [OffsetY2 + BltX + Xpos ]. Raw = SrcPixel . Raw ;
563568 }
564569 }
565570 }
0 commit comments