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 <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
Ruiyu Ni 2016-09-23 15:54:01 +08:00
parent 2abec4bf18
commit e0ac9c8a9b
5 changed files with 89 additions and 164 deletions

View File

@ -2,7 +2,7 @@
This library is only intended to be used by PlatformBootManagerLib This library is only intended to be used by PlatformBootManagerLib
to show progress bar and LOGO. to show progress bar and LOGO.
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under 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 terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at 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 <Protocol/GraphicsOutput.h> #include <Protocol/GraphicsOutput.h>
/** /**
Show LOGO on all consoles. Show LOGO returned from Edkii Platform Logo protocol 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.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
BootLogoEnableLogo ( BootLogoEnableLogo (
IN IMAGE_FORMAT ImageFormat, VOID
IN EFI_GUID *Logo,
IN EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute,
IN INTN OffsetX,
IN INTN OffsetY
); );

View File

@ -2,7 +2,7 @@
The Platform Logo Protocol defines the interface to get the Platform logo The Platform Logo Protocol defines the interface to get the Platform logo
image with the display attribute. image with the display attribute.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under 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 terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at 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__ #ifndef __PLATFORM_LOGO_H__
#define __PLATFORM_LOGO_H__ #define __PLATFORM_LOGO_H__
#include <Protocol/HiiImage.h>
// //
// GUID for EDKII Platform Logo Protocol // GUID for EDKII Platform Logo Protocol
// //
#define EDKII_PLATFORM_LOGO_PROTOCOL_GUID \ #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 struct _EDKII_PLATFORM_LOGO_PROTOCOL EDKII_PLATFORM_LOGO_PROTOCOL;
typedef enum {
ImageFormatUnknown,
ImageFormatBmp,
ImageFormatJpeg,
ImageFormatTiff,
ImageFormatGif
} IMAGE_FORMAT;
typedef enum { typedef enum {
EdkiiPlatformLogoDisplayAttributeLeftTop, EdkiiPlatformLogoDisplayAttributeLeftTop,
EdkiiPlatformLogoDisplayAttributeCenterTop, EdkiiPlatformLogoDisplayAttributeCenterTop,
@ -67,13 +61,11 @@ EFI_STATUS
(EFIAPI *EDKII_PLATFORM_LOGO_GET_IMAGE)( (EFIAPI *EDKII_PLATFORM_LOGO_GET_IMAGE)(
IN EDKII_PLATFORM_LOGO_PROTOCOL *This, IN EDKII_PLATFORM_LOGO_PROTOCOL *This,
IN OUT UINT32 *Instance, IN OUT UINT32 *Instance,
OUT IMAGE_FORMAT *Format, OUT EFI_IMAGE_INPUT *Image,
OUT UINT8 **ImageData,
OUT UINTN *ImageSize,
OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute, OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,
OUT INTN *OffsetX, OUT INTN *OffsetX,
OUT INTN *OffsetY OUT INTN *OffsetY
); );
struct _EDKII_PLATFORM_LOGO_PROTOCOL { struct _EDKII_PLATFORM_LOGO_PROTOCOL {

View File

@ -2,7 +2,7 @@
This library is only intended to be used by PlatformBootManagerLib This library is only intended to be used by PlatformBootManagerLib
to show progress bar and LOGO. to show progress bar and LOGO.
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under 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 terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at 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 <PiDxe.h> #include <Uefi.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/SimpleTextOut.h> #include <Protocol/SimpleTextOut.h>
#include <Protocol/PlatformLogo.h> #include <Protocol/PlatformLogo.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/UgaDraw.h> #include <Protocol/UgaDraw.h>
#include <Protocol/BootLogo.h> #include <Protocol/BootLogo.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/ImageDecoderLib.h>
/** /**
Show LOGO on all consoles. Show LOGO returned from Edkii Platform Logo protocol 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_SUCCESS Logo was displayed.
@retval EFI_UNSUPPORTED Logo was not found or cannot be displayed. @retval EFI_UNSUPPORTED Logo was not found or cannot be displayed.
@ -44,25 +36,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
BootLogoEnableLogo ( BootLogoEnableLogo (
IN IMAGE_FORMAT ImageFormat, VOID
IN EFI_GUID *Logo,
IN EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute,
IN INTN OffsetX,
IN INTN OffsetY
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo; EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo;
EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
INTN OffsetX;
INTN OffsetY;
UINT32 SizeOfX; UINT32 SizeOfX;
UINT32 SizeOfY; UINT32 SizeOfY;
INTN DestX; INTN DestX;
INTN DestY; INTN DestY;
UINT8 *ImageData;
UINTN ImageSize;
UINTN BltSize;
UINT32 Instance; UINT32 Instance;
UINTN Height; EFI_IMAGE_INPUT Image;
UINTN Width;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
EFI_UGA_DRAW_PROTOCOL *UgaDraw; EFI_UGA_DRAW_PROTOCOL *UgaDraw;
UINT32 ColorDepth; UINT32 ColorDepth;
@ -77,10 +64,13 @@ BootLogoEnableLogo (
UINTN LogoWidth; UINTN LogoWidth;
UINTN NewDestX; UINTN NewDestX;
UINTN NewDestY; UINTN NewDestY;
UINTN NewHeight;
UINTN NewWidth;
UINTN BufferSize; UINTN BufferSize;
Status = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
UgaDraw = NULL; UgaDraw = NULL;
// //
// Try to open GOP first // Try to open GOP first
@ -100,15 +90,6 @@ BootLogoEnableLogo (
return EFI_UNSUPPORTED; 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. // Try to open Boot Logo Protocol.
// //
@ -142,25 +123,17 @@ BootLogoEnableLogo (
LogoWidth = 0; LogoWidth = 0;
NewDestX = 0; NewDestX = 0;
NewDestY = 0; NewDestY = 0;
NewHeight = 0;
NewWidth = 0;
Instance = 0; Instance = 0;
DestX = 0; DestX = 0;
DestY = 0; DestY = 0;
while (TRUE) { while (TRUE) {
ImageData = NULL;
ImageSize = 0;
if (PlatformLogo != NULL) {
// //
// Get image from OEMBadging protocol. // Get image from PlatformLogo protocol.
// //
Status = PlatformLogo->GetImage ( Status = PlatformLogo->GetImage (
PlatformLogo, PlatformLogo,
&Instance, &Instance,
&ImageFormat, &Image,
&ImageData,
&ImageSize,
&Attribute, &Attribute,
&OffsetX, &OffsetX,
&OffsetY &OffsetY
@ -169,32 +142,14 @@ BootLogoEnableLogo (
break; break;
} }
} else {
//
// Get the specified image from FV.
//
Status = GetSectionFromAnyFv (Logo, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; continue;
}
} }
if (Blt != NULL) { if (Blt != NULL) {
FreePool (Blt); FreePool (Blt);
} }
Blt = Image.Bitmap;
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;
}
}
// //
// Calculate the display position according to Attribute. // Calculate the display position according to Attribute.
@ -205,42 +160,43 @@ BootLogoEnableLogo (
DestY = 0; DestY = 0;
break; break;
case EdkiiPlatformLogoDisplayAttributeCenterTop: case EdkiiPlatformLogoDisplayAttributeCenterTop:
DestX = (SizeOfX - Width) / 2; DestX = (SizeOfX - Image.Width) / 2;
DestY = 0; DestY = 0;
break; break;
case EdkiiPlatformLogoDisplayAttributeRightTop: case EdkiiPlatformLogoDisplayAttributeRightTop:
DestX = SizeOfX - Width; DestX = SizeOfX - Image.Width;
DestY = 0; DestY = 0;
break; break;
case EdkiiPlatformLogoDisplayAttributeCenterLeft: case EdkiiPlatformLogoDisplayAttributeCenterLeft:
DestX = 0; DestX = 0;
DestY = (SizeOfY - Height) / 2; DestY = (SizeOfY - Image.Height) / 2;
break; break;
case EdkiiPlatformLogoDisplayAttributeCenter: case EdkiiPlatformLogoDisplayAttributeCenter:
DestX = (SizeOfX - Width) / 2; DestX = (SizeOfX - Image.Width) / 2;
DestY = (SizeOfY - Height) / 2; DestY = (SizeOfY - Image.Height) / 2;
break; break;
case EdkiiPlatformLogoDisplayAttributeCenterRight: case EdkiiPlatformLogoDisplayAttributeCenterRight:
DestX = SizeOfX - Width; DestX = SizeOfX - Image.Width;
DestY = (SizeOfY - Height) / 2; DestY = (SizeOfY - Image.Height) / 2;
break; break;
case EdkiiPlatformLogoDisplayAttributeLeftBottom: case EdkiiPlatformLogoDisplayAttributeLeftBottom:
DestX = 0; DestX = 0;
DestY = SizeOfY - Height; DestY = SizeOfY - Image.Height;
break; break;
case EdkiiPlatformLogoDisplayAttributeCenterBottom: case EdkiiPlatformLogoDisplayAttributeCenterBottom:
DestX = (SizeOfX - Width) / 2; DestX = (SizeOfX - Image.Width) / 2;
DestY = SizeOfY - Height; DestY = SizeOfY - Image.Height;
break; break;
case EdkiiPlatformLogoDisplayAttributeRightBottom: case EdkiiPlatformLogoDisplayAttributeRightBottom:
DestX = SizeOfX - Width; DestX = SizeOfX - Image.Width;
DestY = SizeOfY - Height; DestY = SizeOfY - Image.Height;
break; break;
default: default:
ASSERT (FALSE); ASSERT (FALSE);
continue;
break; break;
} }
@ -257,9 +213,9 @@ BootLogoEnableLogo (
0, 0,
(UINTN) DestX, (UINTN) DestX,
(UINTN) DestY, (UINTN) DestY,
Width, Image.Width,
Height, Image.Height,
Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) Image.Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
); );
} else { } else {
ASSERT (UgaDraw != NULL); ASSERT (UgaDraw != NULL);
@ -271,9 +227,9 @@ BootLogoEnableLogo (
0, 0,
(UINTN) DestX, (UINTN) DestX,
(UINTN) DestY, (UINTN) DestY,
Width, Image.Width,
Height, Image.Height,
Width * sizeof (EFI_UGA_PIXEL) Image.Width * sizeof (EFI_UGA_PIXEL)
); );
} }
@ -283,34 +239,28 @@ BootLogoEnableLogo (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
NumberOfLogos++; NumberOfLogos++;
if (LogoWidth == 0) { if (NumberOfLogos == 1) {
// //
// The first Logo. // The first Logo.
// //
LogoDestX = (UINTN) DestX; LogoDestX = (UINTN) DestX;
LogoDestY = (UINTN) DestY; LogoDestY = (UINTN) DestY;
LogoWidth = Width; LogoWidth = Image.Width;
LogoHeight = Height; LogoHeight = Image.Height;
} else { } else {
// //
// Merge new logo with old one. // Merge new logo with old one.
// //
NewDestX = MIN ((UINTN) DestX, LogoDestX); NewDestX = MIN ((UINTN) DestX, LogoDestX);
NewDestY = MIN ((UINTN) DestY, LogoDestY); NewDestY = MIN ((UINTN) DestY, LogoDestY);
NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX; LogoWidth = MAX ((UINTN) DestX + Image.Width, LogoDestX + LogoWidth) - NewDestX;
NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY; LogoHeight = MAX ((UINTN) DestY + Image.Height, LogoDestY + LogoHeight) - NewDestY;
LogoDestX = NewDestX; LogoDestX = NewDestX;
LogoDestY = NewDestY; LogoDestY = NewDestY;
LogoWidth = NewWidth;
LogoHeight = NewHeight;
} }
} }
} }
if (PlatformLogo == NULL) {
break;
}
} }
if (BootLogo == NULL || NumberOfLogos == 0) { if (BootLogo == NULL || NumberOfLogos == 0) {

View File

@ -2,7 +2,7 @@
# This library is only intended to be used by PlatformBootManagerLib # This library is only intended to be used by PlatformBootManagerLib
# to show progress bar and logo. # to show progress bar and logo.
# #
# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials are licensed and made available under # 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 terms and conditions of the BSD License that accompanies this distribution.
# The full text of the license may be found at # The full text of the license may be found at
@ -17,7 +17,7 @@
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = BootLogoLib BASE_NAME = BootLogoLib
MODULE_UNI_FILE = BootLogoLib.uni MODULE_UNI_FILE = BootLogoLib.uni
FILE_GUID = F5AE5B5C-42E8-4A9B-829D-5B631CD5367A FILE_GUID = 85CDAFAD-13BE-422A-A8E5-55A249600DC3
MODULE_TYPE = DXE_DRIVER MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = BootLogoLib|DXE_DRIVER UEFI_APPLICATION LIBRARY_CLASS = BootLogoLib|DXE_DRIVER UEFI_APPLICATION
@ -44,10 +44,6 @@
DebugLib DebugLib
PrintLib PrintLib
PcdLib PcdLib
DxeServicesLib
ImageDecoderLib
[Guids]
[Protocols] [Protocols]
gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES

View File

@ -492,7 +492,7 @@
gEdkiiSmmReadyToBootProtocolGuid = { 0x6e057ecf, 0xfa99, 0x4f39, { 0x95, 0xbc, 0x59, 0xf9, 0x92, 0x1d, 0x17, 0xe4 } } gEdkiiSmmReadyToBootProtocolGuid = { 0x6e057ecf, 0xfa99, 0x4f39, { 0x95, 0xbc, 0x59, 0xf9, 0x92, 0x1d, 0x17, 0xe4 } }
## Include/Protocol/PlatformLogo.h ## 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 ## Include/Protocol/FileExplorer.h
gEfiFileExplorerProtocolGuid = { 0x2C03C536, 0x4594, 0x4515, { 0x9E, 0x7A, 0xD3, 0xD2, 0x04, 0xFE, 0x13, 0x63 } } gEfiFileExplorerProtocolGuid = { 0x2C03C536, 0x4594, 0x4515, { 0x9E, 0x7A, 0xD3, 0xD2, 0x04, 0xFE, 0x13, 0x63 } }