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
This commit is contained in:
eric_tian 2009-05-21 10:02:33 +00:00
parent 4772ce75e8
commit d9e63d93d5
2 changed files with 48 additions and 50 deletions

View File

@ -1078,9 +1078,11 @@ AsciiErrorPrint (
by the right edge of the display. If the length of the formatted Unicode string is by the right edge of the display. If the length of the formatted Unicode string is
greater than PcdUefiLibMaxPrintBufferSize, then at most the first greater than PcdUefiLibMaxPrintBufferSize, then at most the first
PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
is used to convert the string to a bitmap using the glyphs registered with the StringToImage() service is used to convert the string to a bitmap using the glyphs
HII database. No wrapping is performed, so any portions of the string the fall registered with the HII database. No wrapping is performed, so any portions of the
outside the active display region will not be displayed. 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 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. defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
@ -1128,9 +1130,11 @@ PrintXY (
by the right edge of the display. If the length of the formatted ASCII string is by the right edge of the display. If the length of the formatted ASCII string is
greater than PcdUefiLibMaxPrintBufferSize, then at most the first greater than PcdUefiLibMaxPrintBufferSize, then at most the first
PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
is used to convert the string to a bitmap using the glyphs registered with the StringToImage() service is used to convert the string to a bitmap using the glyphs
HII database. No wrapping is performed, so any portions of the string the fall registered with the HII database. No wrapping is performed, so any portions of the
outside the active display region will not be displayed. 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 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. defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.

View File

@ -2,7 +2,7 @@
Mde UEFI library API implementation. Mde UEFI library API implementation.
Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
Copyright (c) 2007 - 2008, Intel Corporation<BR> Copyright (c) 2007 - 2009, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -334,13 +334,10 @@ InternalPrintGraphic (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Index;
CHAR16 *UnicodeWeight;
UINT32 HorizontalResolution; UINT32 HorizontalResolution;
UINT32 VerticalResolution; UINT32 VerticalResolution;
UINT32 ColorDepth; UINT32 ColorDepth;
UINT32 RefreshRate; UINT32 RefreshRate;
UINTN LineBufferLen;
EFI_HII_FONT_PROTOCOL *HiiFont; EFI_HII_FONT_PROTOCOL *HiiFont;
EFI_IMAGE_OUTPUT *Blt; EFI_IMAGE_OUTPUT *Blt;
EFI_FONT_DISPLAY_INFO FontInfo; EFI_FONT_DISPLAY_INFO FontInfo;
@ -354,6 +351,7 @@ InternalPrintGraphic (
HorizontalResolution = 0; HorizontalResolution = 0;
VerticalResolution = 0; VerticalResolution = 0;
Blt = NULL; Blt = NULL;
RowInfoArray = NULL;
ConsoleHandle = gST->ConsoleOutHandle; ConsoleHandle = gST->ConsoleOutHandle;
@ -377,7 +375,7 @@ InternalPrintGraphic (
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return 0; goto Error;
} }
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
@ -387,7 +385,7 @@ InternalPrintGraphic (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return 0; goto Error;
} }
if (GraphicsOutput != NULL) { if (GraphicsOutput != NULL) {
@ -396,7 +394,6 @@ InternalPrintGraphic (
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) { } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
} else { } else {
Status = EFI_UNSUPPORTED;
goto Error; goto Error;
} }
@ -407,21 +404,6 @@ InternalPrintGraphic (
goto Error; 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)); Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
ASSERT (Blt != NULL); ASSERT (Blt != NULL);
@ -454,16 +436,21 @@ InternalPrintGraphic (
Status = HiiFont->StringToImage ( Status = HiiFont->StringToImage (
HiiFont, 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, Buffer,
&FontInfo, &FontInfo,
&Blt, &Blt,
PointX, PointX,
PointY, PointY,
NULL, &RowInfoArray,
NULL, &RowInfoArraySize,
NULL NULL
); );
if (EFI_ERROR (Status)) {
goto Error;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) { } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
ASSERT (UgaDraw!= NULL); ASSERT (UgaDraw!= NULL);
@ -471,7 +458,6 @@ InternalPrintGraphic (
Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
ASSERT (Blt->Image.Bitmap != NULL); 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, // 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. // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
@ -509,23 +495,27 @@ InternalPrintGraphic (
RowInfoArray[0].LineHeight, RowInfoArray[0].LineHeight,
Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
); );
} else {
goto Error;
} }
FreePool (Blt->Image.Bitmap);
} else {
goto Error;
}
//
// Calculate the number of actual printed characters
//
PrintNum = RowInfoArray[0].EndIndex - RowInfoArray[0].StartIndex + 1;
FreePool (RowInfoArray); FreePool (RowInfoArray);
FreePool (Blt->Image.Bitmap);
} else {
Status = EFI_UNSUPPORTED;
}
FreePool (Blt); FreePool (Blt);
return PrintNum;
Error: Error:
if (EFI_ERROR (Status)) { if (Blt != NULL) {
return 0; FreePool (Blt);
} else {
return PrintNum;
} }
return 0;
} }
/** /**
@ -538,9 +528,11 @@ Error:
by the right edge of the display. If the length of the formatted Unicode string is by the right edge of the display. If the length of the formatted Unicode string is
greater than PcdUefiLibMaxPrintBufferSize, then at most the first greater than PcdUefiLibMaxPrintBufferSize, then at most the first
PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
is used to convert the string to a bitmap using the glyphs registered with the StringToImage() service is used to convert the string to a bitmap using the glyphs
HII database. No wrapping is performed, so any portions of the string the fall registered with the HII database. No wrapping is performed, so any portions of the
outside the active display region will not be displayed. 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 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. defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.
@ -613,9 +605,11 @@ PrintXY (
by the right edge of the display. If the length of the formatted ASCII string is by the right edge of the display. If the length of the formatted ASCII string is
greater than PcdUefiLibMaxPrintBufferSize, then at most the first greater than PcdUefiLibMaxPrintBufferSize, then at most the first
PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL
is used to convert the string to a bitmap using the glyphs registered with the StringToImage() service is used to convert the string to a bitmap using the glyphs
HII database. No wrapping is performed, so any portions of the string the fall registered with the HII database. No wrapping is performed, so any portions of the
outside the active display region will not be displayed. 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 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. defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.