From e0ac9c8a9bd67ab934bca86504706b5400cde558 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Fri, 23 Sep 2016 15:54:01 +0800 Subject: [PATCH] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters 1. Change PlatformLogo protocol to return EFI_IMAGE_INPUT instead of RAW image data. PlatformLogo implementation can use HiiImageEx to decode the image if it's JPEG or PNG format. 2. Change BootLogoLib to consume the new PlatformLogo protocol. 3. Change BootLogoEnableLogo() to only use images returned from PlatformLogo protocol. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Liming Gao Cc: Eric Dong Cc: Dandan Bi Signed-off-by: Ruiyu Ni --- MdeModulePkg/Include/Library/BootLogoLib.h | 19 +- MdeModulePkg/Include/Protocol/PlatformLogo.h | 20 +- .../Library/BootLogoLib/BootLogoLib.c | 204 +++++++----------- .../Library/BootLogoLib/BootLogoLib.inf | 8 +- MdeModulePkg/MdeModulePkg.dec | 2 +- 5 files changed, 89 insertions(+), 164 deletions(-) diff --git a/MdeModulePkg/Include/Library/BootLogoLib.h b/MdeModulePkg/Include/Library/BootLogoLib.h index 55fe4b11cc..cacdd29ded 100644 --- a/MdeModulePkg/Include/Library/BootLogoLib.h +++ b/MdeModulePkg/Include/Library/BootLogoLib.h @@ -2,7 +2,7 @@ This library is only intended to be used by PlatformBootManagerLib to show progress bar and LOGO. -Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -20,25 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include /** - Show LOGO on all consoles. - - @param[in] ImageFormat Format of the image file. - @param[in] LogoFile The file name of logo to display. - @param[in] Attribute The display attributes of the image returned. - @param[in] OffsetX The X offset of the image regarding the Attribute. - @param[in] OffsetY The Y offset of the image regarding the Attribute. - - @retval EFI_SUCCESS Logo was displayed. - @retval EFI_UNSUPPORTED Logo was not found or cannot be displayed. + Show LOGO returned from Edkii Platform Logo protocol on all consoles. **/ EFI_STATUS EFIAPI BootLogoEnableLogo ( - IN IMAGE_FORMAT ImageFormat, - IN EFI_GUID *Logo, - IN EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute, - IN INTN OffsetX, - IN INTN OffsetY + VOID ); diff --git a/MdeModulePkg/Include/Protocol/PlatformLogo.h b/MdeModulePkg/Include/Protocol/PlatformLogo.h index 8c1d3cad40..4773173889 100644 --- a/MdeModulePkg/Include/Protocol/PlatformLogo.h +++ b/MdeModulePkg/Include/Protocol/PlatformLogo.h @@ -2,7 +2,7 @@ The Platform Logo Protocol defines the interface to get the Platform logo image with the display attribute. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -16,22 +16,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __PLATFORM_LOGO_H__ #define __PLATFORM_LOGO_H__ +#include + // // GUID for EDKII Platform Logo Protocol // #define EDKII_PLATFORM_LOGO_PROTOCOL_GUID \ - { 0x9b517978, 0xeba1, 0x44e7, { 0xba, 0x65, 0x7c, 0x2c, 0xd0, 0x8b, 0xf8, 0xe9 } } + { 0x53cd299f, 0x2bc1, 0x40c0, { 0x8c, 0x07, 0x23, 0xf6, 0x4f, 0xdb, 0x30, 0xe0 } } typedef struct _EDKII_PLATFORM_LOGO_PROTOCOL EDKII_PLATFORM_LOGO_PROTOCOL; -typedef enum { - ImageFormatUnknown, - ImageFormatBmp, - ImageFormatJpeg, - ImageFormatTiff, - ImageFormatGif -} IMAGE_FORMAT; - typedef enum { EdkiiPlatformLogoDisplayAttributeLeftTop, EdkiiPlatformLogoDisplayAttributeCenterTop, @@ -67,13 +61,11 @@ EFI_STATUS (EFIAPI *EDKII_PLATFORM_LOGO_GET_IMAGE)( IN EDKII_PLATFORM_LOGO_PROTOCOL *This, IN OUT UINT32 *Instance, - OUT IMAGE_FORMAT *Format, - OUT UINT8 **ImageData, - OUT UINTN *ImageSize, + OUT EFI_IMAGE_INPUT *Image, OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute, OUT INTN *OffsetX, OUT INTN *OffsetY -); + ); struct _EDKII_PLATFORM_LOGO_PROTOCOL { diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c index 7cb3bcba46..2c1e8ea5b4 100644 --- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c +++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c @@ -2,7 +2,7 @@ This library is only intended to be used by PlatformBootManagerLib to show progress bar and LOGO. -Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -13,30 +13,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include +#include +#include #include #include -#include #include #include #include #include #include #include -#include #include #include #include -#include /** - Show LOGO on all consoles. - - @param[in] ImageFormat Format of the image file. - @param[in] LogoFile The file name of logo to display. - @param[in] Attribute The display attributes of the image returned. - @param[in] OffsetX The X offset of the image regarding the Attribute. - @param[in] OffsetY The Y offset of the image regarding the Attribute. + Show LOGO returned from Edkii Platform Logo protocol on all consoles. @retval EFI_SUCCESS Logo was displayed. @retval EFI_UNSUPPORTED Logo was not found or cannot be displayed. @@ -44,42 +36,40 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. EFI_STATUS EFIAPI BootLogoEnableLogo ( - IN IMAGE_FORMAT ImageFormat, - IN EFI_GUID *Logo, - IN EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute, - IN INTN OffsetX, - IN INTN OffsetY + VOID ) { - EFI_STATUS Status; - EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo; - UINT32 SizeOfX; - UINT32 SizeOfY; - INTN DestX; - INTN DestY; - UINT8 *ImageData; - UINTN ImageSize; - UINTN BltSize; - UINT32 Instance; - UINTN Height; - UINTN Width; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - EFI_UGA_DRAW_PROTOCOL *UgaDraw; - UINT32 ColorDepth; - UINT32 RefreshRate; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - EFI_BOOT_LOGO_PROTOCOL *BootLogo; - UINTN NumberOfLogos; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt; - UINTN LogoDestX; - UINTN LogoDestY; - UINTN LogoHeight; - UINTN LogoWidth; - UINTN NewDestX; - UINTN NewDestY; - UINTN NewHeight; - UINTN NewWidth; - UINTN BufferSize; + EFI_STATUS Status; + EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo; + EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute; + INTN OffsetX; + INTN OffsetY; + UINT32 SizeOfX; + UINT32 SizeOfY; + INTN DestX; + INTN DestY; + UINT32 Instance; + EFI_IMAGE_INPUT Image; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + EFI_UGA_DRAW_PROTOCOL *UgaDraw; + UINT32 ColorDepth; + UINT32 RefreshRate; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_BOOT_LOGO_PROTOCOL *BootLogo; + UINTN NumberOfLogos; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt; + UINTN LogoDestX; + UINTN LogoDestY; + UINTN LogoHeight; + UINTN LogoWidth; + UINTN NewDestX; + UINTN NewDestY; + UINTN BufferSize; + + Status = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } UgaDraw = NULL; // @@ -100,15 +90,6 @@ BootLogoEnableLogo ( return EFI_UNSUPPORTED; } - Status = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo); - if (EFI_ERROR (Status)) { - PlatformLogo = NULL; - } - - if ((Logo == NULL) && (PlatformLogo == NULL)) { - return EFI_UNSUPPORTED; - } - // // Try to open Boot Logo Protocol. // @@ -142,59 +123,33 @@ BootLogoEnableLogo ( LogoWidth = 0; NewDestX = 0; NewDestY = 0; - NewHeight = 0; - NewWidth = 0; Instance = 0; DestX = 0; DestY = 0; while (TRUE) { - ImageData = NULL; - ImageSize = 0; - - if (PlatformLogo != NULL) { - // - // Get image from OEMBadging protocol. - // - Status = PlatformLogo->GetImage ( - PlatformLogo, - &Instance, - &ImageFormat, - &ImageData, - &ImageSize, - &Attribute, - &OffsetX, - &OffsetY - ); - if (EFI_ERROR (Status)) { - break; - } + // + // Get image from PlatformLogo protocol. + // + Status = PlatformLogo->GetImage ( + PlatformLogo, + &Instance, + &Image, + &Attribute, + &OffsetX, + &OffsetY + ); + if (EFI_ERROR (Status)) { + break; + } - } else { - // - // Get the specified image from FV. - // - Status = GetSectionFromAnyFv (Logo, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } + if (EFI_ERROR (Status)) { + continue; } if (Blt != NULL) { FreePool (Blt); } - - Status = DecodeImage (ImageFormat, ImageData, ImageSize, &Blt, &BltSize, &Width, &Height); - FreePool (ImageData); - if (EFI_ERROR (Status)) { - if (Logo != NULL) { - // - // Directly return failure for single LOGO - // - return Status; - } else { - continue; - } - } + Blt = Image.Bitmap; // // Calculate the display position according to Attribute. @@ -205,42 +160,43 @@ BootLogoEnableLogo ( DestY = 0; break; case EdkiiPlatformLogoDisplayAttributeCenterTop: - DestX = (SizeOfX - Width) / 2; + DestX = (SizeOfX - Image.Width) / 2; DestY = 0; break; case EdkiiPlatformLogoDisplayAttributeRightTop: - DestX = SizeOfX - Width; + DestX = SizeOfX - Image.Width; DestY = 0; break; case EdkiiPlatformLogoDisplayAttributeCenterLeft: DestX = 0; - DestY = (SizeOfY - Height) / 2; + DestY = (SizeOfY - Image.Height) / 2; break; case EdkiiPlatformLogoDisplayAttributeCenter: - DestX = (SizeOfX - Width) / 2; - DestY = (SizeOfY - Height) / 2; + DestX = (SizeOfX - Image.Width) / 2; + DestY = (SizeOfY - Image.Height) / 2; break; case EdkiiPlatformLogoDisplayAttributeCenterRight: - DestX = SizeOfX - Width; - DestY = (SizeOfY - Height) / 2; + DestX = SizeOfX - Image.Width; + DestY = (SizeOfY - Image.Height) / 2; break; case EdkiiPlatformLogoDisplayAttributeLeftBottom: DestX = 0; - DestY = SizeOfY - Height; + DestY = SizeOfY - Image.Height; break; case EdkiiPlatformLogoDisplayAttributeCenterBottom: - DestX = (SizeOfX - Width) / 2; - DestY = SizeOfY - Height; + DestX = (SizeOfX - Image.Width) / 2; + DestY = SizeOfY - Image.Height; break; case EdkiiPlatformLogoDisplayAttributeRightBottom: - DestX = SizeOfX - Width; - DestY = SizeOfY - Height; + DestX = SizeOfX - Image.Width; + DestY = SizeOfY - Image.Height; break; default: ASSERT (FALSE); + continue; break; } @@ -257,9 +213,9 @@ BootLogoEnableLogo ( 0, (UINTN) DestX, (UINTN) DestY, - Width, - Height, - Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + Image.Width, + Image.Height, + Image.Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) ); } else { ASSERT (UgaDraw != NULL); @@ -271,9 +227,9 @@ BootLogoEnableLogo ( 0, (UINTN) DestX, (UINTN) DestY, - Width, - Height, - Width * sizeof (EFI_UGA_PIXEL) + Image.Width, + Image.Height, + Image.Width * sizeof (EFI_UGA_PIXEL) ); } @@ -283,34 +239,28 @@ BootLogoEnableLogo ( if (!EFI_ERROR (Status)) { NumberOfLogos++; - if (LogoWidth == 0) { + if (NumberOfLogos == 1) { // // The first Logo. // LogoDestX = (UINTN) DestX; LogoDestY = (UINTN) DestY; - LogoWidth = Width; - LogoHeight = Height; + LogoWidth = Image.Width; + LogoHeight = Image.Height; } else { // // Merge new logo with old one. // NewDestX = MIN ((UINTN) DestX, LogoDestX); NewDestY = MIN ((UINTN) DestY, LogoDestY); - NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX; - NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY; + LogoWidth = MAX ((UINTN) DestX + Image.Width, LogoDestX + LogoWidth) - NewDestX; + LogoHeight = MAX ((UINTN) DestY + Image.Height, LogoDestY + LogoHeight) - NewDestY; LogoDestX = NewDestX; LogoDestY = NewDestY; - LogoWidth = NewWidth; - LogoHeight = NewHeight; } } } - - if (PlatformLogo == NULL) { - break; - } } if (BootLogo == NULL || NumberOfLogos == 0) { diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf index 8698f26fc4..79b5fc511a 100644 --- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf +++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf @@ -2,7 +2,7 @@ # This library is only intended to be used by PlatformBootManagerLib # to show progress bar and logo. # -# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
# This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at @@ -17,7 +17,7 @@ INF_VERSION = 0x00010005 BASE_NAME = BootLogoLib MODULE_UNI_FILE = BootLogoLib.uni - FILE_GUID = F5AE5B5C-42E8-4A9B-829D-5B631CD5367A + FILE_GUID = 85CDAFAD-13BE-422A-A8E5-55A249600DC3 MODULE_TYPE = DXE_DRIVER VERSION_STRING = 1.0 LIBRARY_CLASS = BootLogoLib|DXE_DRIVER UEFI_APPLICATION @@ -44,10 +44,6 @@ DebugLib PrintLib PcdLib - DxeServicesLib - ImageDecoderLib - -[Guids] [Protocols] gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index bd375f4046..b28677b2df 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -492,7 +492,7 @@ gEdkiiSmmReadyToBootProtocolGuid = { 0x6e057ecf, 0xfa99, 0x4f39, { 0x95, 0xbc, 0x59, 0xf9, 0x92, 0x1d, 0x17, 0xe4 } } ## Include/Protocol/PlatformLogo.h - gEdkiiPlatformLogoProtocolGuid = { 0x9b517978, 0xeba1, 0x44e7, { 0xba, 0x65, 0x7c, 0x2c, 0xd0, 0x8b, 0xf8, 0xe9 } } + gEdkiiPlatformLogoProtocolGuid = { 0x53cd299f, 0x2bc1, 0x40c0, { 0x8c, 0x07, 0x23, 0xf6, 0x4f, 0xdb, 0x30, 0xe0 } } ## Include/Protocol/FileExplorer.h gEfiFileExplorerProtocolGuid = { 0x2C03C536, 0x4594, 0x4515, { 0x9E, 0x7A, 0xD3, 0xD2, 0x04, 0xFE, 0x13, 0x63 } } -- 2.39.2