]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
Change the status code to EFI_NOT_FOUND for Framework Hii's GetGlyph if EFI_WARN_UNKN...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / Fonts.c
CommitLineData
4259256b 1/**@file\r
4259256b 2 This file contains the Glyph related function.\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15\r
16#include "HiiDatabase.h"\r
17\r
133a9dfb 18EFI_NARROW_GLYPH mNarrowGlyphBuffer = {0, 0, {0}};\r
19\r
20BOOLEAN mSysFontColorCached = FALSE;\r
21EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor = {0};\r
59336178 22\r
59336178 23\r
0368663f 24/**\r
25 This function is only called by Graphics Console module and GraphicsLib. \r
26 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
27 complying to UEFI HII.\r
28 \r
29 This function will ASSERT and return EFI_UNSUPPORTED.\r
30\r
31 @param This N.A.\r
32 @param Source N.A.\r
33 @param Index N.A.\r
34 @param GlyphBuffer N.A.\r
35 @param BitWidth N.A.\r
36 @param InternalStatus N.A.\r
37\r
38 @return EFI_UNSUPPORTED N.A.\r
39\r
40**/\r
4259256b 41EFI_STATUS\r
42EFIAPI\r
43HiiGetGlyph (\r
44 IN EFI_HII_PROTOCOL *This,\r
45 IN CHAR16 *Source,\r
46 IN OUT UINT16 *Index,\r
47 OUT UINT8 **GlyphBuffer,\r
48 OUT UINT16 *BitWidth,\r
49 IN OUT UINT32 *InternalStatus\r
50 )\r
4259256b 51{\r
133a9dfb 52 EFI_STATUS Status;\r
53 EFI_IMAGE_OUTPUT *Blt;\r
54 EFI_FONT_DISPLAY_INFO *FontInfo;\r
55 UINTN Xpos;\r
56 UINTN Ypos;\r
57 UINTN BaseLine;\r
58\r
59 if (!mSysFontColorCached) {\r
60 //\r
61 // Cache the system font's foreground color.\r
62 //\r
63 Status = mHiiFontProtocol->GetFontInfo (\r
64 mHiiFontProtocol,\r
65 NULL,\r
66 NULL,\r
67 &FontInfo,\r
68 NULL\r
69 );\r
70\r
71 if (!EFI_ERROR (Status)) {\r
72 ASSERT (StrCmp (FontInfo->FontInfo.FontName, L"sysdefault") == 0);\r
73 mSysFGColor = FontInfo->ForegroundColor;\r
74 FreePool (FontInfo);\r
75\r
76 mSysFontColorCached = TRUE;\r
77 }\r
78 \r
79 }\r
80\r
81 Blt = NULL;\r
82 Status = mHiiFontProtocol->GetGlyph (\r
83 mHiiFontProtocol,\r
84 Source[*Index],\r
85 NULL,\r
86 &Blt,\r
87 &BaseLine\r
88 );\r
89\r
bc3fc71a 90 if (!EFI_ERROR (Status) && (Status != EFI_WARN_UNKNOWN_GLYPH)) {\r
133a9dfb 91 //\r
92 // For simplicity, we only handle Narrow Glyph.\r
93 //\r
133a9dfb 94 if (Blt->Height == EFI_GLYPH_HEIGHT && Blt->Width == EFI_GLYPH_WIDTH) {\r
95\r
96 ZeroMem (&mNarrowGlyphBuffer, sizeof (mNarrowGlyphBuffer));\r
97 mNarrowGlyphBuffer.UnicodeWeight = *Source;\r
98 for (Ypos = 0; Ypos < EFI_GLYPH_HEIGHT; Ypos++) {\r
99 for (Xpos = 0; Xpos < EFI_GLYPH_WIDTH; Xpos++) {\r
100 if (CompareMem (&Blt->Image.Bitmap[Ypos * EFI_GLYPH_WIDTH + Xpos], &mSysFGColor, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) == 0) {\r
101 mNarrowGlyphBuffer.GlyphCol1[Ypos] |= 1 << (EFI_GLYPH_WIDTH - 1 - Xpos);\r
102 }\r
103 }\r
104 }\r
105\r
106 *GlyphBuffer = (UINT8 *) &mNarrowGlyphBuffer;\r
107 *BitWidth = EFI_GLYPH_WIDTH;\r
108 *Index += 1;\r
109 } else {\r
110 Status = EFI_NOT_FOUND;\r
111 }\r
112\r
113 }\r
114\r
bc3fc71a 115 if (EFI_ERROR (Status) || (Status == EFI_WARN_UNKNOWN_GLYPH)) {\r
116 if (Status == EFI_WARN_UNKNOWN_GLYPH) {\r
117 Status = EFI_NOT_FOUND;\r
118 }\r
133a9dfb 119 *GlyphBuffer = NULL;\r
120 }\r
121 return Status;\r
4259256b 122}\r
123\r
0368663f 124/**\r
125 This function is only called by Graphics Console module and GraphicsLib. \r
126 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
127 complying to UEFI HII.\r
128 \r
129 This function will ASSERT and return EFI_UNSUPPORTED.\r
130\r
131 @param This N.A.\r
132 @param GlyphBuffer N.A.\r
133 @param Foreground N.A.\r
134 @param Background N.A.\r
135 @param Count N.A.\r
136 @param Width N.A.\r
137 @param Height N.A.\r
138 @param BltBuffer N.A.\r
139\r
140 @return EFI_UNSUPPORTED N.A.\r
141\r
142**/\r
4259256b 143EFI_STATUS\r
144EFIAPI\r
145HiiGlyphToBlt (\r
146 IN EFI_HII_PROTOCOL *This,\r
147 IN UINT8 *GlyphBuffer,\r
148 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
149 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
150 IN UINTN Count,\r
151 IN UINTN Width,\r
152 IN UINTN Height,\r
153 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer\r
154 )\r
155{\r
133a9dfb 156 UINTN X;\r
157 UINTN Y;\r
158\r
159 //\r
160 // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r
161 //\r
162 for (Y = 0; Y < Height; Y++) {\r
163 for (X = 0; X < Width; X++) {\r
164 if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Y] & (1 << X)) != 0) {\r
165 BltBuffer[Y * Width * Count + (Width - X - 1)] = Foreground;\r
166 } else {\r
167 BltBuffer[Y * Width * Count + (Width - X - 1)] = Background;\r
168 }\r
169 }\r
170 }\r
171\r
172 return EFI_SUCCESS;\r
4259256b 173}\r