]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
Merged in the following trackers from EDK:
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Image.c
index 341a50a7e8f3303126f0b914e9a3621fdb0727a2..6b6a72002dc2e6b22a71bf7eb0ac987d5c4d91fc 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2007, Intel Corporation\r
+Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. 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
@@ -610,7 +610,7 @@ HiiNewImage (
   UINTN                               NewBlockSize;\r
   EFI_IMAGE_INPUT                     *ImageIn;\r
 \r
-  if (This == NULL || ImageId == NULL || Image == NULL || PackageList == NULL) {\r
+  if (This == NULL || ImageId == NULL || Image == NULL || Image->Bitmap == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -798,10 +798,13 @@ HiiNewImage (
                                  length of the image, in bytes.\r
 \r
   @retval EFI_SUCCESS            The new image was returned successfully.\r
-  @retval EFI_NOT_FOUND          The image specified by ImageId is not available.\r
+  @retval EFI_NOT_FOUND           The image specified by ImageId is not in the\r
+                                                database. The specified PackageList is not in the database.\r
   @retval EFI_BUFFER_TOO_SMALL   The buffer specified by ImageSize is too small to\r
                                  hold the image.\r
   @retval EFI_INVALID_PARAMETER  The Image or ImageSize was NULL.\r
+  @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there was not\r
+                                                     enough memory.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -810,8 +813,7 @@ HiiGetImage (
   IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,\r
   IN  EFI_HII_HANDLE                 PackageList,\r
   IN  EFI_IMAGE_ID                   ImageId,\r
-  OUT EFI_IMAGE_INPUT                *Image,\r
-  OUT UINTN                          *ImageSize\r
+  OUT EFI_IMAGE_INPUT                *Image\r
   )\r
 {\r
   HII_DATABASE_PRIVATE_DATA           *Private;\r
@@ -831,7 +833,7 @@ HiiGetImage (
   UINT8                               PaletteIndex;\r
   UINT16                              PaletteSize;\r
 \r
-  if (This == NULL || ImageSize == NULL || Image == NULL || ImageId < 1 || PackageList == NULL) {\r
+  if (This == NULL || Image == NULL || ImageId < 1) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -897,13 +899,12 @@ HiiGetImage (
     // Use the common block code since the definition of these structures is the same.\r
     //\r
     CopyMem (&Iibt1bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));\r
-    ImageLength = sizeof (EFI_IMAGE_INPUT) + sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *\r
-                  (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height - 1);\r
-    if (*ImageSize < ImageLength) {\r
-      *ImageSize = ImageLength;\r
-      return EFI_BUFFER_TOO_SMALL;\r
+    ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *\r
+                  (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height);\r
+    Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);\r
+    if (Image->Bitmap == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
     }\r
-    ZeroMem (Image, ImageLength);\r
 \r
     if (Flag) {\r
       Image->Flags = EFI_IMAGE_TRANSPARENT;\r
@@ -956,13 +957,11 @@ HiiGetImage (
       ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT16),\r
       sizeof (UINT16)\r
       );\r
-    ImageLength = sizeof (EFI_IMAGE_INPUT) +\r
-                  sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * (Width * Height - 1);\r
-    if (*ImageSize < ImageLength) {\r
-      *ImageSize = ImageLength;\r
-      return EFI_BUFFER_TOO_SMALL;\r
+    ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * (Width * Height);\r
+    Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);\r
+    if (Image->Bitmap == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
     }\r
-    ZeroMem (Image, ImageLength);\r
 \r
     if (Flag) {\r
       Image->Flags = EFI_IMAGE_TRANSPARENT;\r
@@ -999,7 +998,7 @@ HiiGetImage (
 \r
   @retval EFI_SUCCESS            The new image was updated successfully.\r
   @retval EFI_NOT_FOUND          The image specified by ImageId is not in the\r
-                                 database.\r
+                                                database. The specified PackageList is not in the database.    \r
   @retval EFI_INVALID_PARAMETER  The Image was NULL.\r
 \r
 **/\r
@@ -1036,7 +1035,7 @@ HiiSetImage (
   UINT32                               Part1Size;\r
   UINT32                               Part2Size;\r
 \r
-  if (This == NULL || Image == NULL || ImageId < 1 || PackageList == NULL) {\r
+  if (This == NULL || Image == NULL || ImageId < 1 || Image->Bitmap == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1448,9 +1447,9 @@ HiiDrawImage (
 \r
   @retval EFI_SUCCESS            The image was successfully drawn.\r
   @retval EFI_OUT_OF_RESOURCES   Unable to allocate an output buffer for Blt.\r
-  @retval EFI_INVALID_PARAMETER  The Image was NULL.\r
-  @retval EFI_NOT_FOUND          The specified packagelist could not be found in\r
-                                 current database.\r
+  @retval EFI_INVALID_PARAMETER  The Blt was NULL.\r
+  @retval EFI_NOT_FOUND          The image specified by ImageId is not in the database. \r
+                           The specified PackageList is not in the database.                             \r
 \r
 **/\r
 EFI_STATUS\r
@@ -1466,14 +1465,12 @@ HiiDrawImageId (
   )\r
 {\r
   EFI_STATUS                          Status;\r
-  EFI_IMAGE_INPUT                     ImageTemp;\r
-  EFI_IMAGE_INPUT                     *Image;\r
-  UINTN                               ImageSize;\r
+  EFI_IMAGE_INPUT                     Image;\r
 \r
   //\r
   // Check input parameter.\r
   //\r
-  if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {\r
+  if (This == NULL || Blt == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1484,24 +1481,16 @@ HiiDrawImageId (
   //\r
   // Get the specified Image.\r
   //\r
-  ImageSize = 0;\r
-  Status = HiiGetImage (This, PackageList, ImageId, &ImageTemp, &ImageSize);\r
-  if (Status != EFI_BUFFER_TOO_SMALL) {\r
+  Status = HiiGetImage (This, PackageList, ImageId, &Image);\r
+  if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Image = (EFI_IMAGE_INPUT *) AllocateZeroPool (ImageSize);\r
-  if (Image == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  Status = HiiGetImage (This, PackageList, ImageId, Image, &ImageSize);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   //\r
   // Draw this image.\r
   //\r
-  Status = HiiDrawImage (This, Flags, Image, Blt, BltX, BltY);\r
-  SafeFreePool (Image);\r
+  Status = HiiDrawImage (This, Flags, &Image, Blt, BltX, BltY);\r
+  SafeFreePool (Image.Bitmap);\r
   return Status;\r
 }\r
 \r