From d9e63d93d583c31a3c4eb20b9b392f241f4c8a29 Mon Sep 17 00:00:00 2001 From: eric_tian Date: Thu, 21 May 2009 10:02:33 +0000 Subject: update the file description of PrintXY and AsciiPrintXY. and also refine the implementation to return the number of actual printed characters. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8372 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/UefiLib/UefiLibPrint.c | 78 ++++++++++++++++------------------- 1 file changed, 36 insertions(+), 42 deletions(-) (limited to 'MdePkg/Library/UefiLib') diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c index fc68e6659a..9c80d01a55 100644 --- a/MdePkg/Library/UefiLib/UefiLibPrint.c +++ b/MdePkg/Library/UefiLib/UefiLibPrint.c @@ -2,7 +2,7 @@ Mde UEFI library API implementation. Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE - Copyright (c) 2007 - 2008, Intel Corporation
+ Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -334,13 +334,10 @@ InternalPrintGraphic ( ) { EFI_STATUS Status; - UINTN Index; - CHAR16 *UnicodeWeight; UINT32 HorizontalResolution; UINT32 VerticalResolution; UINT32 ColorDepth; UINT32 RefreshRate; - UINTN LineBufferLen; EFI_HII_FONT_PROTOCOL *HiiFont; EFI_IMAGE_OUTPUT *Blt; EFI_FONT_DISPLAY_INFO FontInfo; @@ -354,6 +351,7 @@ InternalPrintGraphic ( HorizontalResolution = 0; VerticalResolution = 0; Blt = NULL; + RowInfoArray = NULL; ConsoleHandle = gST->ConsoleOutHandle; @@ -377,7 +375,7 @@ InternalPrintGraphic ( ); } if (EFI_ERROR (Status)) { - return 0; + goto Error; } Status = gBS->HandleProtocol ( @@ -387,7 +385,7 @@ InternalPrintGraphic ( ); if (EFI_ERROR (Status)) { - return 0; + goto Error; } if (GraphicsOutput != NULL) { @@ -396,7 +394,6 @@ InternalPrintGraphic ( } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); } else { - Status = EFI_UNSUPPORTED; goto Error; } @@ -407,21 +404,6 @@ InternalPrintGraphic ( goto Error; } - UnicodeWeight = Buffer; - - for (Index = 0; UnicodeWeight[Index] != 0; Index++) { - if (UnicodeWeight[Index] == CHAR_BACKSPACE || - UnicodeWeight[Index] == CHAR_LINEFEED || - UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) { - UnicodeWeight[Index] = 0; - } - } - - LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT; - if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * PrintNum > LineBufferLen) { - PrintNum = HorizontalResolution / EFI_GLYPH_WIDTH; - } - Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT)); ASSERT (Blt != NULL); @@ -454,16 +436,21 @@ InternalPrintGraphic ( Status = HiiFont->StringToImage ( HiiFont, - EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN, + EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP | + EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y | + EFI_HII_IGNORE_LINE_BREAK | EFI_HII_DIRECT_TO_SCREEN, Buffer, &FontInfo, &Blt, PointX, PointY, - NULL, - NULL, + &RowInfoArray, + &RowInfoArraySize, NULL ); + if (EFI_ERROR (Status)) { + goto Error; + } } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { ASSERT (UgaDraw!= NULL); @@ -471,7 +458,6 @@ InternalPrintGraphic ( Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); ASSERT (Blt->Image.Bitmap != NULL); - RowInfoArray = NULL; // // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform, // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw. @@ -509,23 +495,27 @@ InternalPrintGraphic ( RowInfoArray[0].LineHeight, Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) ); + } else { + goto Error; } - - FreePool (RowInfoArray); FreePool (Blt->Image.Bitmap); - } else { - Status = EFI_UNSUPPORTED; + goto Error; } + // + // Calculate the number of actual printed characters + // + PrintNum = RowInfoArray[0].EndIndex - RowInfoArray[0].StartIndex + 1; + FreePool (RowInfoArray); FreePool (Blt); + return PrintNum; Error: - if (EFI_ERROR (Status)) { - return 0; - } else { - return PrintNum; + if (Blt != NULL) { + FreePool (Blt); } + return 0; } /** @@ -537,10 +527,12 @@ Error: Unicode characters displayed, not including partial characters that may be clipped by the right edge of the display. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, then at most the first - PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL - is used to convert the string to a bitmap using the glyphs registered with the - HII database. No wrapping is performed, so any portions of the string the fall - outside the active display region will not be displayed. + PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL + StringToImage() service is used to convert the string to a bitmap using the glyphs + registered with the HII database. No wrapping is performed, so any portions of the + string the fall outside the active display region will not be displayed. Please see + Section 27.2.6 of the UEFI Specification for a description of the supported string + format including the set of control codes supported by the StringToImage() service. If a graphics console device is not associated with the ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned. @@ -612,10 +604,12 @@ PrintXY ( ASCII characters displayed, not including partial characters that may be clipped by the right edge of the display. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then at most the first - PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL - is used to convert the string to a bitmap using the glyphs registered with the - HII database. No wrapping is performed, so any portions of the string the fall - outside the active display region will not be displayed. + PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL + StringToImage() service is used to convert the string to a bitmap using the glyphs + registered with the HII database. No wrapping is performed, so any portions of the + string the fall outside the active display region will not be displayed. Please see + Section 27.2.6 of the UEFI Specification for a description of the supported string + format including the set of control codes supported by the StringToImage() service. If a graphics console device is not associated with the ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned. -- cgit v1.2.3