]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/GraphicsLib/Graphics.c
1.Removed PrintXY from Graphics Library.
[mirror_edk2.git] / MdeModulePkg / Library / GraphicsLib / Graphics.c
index b23026fba0c808028208fcb38dd8057f8383ffe8..63e0696cf4f553fb6873b8dbe28fa96816b70c5f 100644 (file)
@@ -38,25 +38,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DxeServicesLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
-  { 0x00, 0x00, 0x00, 0x00 },\r
-  { 0x98, 0x00, 0x00, 0x00 },\r
-  { 0x00, 0x98, 0x00, 0x00 },\r
-  { 0x98, 0x98, 0x00, 0x00 },\r
-  { 0x00, 0x00, 0x98, 0x00 },\r
-  { 0x98, 0x00, 0x98, 0x00 },\r
-  { 0x00, 0x98, 0x98, 0x00 },\r
-  { 0x98, 0x98, 0x98, 0x00 },\r
-  { 0x10, 0x10, 0x10, 0x00 },\r
-  { 0xff, 0x10, 0x10, 0x00 },\r
-  { 0x10, 0xff, 0x10, 0x00 },\r
-  { 0xff, 0xff, 0x10, 0x00 },\r
-  { 0x10, 0x10, 0xff, 0x00 },\r
-  { 0xf0, 0x10, 0xff, 0x00 },\r
-  { 0x10, 0xff, 0xff, 0x00 },\r
-  { 0xff, 0xff, 0xff, 0x00 }\r
-};\r
-\r
 \r
 /**\r
   Return the graphics image file named FileNameGuid into Image and return it's\r
@@ -636,299 +617,3 @@ DisableQuietBoot (
   return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
 }\r
 \r
-/**\r
-  Internal display string worker function.\r
-\r
-  @param GraphicsOutput   Graphics output protocol interface.\r
-  @param UgaDraw          UGA draw protocol interface.\r
-  @param Sto              Simple text out protocol interface.\r
-  @param X                X coordinate to start printing.\r
-  @param Y                Y coordinate to start printing.\r
-  @param Foreground       Foreground color.\r
-  @param Background       Background color.\r
-  @param fmt              Format string.\r
-  @param args             Print arguments.\r
-\r
-  @return  Number of Characters printed. Zero means no any character \r
-           displayed successfully.\r
-\r
-**/\r
-UINTN\r
-Print (\r
-  IN EFI_GRAPHICS_OUTPUT_PROTOCOL     *GraphicsOutput,\r
-  IN EFI_UGA_DRAW_PROTOCOL            *UgaDraw,\r
-  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *Sto,\r
-  IN UINTN                            X,\r
-  IN UINTN                            Y,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background,\r
-  IN CHAR16                           *fmt,\r
-  IN VA_LIST                          args\r
-  )\r
-{\r
-  VOID                           *Buffer;\r
-  EFI_STATUS                     Status;\r
-  UINTN                          Index;\r
-  CHAR16                         *UnicodeWeight;\r
-  UINT32                         HorizontalResolution;\r
-  UINT32                         VerticalResolution;\r
-  UINT32                         ColorDepth;\r
-  UINT32                         RefreshRate;\r
-  UINTN                          BufferLen;\r
-  UINTN                          LineBufferLen;\r
-  EFI_HII_FONT_PROTOCOL          *HiiFont;\r
-  EFI_IMAGE_OUTPUT               *Blt;\r
-  EFI_FONT_DISPLAY_INFO          *FontInfo;\r
-  EFI_HII_ROW_INFO               *RowInfoArray;\r
-  UINTN                          RowInfoArraySize;\r
-  UINTN                          PrintNum;     \r
-\r
-  //\r
-  // For now, allocate an arbitrarily long buffer\r
-  //\r
-  Buffer = AllocateZeroPool (0x10000);\r
-  if (Buffer == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  HorizontalResolution  = 0;\r
-  VerticalResolution    = 0;\r
-  Blt                   = NULL;\r
-  FontInfo              = NULL;\r
-  PrintNum              = 0;\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-    VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
-  } else {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Error;\r
-  }\r
-\r
-  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
-\r
-  Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-\r
-  PrintNum = UnicodeVSPrint (Buffer, 0x10000, fmt, args);\r
-\r
-  UnicodeWeight = (CHAR16 *) Buffer;\r
-\r
-  for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
-    if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
-        UnicodeWeight[Index] == CHAR_LINEFEED  ||\r
-        UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
-      UnicodeWeight[Index] = 0;\r
-    }\r
-  }\r
-\r
-  BufferLen = StrLen (Buffer);\r
-\r
-  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
-  if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
-     Status = EFI_INVALID_PARAMETER;\r
-     goto Error;\r
-  }\r
-\r
-  Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
-  if (Blt == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-\r
-  Blt->Width        = (UINT16) (HorizontalResolution);\r
-  Blt->Height       = (UINT16) (VerticalResolution);\r
-\r
-  FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
-  if (FontInfo == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-  if (Foreground != NULL) {\r
-    CopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-  } else {\r
-    CopyMem (\r
-      &FontInfo->ForegroundColor,\r
-      &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
-      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-      );\r
-  }\r
-  if (Background != NULL) {\r
-    CopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-  } else {\r
-    CopyMem (\r
-      &FontInfo->BackgroundColor,\r
-      &mEfiColors[Sto->Mode->Attribute >> 4],\r
-      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-      );\r
-  }\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    Blt->Image.Screen = GraphicsOutput;\r
-    \r
-    Status = HiiFont->StringToImage (\r
-                         HiiFont,\r
-                         EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
-                         Buffer,\r
-                         FontInfo,\r
-                         &Blt,\r
-                         X,\r
-                         Y,\r
-                         NULL,\r
-                         NULL,\r
-                         NULL\r
-                         );\r
-\r
-  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    ASSERT (UgaDraw!= NULL);\r
-\r
-    Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-    if (Blt->Image.Bitmap == NULL) {\r
-      FreePool (Blt);\r
-      FreePool (Buffer);\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    RowInfoArray = NULL;\r
-    //\r
-    //  StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
-    //  we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
-    //\r
-    Status = HiiFont->StringToImage (\r
-                         HiiFont,\r
-                         EFI_HII_IGNORE_IF_NO_GLYPH,\r
-                         Buffer,\r
-                         FontInfo,\r
-                         &Blt,\r
-                         X,\r
-                         Y,\r
-                         &RowInfoArray,\r
-                         &RowInfoArraySize,\r
-                         NULL\r
-                         );\r
-\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
-      // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
-      //\r
-      ASSERT (RowInfoArraySize <= 1);\r
-\r
-      Status = UgaDraw->Blt (\r
-                          UgaDraw,\r
-                          (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
-                          EfiUgaBltBufferToVideo,\r
-                          X,\r
-                          Y,\r
-                          X,\r
-                          Y,\r
-                          RowInfoArray[0].LineWidth,\r
-                          RowInfoArray[0].LineHeight,\r
-                          Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                          );\r
-    }\r
-\r
-    if (RowInfoArray != NULL) {\r
-      FreePool (RowInfoArray);\r
-    }\r
-    if (Blt->Image.Bitmap != NULL) {\r
-      FreePool (Blt->Image.Bitmap);\r
-    }\r
-  } else {\r
-    Status = EFI_UNSUPPORTED;\r
-  }\r
-\r
-Error:\r
-  if (Blt != NULL) {\r
-    FreePool (Blt);\r
-  }\r
-  if (FontInfo != NULL) { \r
-    FreePool (FontInfo);\r
-  }\r
-  FreePool (Buffer);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return PrintNum;\r
-  } else {\r
-    return 0;\r
-  }\r
-}\r
-\r
-/**\r
-  Print Unicode string to graphics screen at the given X,Y coordinates of the graphics screen.\r
-  see definition of Print to find rules for constructing Fmt.\r
-\r
-  @param  X            Row to start printing at.\r
-  @param  Y            Column to start printing at.\r
-  @param  ForeGround   Foreground color.\r
-  @param  BackGround   background color.\r
-  @param  Fmt          Print format sting. See definition of Print.\r
-  @param ...           Variable argument list whose contents are accessed based on \r
-                       the format string specified by Format.\r
-\r
-  @return  Number of Characters printed. Zero means no any character \r
-           displayed successfully.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-PrintXY (\r
-  IN UINTN                            X,\r
-  IN UINTN                            Y,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
-  IN CHAR16                           *Fmt,\r
-  ...\r
-  )\r
-{\r
-  EFI_HANDLE                       Handle;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL     *GraphicsOutput;\r
-  EFI_UGA_DRAW_PROTOCOL            *UgaDraw;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *Sto;\r
-  EFI_STATUS                       Status;\r
-  VA_LIST                          Args;\r
-\r
-  VA_START (Args, Fmt);\r
-\r
-  Handle = gST->ConsoleOutHandle;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &GraphicsOutput\r
-                  );\r
-\r
-  UgaDraw = NULL;\r
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    //\r
-    // If no GOP available, try to open UGA Draw protocol if supported.\r
-    //\r
-    GraphicsOutput = NULL;\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    Handle,\r
-                    &gEfiUgaDrawProtocolGuid,\r
-                    (VOID **) &UgaDraw\r
-                    );\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID **) &Sto\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  }\r
-\r
-  return Print (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
-}\r
-\r