]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Font.c
index 9c68ac89b64d95640e84c6ec8b3beb92de70be46..06b09e7f7625185baedfb912bad3987f26c85c70 100644 (file)
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "HiiDatabase.h"\r
 \r
-STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {\r
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {\r
   //\r
   // B     G     R\r
   //\r
@@ -1024,7 +1024,9 @@ IsSystemFontInfo (
 \r
 Exit:\r
   if (SystemInfo == NULL) {\r
-    SafeFreePool (SystemDefault);    \r
+    if (SystemDefault != NULL) {\r
+      FreePool (SystemDefault);\r
+    }\r
   }\r
   return Flag;\r
 }\r
@@ -1646,7 +1648,9 @@ HiiStringToImage (
     Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);\r
     if (Status == EFI_NOT_FOUND) {\r
       if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {\r
-        SafeFreePool (GlyphBuf[Index]);\r
+        if (GlyphBuf[Index] != NULL) {\r
+          FreePool (GlyphBuf[Index]);\r
+        }\r
         GlyphBuf[Index] = NULL;\r
         StringPtr++;\r
       } else {\r
@@ -1730,7 +1734,6 @@ HiiStringToImage (
         if (LineHeight < Cell[Index].Height) {\r
           LineHeight = (UINTN) Cell[Index].Height;\r
         }\r
-        BaseLineOffset += (UINTN) Cell[Index].OffsetY;\r
 \r
         if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&\r
             (Flags & EFI_HII_OUT_FLAG_WRAP) == 0 &&\r
@@ -1799,7 +1802,7 @@ HiiStringToImage (
         if (Index > 0) {\r
           RowInfo[RowIndex].EndIndex       = Index - 1;\r
           RowInfo[RowIndex].LineWidth      = LineWidth - Cell[Index].AdvanceX;\r
-          RowInfo[RowIndex].BaselineOffset = BaseLineOffset - Cell[Index].OffsetY;\r
+          RowInfo[RowIndex].BaselineOffset = BaseLineOffset;\r
           if (LineHeight > Cell[Index - 1].Height) {\r
             LineHeight = Cell[Index - 1].Height;\r
           }\r
@@ -1872,11 +1875,11 @@ HiiStringToImage (
                                         0\r
                                         );\r
         if (EFI_ERROR (Status)) {\r
-          SafeFreePool (BltBuffer);\r
+          FreePool (BltBuffer);\r
           goto Exit;\r
         }\r
 \r
-        SafeFreePool (BltBuffer);\r
+        FreePool (BltBuffer);\r
 \r
       } else {\r
         for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
@@ -1939,7 +1942,7 @@ HiiStringToImage (
     Image->Height = 600;\r
     Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height *sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
     if (Image->Image.Bitmap == NULL) {\r
-      SafeFreePool (Image);\r
+      FreePool (Image);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -1971,16 +1974,34 @@ HiiStringToImage (
 Exit:\r
 \r
   for (Index = 0; Index < MAX_STRING_LENGTH; Index++) {\r
-    SafeFreePool (GlyphBuf[Index]);\r
+    if (GlyphBuf[Index] != NULL) {\r
+      FreePool (GlyphBuf[Index]);\r
+    }\r
+  }\r
+  if (StringIn != NULL) {\r
+    FreePool (StringIn);\r
+  }\r
+  if (StringIn2 != NULL) {\r
+    FreePool (StringIn2);\r
+  }\r
+  if (StringInfoOut != NULL) {\r
+    FreePool (StringInfoOut);\r
+  }\r
+  if (RowInfo != NULL) {\r
+    FreePool (RowInfo);\r
+  }\r
+  if (SystemDefault != NULL) {\r
+    FreePool (SystemDefault);\r
+  }\r
+  if (GlyphBuf != NULL) {\r
+    FreePool (GlyphBuf);\r
+  }\r
+  if (Cell != NULL) {\r
+    FreePool (Cell);\r
+  }\r
+  if (Attributes != NULL) {\r
+    FreePool (Attributes);\r
   }\r
-  SafeFreePool (StringIn);\r
-  SafeFreePool (StringIn2);\r
-  SafeFreePool (StringInfoOut);\r
-  SafeFreePool (RowInfo);\r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (GlyphBuf);\r
-  SafeFreePool (Cell);\r
-  SafeFreePool (Attributes);\r
 \r
   return Status;\r
 }\r
@@ -2087,7 +2108,7 @@ HiiStringIdToImage (
   if (Language != NULL) {\r
     AsciiStrCpy (CurrentLang, (CHAR8 *) Language);\r
   } else {\r
-    HiiLibGetCurrentLanguage (CurrentLang);\r
+    GetCurrentLanguage (CurrentLang);\r
   }\r
 \r
   //\r
@@ -2114,7 +2135,7 @@ HiiStringIdToImage (
                                 &StringFontInfo\r
                                 );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    SafeFreePool (String);\r
+    FreePool (String);\r
     String = (EFI_STRING) AllocateZeroPool (StringSize);\r
     if (String == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -2181,9 +2202,15 @@ HiiStringIdToImage (
            );\r
 \r
 Exit:\r
-  SafeFreePool (String);\r
-  SafeFreePool (StringFontInfo);\r
-  SafeFreePool (NewStringInfo);\r
+  if (String != NULL) {\r
+    FreePool (String);\r
+  }\r
+  if (StringFontInfo != NULL) {\r
+    FreePool (StringFontInfo);\r
+  }\r
+  if (NewStringInfo != NULL) {\r
+    FreePool (NewStringInfo);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -2297,7 +2324,7 @@ HiiGetGlyph (
 \r
   Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
   if (Image->Image.Bitmap == NULL) {\r
-    SafeFreePool (Image);\r
+    FreePool (Image);\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
   }\r
@@ -2338,10 +2365,18 @@ Exit:
     }\r
   }\r
 \r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (StringInfoOut);\r
-  SafeFreePool (String);\r
-  SafeFreePool (GlyphBuffer);\r
+  if (SystemDefault != NULL) {\r
+   FreePool (SystemDefault);\r
+  }\r
+  if (StringInfoOut != NULL) {\r
+    FreePool (StringInfoOut);\r
+  }\r
+  if (String != NULL) {\r
+    FreePool (String);\r
+  }\r
+  if (GlyphBuffer != NULL) {\r
+    FreePool (GlyphBuffer);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -2497,10 +2532,10 @@ HiiGetFontInfo (
   FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;\r
 \r
   if (IsFontInfoExisted (Private, FontInfo, &InfoOut.FontInfoMask, LocalFontHandle, &GlobalFont)) {\r
+    //\r
+    // Test to guarantee all characters are available in the found font.\r
+    //    \r
     if (String != NULL) {\r
-      //\r
-      // Test to guarantee all characters are available in the found font.\r
-      //\r
       StringIn = String;\r
       while (*StringIn != 0) {\r
         Status = FindGlyphBlock (GlobalFont->FontPackage, *StringIn, NULL, NULL, NULL);\r
@@ -2510,29 +2545,27 @@ HiiGetFontInfo (
         }\r
         StringIn++;\r
       }\r
-\r
-      //\r
-      // Write to output parameter\r
-      //\r
-      if (StringInfoOut != NULL) {\r
-        StringInfoOutLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (EFI_FONT_INFO) + GlobalFont->FontInfoSize;\r
-        *StringInfoOut   = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (StringInfoOutLen);\r
-        if (*StringInfoOut == NULL) {\r
-          Status = EFI_OUT_OF_RESOURCES;\r
-          LocalFontHandle = NULL;\r
-          goto Exit;\r
-        }\r
-        CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));\r
-        CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);\r
+    }\r
+    //\r
+    // Write to output parameter\r
+    //\r
+    if (StringInfoOut != NULL) {\r
+      StringInfoOutLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (EFI_FONT_INFO) + GlobalFont->FontInfoSize;\r
+      *StringInfoOut   = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (StringInfoOutLen);      \r
+      if (*StringInfoOut == NULL) {\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        LocalFontHandle = NULL;\r
+        goto Exit;\r
       }\r
-      LocalFontHandle = GlobalFont->Entry.ForwardLink;\r
-\r
-      Status = EFI_SUCCESS;\r
-      goto Exit;\r
+      \r
+      CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));\r
+      CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);\r
     }\r
-  } else {\r
-    LocalFontHandle = NULL;\r
-  }\r
+    \r
+    LocalFontHandle = GlobalFont->Entry.ForwardLink;    \r
+    Status = EFI_SUCCESS;\r
+    goto Exit;\r
+  }  \r
 \r
   Status = EFI_NOT_FOUND;\r
 \r
@@ -2542,8 +2575,12 @@ Exit:
     *FontHandle = LocalFontHandle;\r
   }\r
 \r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (FontInfo);\r
+  if (SystemDefault != NULL) {\r
+   FreePool (SystemDefault);\r
+  }\r
+  if (FontInfo != NULL) {\r
+   FreePool (FontInfo);\r
+  }\r
   return Status;\r
 }\r
 \r