From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CDE371A20CA for ; Fri, 23 Sep 2016 01:25:38 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 23 Sep 2016 01:25:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,381,1470726000"; d="scan'208";a="172311869" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 23 Sep 2016 01:25:37 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Liming Gao , Eric Dong , Dandan Bi Date: Fri, 23 Sep 2016 16:25:19 +0800 Message-Id: <20160923082521.99872-12-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20160923082521.99872-1-ruiyu.ni@intel.com> References: <20160923082521.99872-1-ruiyu.ni@intel.com> Subject: [PATCH 11/13] MdeModulePkg/BootLogoLib&PlatformLogo: Use HII data types in parameters X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2016 08:25:39 -0000 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 Cc: Liming Gao Cc: Eric Dong Cc: Dandan Bi Signed-off-by: Ruiyu Ni --- MdeModulePkg/Include/Library/BootLogoLib.h | 19 +-- MdeModulePkg/Include/Protocol/PlatformLogo.h | 18 +- MdeModulePkg/Library/BootLogoLib/BootLogoLib.c | 204 +++++++++-------------- MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf | 6 +- 4 files changed, 86 insertions(+), 161 deletions(-) diff --git a/MdeModulePkg/Include/Library/BootLogoLib.h b/MdeModulePkg/Include/Library/BootLogoLib.h index 55fe4b1..cacdd29 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 8c1d3ca..bb98c56 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,6 +16,8 @@ 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 // @@ -25,14 +27,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. typedef struct _EDKII_PLATFORM_LOGO_PROTOCOL EDKII_PLATFORM_LOGO_PROTOCOL; typedef enum { - ImageFormatUnknown, - ImageFormatBmp, - ImageFormatJpeg, - ImageFormatTiff, - ImageFormatGif -} IMAGE_FORMAT; - -typedef enum { EdkiiPlatformLogoDisplayAttributeLeftTop, EdkiiPlatformLogoDisplayAttributeCenterTop, EdkiiPlatformLogoDisplayAttributeRightTop, @@ -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 7cb3bcb..2c1e8ea 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 8698f26..8fa0b46 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 @@ -44,10 +44,6 @@ [LibraryClasses] DebugLib PrintLib PcdLib - DxeServicesLib - ImageDecoderLib - -[Guids] [Protocols] gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES -- 2.9.0.windows.1