]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen
authorMichael D Kinney <michael.d.kinney@intel.com>
Wed, 21 Mar 2018 20:21:10 +0000 (13:21 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Thu, 22 Mar 2018 03:55:27 +0000 (20:55 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=907

When -G option is used to convert a BMP file to a UX capsule,
the bitmap is centered horizontally and placed in the lower
half of the screen below the boot logo.

This matches examples shown in the following pages:

https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/user-experience-for-uefi-firmware-updates
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/boot-screen-components

Checks are also made to make sure the bitmap provided
fits in the current GOP mode.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf

index b9ff812179aaeb8579967cf97e9aac6d6cf7da48..e1e48befc2de8895142af8d1cd9a0b95c0d358eb 100644 (file)
@@ -21,6 +21,7 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/BmpSupportLib.h>\r
 #include <Protocol/GraphicsOutput.h>\r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/CapsuleReport.h>\r
@@ -173,15 +174,21 @@ CreateBmpFmp (
   EFI_DISPLAY_CAPSULE                           *DisplayCapsule;\r
   EFI_STATUS                                    Status;\r
   EFI_GRAPHICS_OUTPUT_PROTOCOL                  *Gop;\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION          *Info;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL                 *GopBlt;\r
+  UINTN                                         GopBltSize;\r
+  UINTN                                         Height;\r
+  UINTN                                         Width;\r
 \r
   Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);\r
   if (EFI_ERROR(Status)) {\r
     Print(L"CapsuleApp: NO GOP is found.\n");\r
     return EFI_UNSUPPORTED;\r
   }\r
+  Info = Gop->Mode->Info;\r
   Print(L"Current GOP: Mode - %d, ", Gop->Mode->Mode);\r
-  Print(L"HorizontalResolution - %d, ", Gop->Mode->Info->HorizontalResolution);\r
-  Print(L"VerticalResolution - %d\n", Gop->Mode->Info->VerticalResolution);\r
+  Print(L"HorizontalResolution - %d, ", Info->HorizontalResolution);\r
+  Print(L"VerticalResolution - %d\n", Info->VerticalResolution);\r
   // HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth\r
   // VerticalResolution   >= BMP_IMAGE_HEADER.PixelHeight\r
 \r
@@ -207,6 +214,35 @@ CreateBmpFmp (
     goto Done;\r
   }\r
 \r
+  GopBlt = NULL;\r
+  Status = TranslateBmpToGopBlt (\r
+             BmpBuffer,\r
+             FileSize,\r
+             &GopBlt,\r
+             &GopBltSize,\r
+             &Height,\r
+             &Width\r
+             );\r
+  if (EFI_ERROR(Status)) {\r
+    Print(L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName);\r
+    goto Done;\r
+  }\r
+  if (GopBlt != NULL) {\r
+    FreePool (GopBlt);\r
+  }\r
+  Print(L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, Height);\r
+\r
+  if (Height > Info->VerticalResolution) {\r
+    Status = EFI_INVALID_PARAMETER;\r
+    Print(L"CapsuleApp: BMP image (%s) height is larger than current resolution.\n", BmpName);\r
+    goto Done;\r
+  }\r
+  if (Width > Info->HorizontalResolution) {\r
+    Status = EFI_INVALID_PARAMETER;\r
+    Print(L"CapsuleApp: BMP image (%s) width is larger than current resolution.\n", BmpName);\r
+    goto Done;\r
+  }\r
+\r
   FullCapsuleBufferSize = sizeof(EFI_DISPLAY_CAPSULE) + FileSize;\r
   FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);\r
   if (FullCapsuleBuffer == NULL) {\r
@@ -226,8 +262,27 @@ CreateBmpFmp (
   DisplayCapsule->ImagePayload.ImageType = 0; // BMP\r
   DisplayCapsule->ImagePayload.Reserved = 0;\r
   DisplayCapsule->ImagePayload.Mode = Gop->Mode->Mode;\r
-  DisplayCapsule->ImagePayload.OffsetX = 0;\r
-  DisplayCapsule->ImagePayload.OffsetY = 0;\r
+\r
+  //\r
+  // Center the bitmap horizontally\r
+  //\r
+  DisplayCapsule->ImagePayload.OffsetX = (UINT32)((Info->HorizontalResolution - Width) / 2);\r
+\r
+  //\r
+  // Put bitmap 3/4 down the display.  If bitmap is too tall, then align bottom\r
+  // of bitmap at bottom of display.\r
+  //\r
+  DisplayCapsule->ImagePayload.OffsetY =\r
+    MIN (\r
+      (UINT32)(Info->VerticalResolution - Height),\r
+      (UINT32)(((3 * Info->VerticalResolution) - (2 * Height)) / 4)\r
+      );\r
+\r
+  Print(L"BMP image (%s), OffsetX - %d, OffsetY - %d\n",\r
+    BmpName,\r
+    DisplayCapsule->ImagePayload.OffsetX,\r
+    DisplayCapsule->ImagePayload.OffsetY\r
+    );\r
 \r
   CopyMem((DisplayCapsule + 1), BmpBuffer, FileSize);\r
 \r
index b06c4ea1bc8813af9c5122f4ce506bcd330b2db0..3a67c6b9099a0af1ec1f1eb43c1a0c7f45528b90 100644 (file)
@@ -4,7 +4,7 @@
 # This application can trigger capsule update process. It can also\r
 # generate capsule image, or dump capsule variable information.\r
 #\r
-#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
@@ -63,6 +63,7 @@
   UefiRuntimeServicesTableLib\r
   UefiLib\r
   PrintLib\r
+  BmpSupportLib\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   CapsuleAppExtra.uni\r