+++ /dev/null
-/** @file\r
- This file contains the Glyph related function.\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include "HiiDatabase.h"\r
-\r
-EFI_NARROW_GLYPH mNarrowGlyphBuffer = {0, 0, {0}};\r
-\r
-BOOLEAN mSysFontColorCached = FALSE;\r
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor = {0};\r
-\r
-\r
-/**\r
- Translates a Unicode character into the corresponding font glyph.\r
- \r
- Notes:\r
- This function is only called by Graphics Console module and GraphicsLib. \r
- Wrap the Framework HII GetGlyph function to UEFI Font Protocol.\r
- \r
- EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
- complying to UEFI HII.\r
- \r
- @param This A pointer to the EFI_HII_PROTOCOL instance.\r
- @param Source A pointer to a Unicode string.\r
- @param Index On input, the offset into the string from which to fetch the character. On successful completion, the \r
- index is updated to the first character past the character(s) making up the just extracted glyph. \r
- @param GlyphBuffer Pointer to an array where the glyphs corresponding to the characters in the source may be stored. \r
- GlyphBuffer is assumed to be wide enough to accept a wide glyph character.\r
- @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by this value is filled with the length of the glyph in pixels. \r
- It is unchanged if the call was unsuccessful.\r
- @param InternalStatus To save the time required to read the string from the beginning on each glyph extraction \r
- (for example, to ensure that the narrow versus wide glyph mode is correct), this value is \r
- updated each time the function is called with the status that is local to the call. The cell pointed \r
- to by this parameter must be initialized to zero prior to invoking the call the first time for any string.\r
-\r
- @retval EFI_SUCCESS It worked.\r
- @retval EFI_NOT_FOUND A glyph for a character was not found.\r
- \r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HiiGetGlyph (\r
- IN EFI_HII_PROTOCOL *This,\r
- IN CHAR16 *Source,\r
- IN OUT UINT16 *Index,\r
- OUT UINT8 **GlyphBuffer,\r
- OUT UINT16 *BitWidth,\r
- IN OUT UINT32 *InternalStatus\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_IMAGE_OUTPUT *Blt;\r
- EFI_FONT_DISPLAY_INFO *FontInfo;\r
- UINTN Xpos;\r
- UINTN Ypos;\r
- UINTN BaseLine;\r
-\r
- if (!mSysFontColorCached) {\r
- //\r
- // Cache the system font's foreground color.\r
- //\r
- Status = mHiiFontProtocol->GetFontInfo (\r
- mHiiFontProtocol,\r
- NULL,\r
- NULL,\r
- &FontInfo,\r
- NULL\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- ASSERT (StrCmp (FontInfo->FontInfo.FontName, L"sysdefault") == 0);\r
- mSysFGColor = FontInfo->ForegroundColor;\r
- FreePool (FontInfo);\r
-\r
- mSysFontColorCached = TRUE;\r
- }\r
- \r
- }\r
-\r
- Blt = NULL;\r
- Status = mHiiFontProtocol->GetGlyph (\r
- mHiiFontProtocol,\r
- Source[*Index],\r
- NULL,\r
- &Blt,\r
- &BaseLine\r
- );\r
-\r
- if (!EFI_ERROR (Status) && (Status != EFI_WARN_UNKNOWN_GLYPH)) {\r
- //\r
- // For simplicity, we only handle Narrow Glyph.\r
- //\r
- if (Blt->Height == EFI_GLYPH_HEIGHT && Blt->Width == EFI_GLYPH_WIDTH) {\r
-\r
- ZeroMem (&mNarrowGlyphBuffer, sizeof (mNarrowGlyphBuffer));\r
- mNarrowGlyphBuffer.UnicodeWeight = *Source;\r
- for (Ypos = 0; Ypos < EFI_GLYPH_HEIGHT; Ypos++) {\r
- for (Xpos = 0; Xpos < EFI_GLYPH_WIDTH; Xpos++) {\r
- if (CompareMem (&Blt->Image.Bitmap[Ypos * EFI_GLYPH_WIDTH + Xpos], &mSysFGColor, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) == 0) {\r
- mNarrowGlyphBuffer.GlyphCol1[Ypos] = (UINT8) (mNarrowGlyphBuffer.GlyphCol1[Ypos] | (1 << (EFI_GLYPH_WIDTH - 1 - Xpos)));\r
- }\r
- }\r
- }\r
-\r
- *GlyphBuffer = (UINT8 *) &mNarrowGlyphBuffer;\r
- *BitWidth = EFI_GLYPH_WIDTH;\r
- *Index += 1;\r
- } else {\r
- Status = EFI_NOT_FOUND;\r
- }\r
-\r
- }\r
-\r
- if (EFI_ERROR (Status) || (Status == EFI_WARN_UNKNOWN_GLYPH)) {\r
- if (Status == EFI_WARN_UNKNOWN_GLYPH) {\r
- Status = EFI_NOT_FOUND;\r
- }\r
- *GlyphBuffer = NULL;\r
- }\r
- return Status;\r
-}\r
-\r
-/**\r
- Translates a glyph into the format required for input to the Universal Graphics Adapter (UGA) Block Transfer (BLT) routines.\r
- \r
- Notes:\r
- This function is only called by Graphics Console module and GraphicsLib. \r
- EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
- complying to UEFI HII.\r
- \r
- @param This A pointer to the EFI_HII_PROTOCOL instance.\r
- @param GlyphBuffer A pointer to the buffer that contains glyph data. \r
- @param Foreground The foreground setting requested to be used for the generated BltBuffer data. Type EFI_UGA_PIXEL is defined in "Related Definitions" below.\r
- @param Background The background setting requested to be used for the generated BltBuffer data. \r
- @param Count The entry in the BltBuffer upon which to act.\r
- @param Width The width in bits of the glyph being converted.\r
- @param Height The height in bits of the glyph being converted\r
- @param BltBuffer A pointer to the buffer that contains the data that is ready to be used by the UGA BLT routines. \r
-\r
- @retval EFI_SUCCESS It worked.\r
- @retval EFI_NOT_FOUND A glyph for a character was not found.\r
- \r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HiiGlyphToBlt (\r
- IN EFI_HII_PROTOCOL *This,\r
- IN UINT8 *GlyphBuffer,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
- IN UINTN Count,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer\r
- )\r
-{\r
- UINTN Xpos;\r
- UINTN Ypos;\r
-\r
- //\r
- // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r
- //\r
- for (Ypos = 0; Ypos < Height; Ypos++) {\r
- for (Xpos = 0; Xpos < Width; Xpos++) {\r
- if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Ypos] & (1 << Xpos)) != 0) {\r
- BltBuffer[Ypos * Width * Count + (Width - Xpos - 1)] = Foreground;\r
- } else {\r
- BltBuffer[Ypos * Width * Count + (Width - Xpos - 1)] = Background;\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r