13#include <Library/DebugLib.h>
14#include <Library/MemoryAllocationLib.h>
17#include <Library/UefiBootServicesTableLib.h>
18#include <Library/UefiRuntimeServicesTableLib.h>
19#include <Library/PrintLib.h>
20#include <Library/BaseLib.h>
88 FreePool ((VOID *)Memory);
128 IN CONST CHAR8 *ImageFilePath,
130 IN UINT32 MatchWidth,
131 IN UINT32 MatchHeight,
133 IN CONST CHAR8 *Prefix,
134 IN BOOLEAN AllowLessSize
144 ASSERT (ImageFilePath != NULL);
145 ASSERT (Scale == 1 || Scale == 2);
149 for (Index = 0; Index < ImageCount; ++Index) {
155 Index > 0 ?
"Ext" :
"",
158 if (EFI_ERROR (Status)) {
159 DEBUG ((DEBUG_WARN,
"OCUI: Cannot fit %a\n", ImageFilePath));
160 return EFI_OUT_OF_RESOURCES;
164 Status = EFI_NOT_FOUND;
167 if ((FileData != NULL) && (FileSize > 0)) {
179 if (FileData != NULL) {
184 if (EFI_ERROR (Status)) {
187 "OCUI: Failed to load image (%u/%u) %s prefix:%a icon:%d - %r\n",
198 "Memory may be leaked due to previously loaded images."
200 return EFI_NOT_FOUND;
203 Images[Index].Width = 0;
204 Images[Index].Height = 0;
205 Images[Index].Buffer = NULL;
216 IN CONST CHAR8 *LabelFilePath,
225 ASSERT (Scale == 1 || Scale == 2);
232 Scale == 2 ?
"l2x" :
"lbl"
234 if (EFI_ERROR (Status)) {
235 DEBUG ((DEBUG_WARN,
"OCUI: Cannot fit %a\n", LabelFilePath));
236 return EFI_OUT_OF_RESOURCES;
241 if (*FileData == NULL) {
242 DEBUG ((DEBUG_WARN,
"OCUI: Failed to load %s\n", Path));
243 return EFI_NOT_FOUND;
246 if (*FileSize == 0) {
247 FreePool (*FileData);
248 DEBUG ((DEBUG_WARN,
"OCUI: Empty %s\n", Path));
249 return EFI_NOT_FOUND;
258 IN CONST CHAR8 *ImageFilePath,
268 ASSERT (Scale == 1 || Scale == 2);
271 if (EFI_ERROR (Status)) {
275 Status =
GuiLabelToImage (Image, ImageData, ImageSize, Scale, Inverted);
277 FreePool (ImageData);
279 if (EFI_ERROR (Status)) {
280 DEBUG ((DEBUG_WARN,
"OCUI: Failed to decode label %a - %r\n", ImageFilePath, Status));
290 IN CHAR8 *FlavourName,
291 IN UINTN FlavourNameLen,
292 IN UINT32 IconTypeIndex,
293 IN BOOLEAN UseFlavourIcon,
295 OUT BOOLEAN *CustomIcon
305 ASSERT (EntryIcon != NULL);
306 ASSERT (CustomIcon != NULL);
308 if ((FlavourNameLen == 0) ||
312 return EFI_UNSUPPORTED;
320 if (GuiContext->Icons[Index][IconTypeIndex].Buffer != NULL) {
321 CopyMem (EntryIcon, &GuiContext->Icons[Index][IconTypeIndex], sizeof (*EntryIcon));
333 if (!UseFlavourIcon) {
334 return EFI_NOT_FOUND;
343 IconTypeIndex > 0 ?
"Ext" :
"",
347 if (EFI_ERROR (Status)) {
348 DEBUG ((DEBUG_WARN,
"OCUI: Cannot fit %a\n", ImageName));
353 DEBUG ((DEBUG_INFO,
"OCUI: Trying flavour icon %s\n", Path));
355 Status = EFI_NOT_FOUND;
358 if ((FileData != NULL) && (FileSize > 0)) {
370 if (FileData != NULL) {
374 if (EFI_ERROR (Status)) {
375 DEBUG ((DEBUG_WARN,
"OCUI: Invalid icon file\n"));
379 if (!EFI_ERROR (Status)) {
380 ASSERT (EntryIcon->Buffer != NULL);
385 return EFI_NOT_FOUND;
399 UINT32 FontImageSize;
406 BOOLEAN AllowLessSize;
407 BOOLEAN UseGenericLabel;
412 UiScaleSize =
sizeof (Context->Scale);
416 Status =
gRT->GetVariable (
421 (VOID *)&Context->Scale
424 if (EFI_ERROR (Status) || (Context->Scale != 2)) {
428 Status =
gBS->LocateProtocol (
433 if (!EFI_ERROR (Status)) {
437 if (EFI_ERROR (Status)) {
441 if (AsciiStrCmp (Picker->PickerVariant,
"Auto") == 0) {
443 Context->Prefix =
"Acidanthera\\Chardonnay";
445 Context->Prefix =
"Acidanthera\\GoldenGate";
447 }
else if (AsciiStrCmp (Picker->PickerVariant,
"Default") == 0) {
448 Context->Prefix =
"Acidanthera\\GoldenGate";
450 Context->Prefix = Picker->PickerVariant;
454 &Context->Background,
466 Context->LightBackground = FALSE;
468 Context->LightBackground = TRUE;
473 Context->LightBackground = (Context->BackgroundColor.Pixel.Red * 299U
474 + Context->BackgroundColor.Pixel.Green * 587U
475 + Context->BackgroundColor.Pixel.Blue * 114U) >= 186000;
481 Context->BackgroundColor.Pixel.Reserved = 0xFF;
484 AllowLessSize = FALSE;
488 AllowLessSize = TRUE;
495 AllowLessSize = TRUE;
502 AllowLessSize = TRUE;
506 AllowLessSize = TRUE;
510 AllowLessSize = TRUE;
514 AllowLessSize = TRUE;
518 AllowLessSize = TRUE;
522 AllowLessSize = TRUE;
529 Context->Icons[Index],
539 if (!EFI_ERROR (Status)) {
547 if (Context->Icons[Index]->Width != Context->Icons[
ICON_SELECTOR]->Width) {
548 Status = EFI_UNSUPPORTED;
551 "OCUI: %a width %upx != %a width %upx\n",
553 Context->Icons[Index]->Width,
559 "Selector must be loaded before SetDefault."
571 Status = EFI_NOT_FOUND;
572 DEBUG ((DEBUG_WARN,
"OCUI: Missing external disk icon\n"));
575 "The base icon should must be cleaned up explicitly."
583 "OCUI: Expected at least %dx%d for cursor, actual %dx%d\n",
589 Status = EFI_UNSUPPORTED;
593 ZeroMem (&Context->Icons[Index], sizeof (Context->Icons[Index]));
597 DEBUG ((DEBUG_WARN,
"OCUI: Failed to load images for %a\n", Context->Prefix));
599 return EFI_UNSUPPORTED;
604 if (!UseGenericLabel) {
605 Context->Labels[Index].Buffer = NULL;
611 Context->LightBackground,
612 &Context->Labels[Index]
614 if (EFI_ERROR (Status)) {
615 Context->Labels[Index].Buffer = NULL;
616 DEBUG ((DEBUG_WARN,
"OCUI: Failed to load images\n"));
618 return EFI_UNSUPPORTED;
623 if (Context->Scale == 2) {
631 if ((FontImage != NULL) && (FontData != NULL)) {
633 &Context->FontContext,
643 "OCUI: Font has height %d instead of %d\n",
644 Context->FontContext.BmfContext.Height,
654 DEBUG ((DEBUG_WARN,
"OCUI: Font init failed\n"));
656 return EFI_UNSUPPORTED;
EFI_GUID gAppleVendorVariableGuid
#define APPLE_UI_SCALE_VARIABLE_NAME
BOOLEAN GuiFontConstruct(OUT GUI_FONT_CONTEXT *Context, IN VOID *FontImage, IN UINTN FontImageSize, IN VOID *FileBuffer, IN UINT32 FileSize, IN UINT8 Scale)
GLOBAL_REMOVE_IF_UNREFERENCED BOOT_PICKER_GUI_CONTEXT mGuiContext
STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mHighlightPixel
STATIC EFI_STATUS LoadLabelFileFromStorageForScale(IN OC_STORAGE_CONTEXT *Storage, IN CONST CHAR8 *LabelFilePath, IN UINT8 Scale, OUT VOID **FileData, OUT UINT32 *FileSize)
STATIC CONST CHAR8 * mLabelNames[LABEL_NUM_TOTAL]
STATIC CONST CHAR8 * mIconNames[ICON_NUM_TOTAL]
CONST GUI_IMAGE * InternalGetCursorImage(IN BOOT_PICKER_GUI_CONTEXT *Context)
STATIC VOID InternalContextDestruct(IN OUT BOOT_PICKER_GUI_CONTEXT *Context)
EFI_STATUS InternalGetFlavourIcon(IN BOOT_PICKER_GUI_CONTEXT *GuiContext, IN OC_STORAGE_CONTEXT *Storage, IN CHAR8 *FlavourName, IN UINTN FlavourNameLen, IN UINT32 IconTypeIndex, IN BOOLEAN UseFlavourIcon, OUT GUI_IMAGE *EntryIcon, OUT BOOLEAN *CustomIcon)
EFI_STATUS InternalContextConstruct(OUT BOOT_PICKER_GUI_CONTEXT *Context, IN OC_STORAGE_CONTEXT *Storage, IN OC_PICKER_CONTEXT *Picker)
STATIC VOID InternalSafeFreePool(IN CONST VOID *Memory)
EFI_STATUS LoadLabelFromStorage(IN OC_STORAGE_CONTEXT *Storage, IN CONST CHAR8 *ImageFilePath, IN UINT8 Scale, IN BOOLEAN Inverted, OUT GUI_IMAGE *Image)
STATIC EFI_STATUS LoadImageFileFromStorage(OUT GUI_IMAGE *Images, IN OC_STORAGE_CONTEXT *Storage, IN CONST CHAR8 *ImageFilePath, IN UINT8 Scale, IN UINT32 MatchWidth, IN UINT32 MatchHeight, IN BOOLEAN Icon, IN CONST CHAR8 *Prefix, IN BOOLEAN AllowLessSize)
#define MAX_CURSOR_DIMENSION
#define PASSWORD_ENTER_WIDTH
#define PASSWORD_DOT_DIMENSION
#define BOOT_ACTION_BUTTON_FOCUS_DIMENSION
#define BOOT_ENTRY_LABEL_HEIGHT
#define BOOT_ACTION_BUTTON_DIMENSION
@ LABEL_FIRMWARE_SETTINGS
@ LABEL_APPLE_TIME_MACHINE
#define PASSWORD_BOX_HEIGHT
#define BOOT_SELECTOR_BUTTON_HEIGHT
#define BOOT_SELECTOR_BUTTON_WIDTH
#define BOOT_ENTRY_LABEL_TEXT_OFFSET
@ ICON_APPLE_TIME_MACHINE
#define BOOT_ENTRY_ICON_DIMENSION
#define MIN_CURSOR_DIMENSION
#define PASSWORD_BOX_WIDTH
#define PASSWORD_LOCK_DIMENSION
#define PASSWORD_ENTER_HEIGHT
#define BOOT_SCROLL_BUTTON_DIMENSION
#define BOOT_SELECTOR_BACKGROUND_DIMENSION
EFI_STATUS GuiLabelToImage(OUT GUI_IMAGE *Image, IN VOID *RawData, IN UINT32 DataLength, IN UINT8 Scale, IN BOOLEAN Inverted)
EFI_STATUS GuiIcnsToImageIcon(OUT GUI_IMAGE *Image, IN VOID *IcnsImage, IN UINT32 IcnsImageSize, IN UINT8 Scale, IN UINT32 MatchWidth, IN UINT32 MatchHeight, IN BOOLEAN AllowLess)
EFI_STATUS GuiCreateHighlightedImage(OUT GUI_IMAGE *SelectedImage, IN CONST GUI_IMAGE *SourceImage, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL *HighlightPixel)
STATIC_ASSERT(BYTES_PER_PIXEL==sizeof(UINT32), "Non 4-byte pixels are unsupported!")
#define OC_ATTR_USE_GENERIC_LABEL_IMAGE
#define OPEN_CORE_IMAGE_PATH
#define OPEN_CORE_FONT_PATH
#define OPEN_CORE_LABEL_PATH
#define OC_MAX_CONTENT_FLAVOUR_SIZE
BOOLEAN OcStorageExistsFileUnicode(IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath)
VOID * OcStorageReadFileUnicode(IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL)
#define OC_STORAGE_SAFE_PATH_MAX
VOID UnicodeUefiSlashes(IN OUT CHAR16 *String)
INTN EFIAPI OcAsciiStrniCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
EFI_STATUS EFIAPI OcUnicodeSafeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_RUNTIME_SERVICES * gRT
#define APPLE_COLOR_SYRAH_BLACK
#define APPLE_COLOR_LIGHT_GRAY
EFI_GUID gEfiUserInterfaceThemeProtocolGuid
UI_THEME_GET_BACKGROUND_COLOR GetBackgroundColor
Present as of Revision 1.