1.Removed PrintXY from Graphics Library.

2.Added PrintXY and AsciiPrintXY in Uefi Library
3.Moved PcdUgaConsumeSupport from MdeModulePkg to MdePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6642 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2008-11-20 03:08:28 +00:00
parent b10a05d6c3
commit b31547205f
13 changed files with 522 additions and 362 deletions

View File

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