mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-29 12:35:53 +01:00
Switch IconsNames from CHAR8*[] to LString8[] to avoid memory
allocation.
This commit is contained in:
parent
286b189846
commit
8b2d5934fd
@ -55,8 +55,6 @@
|
||||
#define DBG(...) DebugLog(DEBUG_COMMON_MENU, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
extern CONST CHAR8* IconsNames[];
|
||||
|
||||
const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
|
||||
{
|
||||
@ -115,7 +113,7 @@ const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const
|
||||
// DBG("asked IconNum = %llu Volume->DiskKind=%d OSType=%d\n", IconNum, Volume->DiskKind, OSType);
|
||||
IconX = &ThemeX->GetIcon(IconNum); //asked IconNum = BUILTIN_ICON_VOL_INTERNAL_HFS, got day icon
|
||||
if (IconX->Image.isEmpty()) {
|
||||
DBG("asked Icon %s not found, took internal\n", IconsNames[IconNum]);
|
||||
DBG("asked Icon %s not found, took internal\n", IconsNames[IconNum].c_str());
|
||||
IconX = &ThemeX->GetIcon(BUILTIN_ICON_VOL_INTERNAL); //including embedded which is really present
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#include "XTheme.h"
|
||||
|
||||
extern const CHAR8* IconsNames[];
|
||||
extern const INTN IconsNamesSize;
|
||||
//extern const LString8 IconsNames[]; -> Include XIcon.h instead if duplicating declaration.
|
||||
//extern const INTN IconsNamesSize;
|
||||
|
||||
|
||||
#define NSVG_RGB(r, g, b) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16))
|
||||
@ -254,7 +254,7 @@ if ( nsvg__nbDanglingPtr() > 0 ) {
|
||||
|
||||
// --- Make other OSes
|
||||
for (INTN i = ICON_OTHER_OS; i < IconsNamesSize; ++i) {
|
||||
if (AsciiStrLen(IconsNames[i]) == 0) break;
|
||||
if ( IconsNames[i].isEmpty() ) break;
|
||||
XIcon* NewIcon = new XIcon(i, false); //initialize without embedded
|
||||
Status = ParseSVGXIcon(SVGParser, i, NewIcon->Name, &NewIcon->Image);
|
||||
// DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, efiStrError(Status));
|
||||
|
@ -25,7 +25,7 @@ extern "C" {
|
||||
#define DBG(...) DebugLog(DEBUG_XICON, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
CONST CHAR8* IconsNames[] = {
|
||||
CONST LString8 IconsNames[] = {
|
||||
"func_about",
|
||||
"func_options",
|
||||
"func_clover",
|
||||
@ -105,7 +105,7 @@ ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
|
||||
XIcon::XIcon(INTN Index, XBool TakeEmbedded) : Id(Index), Empty(false)
|
||||
{
|
||||
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index < IconsNamesSize) { //full table
|
||||
Name.takeValueFrom(IconsNames[Index]);
|
||||
Name = IconsNames[Index];
|
||||
}
|
||||
if (TakeEmbedded) {
|
||||
GetEmbedded();
|
||||
@ -195,7 +195,7 @@ void XIcon::GetEmbedded()
|
||||
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX_CHECKED, emb_checkbox_checked)
|
||||
break;
|
||||
case BUILTIN_ICON_SELECTION:
|
||||
Name.takeValueFrom("selection_indicator");
|
||||
Name = "selection_indicator"_XS8;
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_SELECTION, emb_selection_indicator)
|
||||
break;
|
||||
default:
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "../Platform/BootLog.h"
|
||||
#include "../Platform/Utils.h"
|
||||
|
||||
extern CONST CHAR8* IconsNames[];
|
||||
extern CONST LString8 IconsNames[];
|
||||
extern const INTN IconsNamesSize;
|
||||
|
||||
|
||||
|
@ -630,7 +630,7 @@ EFI_STATUS XImage::LoadXImage(const EFI_FILE *BaseDir, const wchar_t* LIconName)
|
||||
}
|
||||
//dont call this procedure for SVG theme BaseDir == NULL?
|
||||
//it can be used for other files
|
||||
EFI_STATUS XImage::LoadXImage(const EFI_FILE *BaseDir, const XStringW& IconName)
|
||||
EFI_STATUS XImage::LoadXImage(const EFI_FILE *BaseDir, const XString8& IconName)
|
||||
{
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
UINT8 *FileData = NULL;
|
||||
@ -668,7 +668,7 @@ EFI_STATUS XImage::LoadXImage(const EFI_FILE *BaseDir, const XStringW& IconName)
|
||||
// decode it
|
||||
Status = FromPNG(FileData, FileDataLength);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DBG("%ls not decoded. Status=%s\n", IconName.wc_str(), efiStrError(Status));
|
||||
DBG("%s not decoded. Status=%s\n", IconName.c_str(), efiStrError(Status));
|
||||
}
|
||||
FreePool(FileData);
|
||||
return Status;
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
void DrawOnBack(INTN x, INTN y, const XImage& Plate) const;
|
||||
//I changed the name because LoadImage is too widely used
|
||||
// will be used instead of old egLoadImage
|
||||
EFI_STATUS LoadXImage(const EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
||||
EFI_STATUS LoadXImage(const EFI_FILE *Dir, const XString8& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
||||
EFI_STATUS LoadXImage(const EFI_FILE *Dir, const wchar_t* LIconName);
|
||||
EFI_STATUS LoadXImage(const EFI_FILE *Dir, const char* IconName);
|
||||
EFI_STATUS LoadIcns(const EFI_FILE *Dir, IN CONST CHAR16 *FileName, IN UINTN PixelSize);
|
||||
|
@ -1045,7 +1045,7 @@ void XTheme::ClearScreen() //and restore background and banner
|
||||
default:
|
||||
// already scaled
|
||||
Background = BigBack;
|
||||
// DBG("back copy equal\n");
|
||||
//DBG("Assign Background = BigBack. BigBack.Width=%lld BigBack.Height=%lld\n", BigBack.GetWidth(), BigBack.GetHeight());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -1090,7 +1090,7 @@ void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
|
||||
}
|
||||
NewIcon->Native = !EFI_ERROR(Status);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i]));
|
||||
NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i].c_str()));
|
||||
}
|
||||
Icons.AddReference(NewIcon, true);
|
||||
if (EFI_ERROR(Status)) {
|
||||
|
@ -101,7 +101,7 @@ void XTheme::LoadFontImage(IN XBool UseEmbedded, IN INTN Rows, IN INTN Cols)
|
||||
Status = NewImage.FromPNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data)); //always success
|
||||
MsgLog("Using embedded font\n");
|
||||
} else if (isKorean){
|
||||
Status = NewImage.LoadXImage(ThemeDir, L"FontKorean.png"_XSW);
|
||||
Status = NewImage.LoadXImage(ThemeDir, "FontKorean.png"_XS8);
|
||||
MsgLog("Loading korean font from ThemeDir: %s\n", efiStrError(Status));
|
||||
if (!EFI_ERROR(Status)) {
|
||||
CharWidth = 22; //standard for korean
|
||||
|
Loading…
Reference in New Issue
Block a user