Merged in the following trackers from EDK:

EDK1145 Cursor mising in shell in some case 
EDK1099: Dell - [HII] HiiGetFontInfo() not retrieve the system font by FoFontInfoMask
EDK1127: [UEFI 2.10] Keyboard layout support 
EDK1129: [UEFI HII] GUID is represented wrongly in Config String
And some other fixes such as
*[UEFI HII] HiiGetAltCfg is generating "Name=" sub string in the wrong format 
*UEFI HII: GetUnicodeStringTextOrSize() doesn't handle NULL StringDest properly
*GetFontInfo() need be updated to avoid iteration 
*HIIStringProtocolTest failed on multiple platform
*[Uefi 2.1] Comply with latest Hii ECR 
* GetFontInfo() need be updated to avoid iteration


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5361 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12
2008-06-23 09:41:33 +00:00
parent 54cf87805f
commit 813acf3a9a
18 changed files with 1425 additions and 693 deletions

View File

@@ -905,15 +905,14 @@ GetSystemFont (
/**
Check whether EFI_FONT_DISPLAY_INFO points to system default font and color.
Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
returns the system default according to the optional inputs.
@param Private HII database driver private data.
@param StringInfo Points to the string output information,
including the color and font.
@param SystemInfo If not NULL, points to system default font and
color when incoming StringInfo does not match the
default. Points to NULL if matches. It's
caller's reponsibility to free this buffer.
@param SystemInfo If not NULL, points to system default font and color.
@param SystemInfoLen If not NULL, output the length of default system
info.
@@ -933,6 +932,7 @@ IsSystemFontInfo (
EFI_STATUS Status;
EFI_FONT_DISPLAY_INFO *SystemDefault;
UINTN DefaultLen;
BOOLEAN Flag;
ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);
@@ -940,28 +940,69 @@ IsSystemFontInfo (
return TRUE;
}
//
// Check whether incoming string font and color matches system default.
//
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);
ASSERT_EFI_ERROR (Status);
//
// Record the system default info.
//
if (SystemInfo != NULL) {
*SystemInfo = SystemDefault;
} else {
SafeFreePool (SystemDefault);
}
if (SystemInfoLen != NULL) {
*SystemInfoLen = DefaultLen;
}
if (StringInfo == NULL ||
(StringInfo != NULL && CompareMem (SystemDefault, StringInfo, DefaultLen) == 0)) {
if (StringInfo == NULL) {
return TRUE;
}
return FALSE;
Flag = FALSE;
//
// Check the FontInfoMask to see whether it is retrieving system info.
//
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) == 0) {
if (StrCmp (StringInfo->FontInfo.FontName, SystemDefault->FontInfo.FontName) != 0) {
goto Exit;
}
}
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) == 0) {
if (StringInfo->FontInfo.FontSize != SystemDefault->FontInfo.FontSize) {
goto Exit;
}
}
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) == 0) {
if (StringInfo->FontInfo.FontStyle != SystemDefault->FontInfo.FontStyle) {
goto Exit;
}
}
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == 0) {
if (CompareMem (
&StringInfo->ForegroundColor,
&SystemDefault->ForegroundColor,
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
) != 0) {
goto Exit;
}
}
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == 0) {
if (CompareMem (
&StringInfo->BackgroundColor,
&SystemDefault->BackgroundColor,
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
) != 0) {
goto Exit;
}
}
Flag = TRUE;
Exit:
if (SystemInfo == NULL) {
SafeFreePool (SystemDefault);
}
return Flag;
}
@@ -1400,6 +1441,7 @@ IsLineBreak (
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
@retval EFI_INVALID_PARAMETER The String or Blt was NULL.
@retval EFI_INVALID_PARAMETER Flags were invalid combination..
**/
EFI_STATUS
@@ -1470,16 +1512,16 @@ HiiStringToImage (
//
// These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
//
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_X)) == EFI_HII_OUT_FLAG_CLEAN_X) {
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X) {
return EFI_INVALID_PARAMETER;
}
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLEAN_Y) {
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
return EFI_INVALID_PARAMETER;
}
//
// This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
//
if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) {
if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) {
return EFI_INVALID_PARAMETER;
}
@@ -1633,7 +1675,7 @@ HiiStringToImage (
//
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);
if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {
if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
//
// Don't draw at all if there is only one row and
// the row's bottom-most on pixel cannot fit.
@@ -1705,7 +1747,7 @@ HiiStringToImage (
//
if (!LineBreak) {
Flags &= (~ (EFI_HII_OUT_FLAGS) EFI_HII_OUT_FLAG_WRAP);
Flags |= EFI_HII_OUT_FLAG_CLEAN_X;
Flags |= EFI_HII_OUT_FLAG_CLIP_CLEAN_X;
}
}
@@ -1713,7 +1755,7 @@ HiiStringToImage (
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
//
if (LineWidth + BltX <= Image->Width ||
(LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLEAN_X) == 0)) {
(LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_X) == 0)) {
//
// Record right-most character in RowInfo even if it is partially displayed.
//
@@ -1749,7 +1791,7 @@ HiiStringToImage (
//
if (RowIndex == MaxRowNum - 1 && Image->Height < LineHeight) {
LineHeight = Image->Height;
if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {
if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
//
// Don't draw at all if the row's bottom-most on pixel cannot fit.
//
@@ -1968,7 +2010,10 @@ Exit:
@retval EFI_SUCCESS The string was successfully rendered.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
@retval EFI_INVALID_PARAMETER The PackageList was NULL.
@retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
@retval EFI_INVALID_PARAMETER Flags were invalid combination.
@retval EFI_NOT_FOUND The specified PackageList is not in the Database or the stringid is not
in the specified PackageList.
**/
EFI_STATUS
@@ -1992,6 +2037,10 @@ HiiStringIdToImage (
HII_DATABASE_PRIVATE_DATA *Private;
EFI_STRING String;
UINTN StringSize;
UINTN FontLen;
EFI_FONT_INFO *StringFontInfo;
EFI_FONT_DISPLAY_INFO *NewStringInfo;
CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2001,7 +2050,14 @@ HiiStringIdToImage (
return EFI_NOT_FOUND;
}
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
//
// When Language points to NULL, current system language is used.
//
if (Language != NULL) {
AsciiStrCpy (CurrentLang, (CHAR8 *) Language);
} else {
HiiLibGetCurrentLanguage (CurrentLang);
}
//
// Get the string to be displayed.
@@ -2013,14 +2069,18 @@ HiiStringIdToImage (
return EFI_OUT_OF_RESOURCES;
}
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
StringFontInfo = NULL;
NewStringInfo = NULL;
Status = Private->HiiString.GetString (
&Private->HiiString,
Language,
CurrentLang,
PackageList,
StringId,
String,
&StringSize,
NULL
&StringFontInfo
);
if (Status == EFI_BUFFER_TOO_SMALL) {
SafeFreePool (String);
@@ -2041,11 +2101,42 @@ HiiStringIdToImage (
}
if (EFI_ERROR (Status)) {
SafeFreePool (String);
return Status;
goto Exit;
}
//
// When StringInfo specifies that string will be output in the system default font and color,
// use particular stringfontinfo described in string package instead if exists.
// StringFontInfo equals NULL means system default font attaches with the string block.
//
if (StringFontInfo != NULL && IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, NULL, NULL)) {
FontLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + StrSize (StringFontInfo->FontName);
NewStringInfo = AllocateZeroPool (FontLen);
if (NewStringInfo == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
NewStringInfo->FontInfoMask = EFI_FONT_INFO_SYS_FORE_COLOR | EFI_FONT_INFO_SYS_BACK_COLOR;
NewStringInfo->FontInfo.FontStyle = StringFontInfo->FontStyle;
NewStringInfo->FontInfo.FontSize = StringFontInfo->FontSize;
StrCpy (NewStringInfo->FontInfo.FontName, StringFontInfo->FontName);
Status = HiiStringToImage (
This,
Flags,
String,
NewStringInfo,
Blt,
BltX,
BltY,
RowInfoArray,
RowInfoArraySize,
ColumnInfoArray
);
goto Exit;
}
return HiiStringToImage (
Status = HiiStringToImage (
This,
Flags,
String,
@@ -2058,6 +2149,12 @@ HiiStringIdToImage (
ColumnInfoArray
);
Exit:
SafeFreePool (String);
SafeFreePool (StringFontInfo);
SafeFreePool (NewStringInfo);
return Status;
}
@@ -2231,7 +2328,9 @@ Exit:
returned font handle or points to NULL if there
are no more matching fonts.
@param StringInfoIn Upon entry, points to the font to return
information about.
information about.
If NULL, then the information about the system default
font will be returned.
@param StringInfoOut Upon return, contains the matching font's
information. If NULL, then no information is
returned. It's caller's responsibility to free
@@ -2242,7 +2341,7 @@ Exit:
@retval EFI_SUCCESS Matching font returned successfully.
@retval EFI_NOT_FOUND No matching font was found.
@retval EFI_INVALID_PARAMETER StringInfoIn is NULL.
@retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
request.
@@ -2252,7 +2351,7 @@ EFIAPI
HiiGetFontInfo (
IN CONST EFI_HII_FONT_PROTOCOL *This,
IN OUT EFI_FONT_HANDLE *FontHandle,
IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn,
IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL
OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,
IN CONST EFI_STRING String OPTIONAL
)
@@ -2267,51 +2366,71 @@ HiiGetFontInfo (
EFI_STRING StringIn;
EFI_FONT_HANDLE LocalFontHandle;
if (This == NULL || StringInfoIn == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Check the font information mask to make sure it is valid.
//
if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==
(EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==
(EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==
(EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==
(EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==
(EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
FontInfo = NULL;
SystemDefault = NULL;
LocalFontHandle = NULL;
if (FontHandle != NULL) {
LocalFontHandle = *FontHandle;
}
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
//
// Already searched to the end of the whole list, return directly.
//
if (LocalFontHandle == &Private->FontInfoList) {
LocalFontHandle = NULL;
Status = EFI_NOT_FOUND;
goto Exit;
}
//
// Get default system display info, if StringInfoIn points to
// system display info, return it directly.
//
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, &SystemDefault, &StringInfoOutLen)) {
if (StringInfoOut != NULL) {
*StringInfoOut = AllocateCopyPool (StringInfoOutLen, (EFI_FONT_DISPLAY_INFO *) StringInfoIn);
if (*StringInfoOut == NULL) {
Status = EFI_OUT_OF_RESOURCES;
LocalFontHandle = NULL;
goto Exit;
//
// System font is the first node. When handle is not NULL, system font can not
// be found any more.
//
if (LocalFontHandle == NULL) {
if (StringInfoOut != NULL) {
*StringInfoOut = AllocateCopyPool (StringInfoOutLen, SystemDefault);
if (*StringInfoOut == NULL) {
Status = EFI_OUT_OF_RESOURCES;
LocalFontHandle = NULL;
goto Exit;
}
}
}
LocalFontHandle = Private->FontInfoList.ForwardLink;
Status = EFI_SUCCESS;
goto Exit;
LocalFontHandle = Private->FontInfoList.ForwardLink;
Status = EFI_SUCCESS;
goto Exit;
} else {
LocalFontHandle = NULL;
Status = EFI_NOT_FOUND;
goto Exit;
}
}
//
// Check the font information mask to make sure it is valid.
//
if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==
(EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==
(EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==
(EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==
(EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==
(EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {
return EFI_INVALID_PARAMETER;
}
//
@@ -2331,13 +2450,17 @@ HiiGetFontInfo (
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_SIZE) == EFI_FONT_INFO_SYS_SIZE) {
InfoOut.FontInfo.FontSize = SystemDefault->FontInfo.FontSize;
} else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {
}
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {
InfoOut.FontInfo.FontStyle = SystemDefault->FontInfo.FontStyle;
} else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {
}
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {
InfoOut.ForegroundColor = SystemDefault->ForegroundColor;
} else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {
}
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {
InfoOut.BackgroundColor = SystemDefault->BackgroundColor;
}
FontInfo->FontSize = InfoOut.FontInfo.FontSize;
FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;
@@ -2393,3 +2516,4 @@ Exit:
return Status;
}