OpenCore  1.0.6
OpenCore Bootloader
Loading...
Searching...
No Matches
OcAppleUserInterfaceThemeLib.c
Go to the documentation of this file.
1
16#include <Guid/AppleVariable.h>
17#include <Guid/OcVariable.h>
18#include <Library/DebugLib.h>
19#include <Library/OcMiscLib.h>
20#include <Library/UefiRuntimeServicesTableLib.h>
21#include <Library/UefiBootServicesTableLib.h>
24
25STATIC UINT32 mCurrentColor;
26
27STATIC
28EFI_STATUS
29EFIAPI
31 OUT UINT32 *Color
32 )
33{
34 if (Color == NULL) {
35 return EFI_INVALID_PARAMETER;
36 }
37
38 *Color = mCurrentColor;
39 return EFI_SUCCESS;
40}
41
46
49 IN BOOLEAN Reinstall
50 )
51{
52 EFI_STATUS Status;
53 UINT32 Color;
54 UINTN DataSize;
56 EFI_HANDLE NewHandle;
57
58 if (Reinstall) {
60 if (EFI_ERROR (Status)) {
61 DEBUG ((DEBUG_ERROR, "OCUT: Uninstall failed - %r\n", Status));
62 return NULL;
63 }
64 } else {
65 Status = gBS->LocateProtocol (
67 NULL,
68 (VOID **)&EfiUiInterface
69 );
70 if (!EFI_ERROR (Status)) {
71 return EfiUiInterface;
72 }
73 }
74
75 //
76 // Default color is black.
77 //
79
80 //
81 // OC_BACKGROUND_COLOR_VARIABLE_NAME has priority.
82 //
83 DataSize = sizeof (Color);
84 Status = gRT->GetVariable (
87 0,
88 &DataSize,
89 &Color
90 );
91 if (!EFI_ERROR (Status)) {
92 mCurrentColor = Color;
93 } else {
94 //
95 // APPLE_DEFAULT_BACKGROUND_COLOR_VARIABLE_NAME is used as a fallback.
96 //
97 DataSize = sizeof (Color);
98 Status = gRT->GetVariable (
101 0,
102 &DataSize,
103 &Color
104 );
105 if (!EFI_ERROR (Status)) {
106 mCurrentColor = Color;
107 }
108 }
109
110 NewHandle = NULL;
111 Status = gBS->InstallMultipleProtocolInterfaces (
112 &NewHandle,
115 NULL
116 );
117 if (EFI_ERROR (Status)) {
118 return NULL;
119 }
120
122}
EFI_GUID gAppleVendorVariableGuid
#define APPLE_DEFAULT_BACKGROUND_COLOR_VARIABLE_NAME
STATIC EFI_STATUS EFIAPI UserInterfaceThemeGetColor(OUT UINT32 *Color)
EFI_USER_INTERFACE_THEME_PROTOCOL * OcAppleUserInterfaceThemeInstallProtocol(IN BOOLEAN Reinstall)
STATIC EFI_USER_INTERFACE_THEME_PROTOCOL mAppleUserInterfaceThemeProtocol
STATIC UINT32 mCurrentColor
EFI_BOOT_SERVICES * gBS
EFI_STATUS OcUninstallAllProtocolInstances(EFI_GUID *Protocol)
#define OC_BACKGROUND_COLOR_VARIABLE_NAME
Definition OcVariable.h:88
EFI_GUID gOcVendorVariableGuid
EFI_RUNTIME_SERVICES * gRT
#define APPLE_COLOR_SYRAH_BLACK
#define USER_THEME_INTERFACE_PROTOCOL_REVISION
EFI_GUID gEfiUserInterfaceThemeProtocolGuid