mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
dynamic images again with memory free
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
f8ccb366fa
commit
be079edc92
@ -276,12 +276,12 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number)
|
||||
}
|
||||
|
||||
realMax = maximum.Control.Control;
|
||||
DBG("Maximum control=0x%hX\n", realMax);
|
||||
DBG("Maximum control=0x%hX\n", realMax);
|
||||
if (gSettings.Turbo) {
|
||||
realTurbo = (gCPUStructure.Turbo4 > gCPUStructure.Turbo1) ?
|
||||
(gCPUStructure.Turbo4 / 10) : (gCPUStructure.Turbo1 / 10);
|
||||
maximum.Control.Control = realTurbo;
|
||||
MsgLog("Turbo control=0x%hX\n", realTurbo);
|
||||
MsgLog("Turbo control=0x%hX\n", realTurbo);
|
||||
}
|
||||
Apsn = (realTurbo > realMax)?(realTurbo - realMax):0;
|
||||
realMin = RShiftU64(AsmReadMsr64(MSR_PLATFORM_INFO), 40) & 0xff;
|
||||
@ -292,7 +292,7 @@ SSDT_TABLE *generate_pss_ssdt(UINTN Number)
|
||||
minimum.Control.Control = realMin;
|
||||
}
|
||||
|
||||
MsgLog("P-States: min 0x%hX, max 0x%hX\n", minimum.Control.Control, maximum.Control.Control);
|
||||
MsgLog("P-States: min 0x%hX, max 0x%hX\n", minimum.Control.Control, maximum.Control.Control);
|
||||
|
||||
// Sanity check
|
||||
if (maximum.Control.Control < minimum.Control.Control) {
|
||||
|
@ -213,8 +213,7 @@ VOID GetCPUProperties (VOID)
|
||||
}
|
||||
AsciiStrnCpyS(gCPUStructure.BrandString, 48, s, 48);
|
||||
|
||||
if (!strncmp((const CHAR8*)gCPUStructure.BrandString, (const CHAR8*)CPU_STRING_UNKNOWN, iStrLen((gCPUStructure.BrandString) + 1, 48)))
|
||||
{
|
||||
if (!strncmp((const CHAR8*)gCPUStructure.BrandString, CPU_STRING_UNKNOWN, iStrLen((gCPUStructure.BrandString) + 1, 48))) {
|
||||
gCPUStructure.BrandString[0] = '\0';
|
||||
}
|
||||
gCPUStructure.BrandString[47] = '\0';
|
||||
@ -264,7 +263,6 @@ VOID GetCPUProperties (VOID)
|
||||
if (gCPUStructure.Cores == 0) {
|
||||
gCPUStructure.Cores = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (gCPUStructure.CoresPerPackage == 0) {
|
||||
@ -440,12 +438,12 @@ VOID GetCPUProperties (VOID)
|
||||
msr = AsmReadMsr64(MSR_FLEX_RATIO);
|
||||
if ((RShiftU64(msr, 16) & 0x01) != 0) {
|
||||
UINT8 flex_ratio = RShiftU64(msr, 8) & 0xff;
|
||||
MsgLog("non-usable FLEX_RATIO = %llX\n", msr);
|
||||
MsgLog("non-usable FLEX_RATIO = %llX\n", msr);
|
||||
if (flex_ratio == 0) {
|
||||
AsmWriteMsr64(MSR_FLEX_RATIO, (msr & 0xFFFFFFFFFFFEFFFFULL));
|
||||
gBS->Stall(10);
|
||||
msr = AsmReadMsr64(MSR_FLEX_RATIO);
|
||||
MsgLog("corrected FLEX_RATIO = %llX\n", msr);
|
||||
MsgLog("corrected FLEX_RATIO = %llX\n", msr);
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -607,7 +605,7 @@ VOID GetCPUProperties (VOID)
|
||||
gCPUStructure.MaxRatio = (UINT32)(RShiftU64(msr, 8)) & 0x1f;
|
||||
TurboMsr = (UINT32)(RShiftU64(msr, 40)) & 0x1f;
|
||||
if ((TurboMsr > gCPUStructure.MaxRatio) && (gCPUStructure.Model == CPU_MODEL_MEROM)) {
|
||||
DBG(" CPU works at low speed, MaxRatio=%llu CurrRatio=%d\n", TurboMsr,
|
||||
DBG(" CPU works at low speed, MaxRatio=%llu CurrRatio=%d\n", TurboMsr,
|
||||
gCPUStructure.MaxRatio);
|
||||
gCPUStructure.MaxRatio = (UINT32)TurboMsr;
|
||||
}
|
||||
@ -634,8 +632,8 @@ VOID GetCPUProperties (VOID)
|
||||
gCPUStructure.Turbo4 = (UINT16)(gCPUStructure.MaxRatio + 10);
|
||||
}
|
||||
DBG("MSR dumps:\n");
|
||||
DBG("\t@0x00CD=%llx\n", msr);
|
||||
DBG("\t@0x0198=%llx\n", AsmReadMsr64(MSR_IA32_PERF_STATUS));
|
||||
DBG("\t@0x00CD=%llx\n", msr);
|
||||
DBG("\t@0x0198=%llx\n", AsmReadMsr64(MSR_IA32_PERF_STATUS));
|
||||
break;
|
||||
default:
|
||||
gCPUStructure.TSCFrequency = MultU64x32(gCPUStructure.CurrentSpeed, Mega); //MHz -> Hz
|
||||
|
@ -73,7 +73,7 @@
|
||||
#define CPU_VENDOR_INTEL 0x756E6547
|
||||
#define CPU_VENDOR_AMD 0x68747541
|
||||
/* Unknown CPU */
|
||||
#define CPU_STRING_UNKNOWN "Unknown CPU Type"
|
||||
const char CPU_STRING_UNKNOWN[] = "Unknown CPU Type";
|
||||
|
||||
|
||||
/* CPU defines */
|
||||
|
@ -1895,8 +1895,13 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuLabel(IN CONST XStringW& Text, IN INTN XPos,
|
||||
INTN X = XPos - (TextWidth >> 1) - (BadgeDim + 16);
|
||||
INTN Y = YPos - ((BadgeDim - ThemeX.TextHeight) >> 1);
|
||||
Back.CopyRect(ThemeX.Background, X, Y);
|
||||
Back.Compose(0, 0, Entries[ScrollState.CurrentSelection].Image.GetBest(!Daylight), false, BadgeDim/128.f);
|
||||
bool free = false;
|
||||
XImage *CurrSel = Entries[ScrollState.CurrentSelection].Image.GetBest(!Daylight, &free);
|
||||
Back.Compose(0, 0, *CurrSel, false, BadgeDim/128.f);
|
||||
Back.DrawOnBack(X, Y, Back);
|
||||
if (free) {
|
||||
delete CurrSel;
|
||||
}
|
||||
}
|
||||
|
||||
OldX = XPos;
|
||||
@ -2009,8 +2014,8 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
}
|
||||
|
||||
// const XImage& MainImage = (!ThemeX.Daylight && !MainIcon.ImageNight.isEmpty())? MainIcon.ImageNight : MainIcon.Image;
|
||||
|
||||
const XImage& MainImage = MainIcon.GetBest(!Daylight);
|
||||
bool free = false;
|
||||
XImage *MainImage = MainIcon.GetBest(!Daylight, &free);
|
||||
|
||||
INTN CompWidth = (Entry->Row == 0) ? ThemeX.row0TileSize : ThemeX.row1TileSize;
|
||||
INTN CompHeight = CompWidth;
|
||||
@ -2035,9 +2040,9 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
XImage Back(CompWidth, CompHeight);
|
||||
Back.CopyRect(ThemeX.Background, XPos, YPos);
|
||||
|
||||
INTN OffsetX = (CompWidth - MainImage.GetWidth()) / 2;
|
||||
INTN OffsetX = (CompWidth - MainImage->GetWidth()) / 2;
|
||||
OffsetX = (OffsetX > 0) ? OffsetX: 0;
|
||||
INTN OffsetY = (CompHeight - MainImage.GetHeight()) / 2;
|
||||
INTN OffsetY = (CompHeight - MainImage->GetHeight()) / 2;
|
||||
OffsetY = (OffsetY > 0) ? OffsetY: 0;
|
||||
|
||||
INTN OffsetTX = (CompWidth - TopImage.GetWidth()) / 2;
|
||||
@ -2050,18 +2055,28 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
float composeScale = (ThemeX.NonSelectedGrey && !selected)? -1.f: 1.f;
|
||||
if(ThemeX.SelectionOnTop) {
|
||||
//place main image in centre. It may be OS or Drive
|
||||
Back.Compose(OffsetX, OffsetY, MainImage, false, composeScale);
|
||||
Back.Compose(OffsetX, OffsetY, *MainImage, false, composeScale);
|
||||
} else {
|
||||
Back.Compose(OffsetTX, OffsetTY, TopImage, false); //selection first
|
||||
Back.Compose(OffsetX, OffsetY, MainImage, false, composeScale);
|
||||
Back.Compose(OffsetX, OffsetY, *MainImage, false, composeScale);
|
||||
}
|
||||
|
||||
Entry->Place.XPos = XPos;
|
||||
Entry->Place.YPos = YPos;
|
||||
Entry->Place.Width = MainImage->GetWidth();
|
||||
Entry->Place.Height = MainImage->GetHeight();
|
||||
|
||||
if (free) {
|
||||
delete MainImage;
|
||||
}
|
||||
// place the badge image
|
||||
float fBadgeScale = ThemeX.BadgeScale/16.f;
|
||||
if ((Entry->Row == 0) && BadgeIcon && !BadgeIcon->isEmpty()) {
|
||||
// const XImage& BadgeImage = (!ThemeX.Daylight && !BadgeIcon->ImageNight.isEmpty()) ? &BadgeIcon->ImageNight : BadgeImage = &BadgeIcon->Image;
|
||||
const XImage& BadgeImage = BadgeIcon->GetBest(!Daylight);
|
||||
INTN BadgeWidth = (INTN)(BadgeImage.GetWidth() * fBadgeScale);
|
||||
INTN BadgeHeight = (INTN)(BadgeImage.GetHeight() * fBadgeScale);
|
||||
free = false;
|
||||
XImage* BadgeImage = BadgeIcon->GetBest(!Daylight, &free);
|
||||
INTN BadgeWidth = (INTN)(BadgeImage->GetWidth() * fBadgeScale);
|
||||
INTN BadgeHeight = (INTN)(BadgeImage->GetHeight() * fBadgeScale);
|
||||
|
||||
if ((BadgeWidth + 8) < CompWidth && (BadgeHeight + 8) < CompHeight) {
|
||||
|
||||
@ -2080,7 +2095,8 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
OffsetY += CompHeight - 8 - BadgeHeight;
|
||||
}
|
||||
// DBG(" badge offset=[%lld,%lld]\n", OffsetX, OffsetY);
|
||||
Back.Compose(OffsetX, OffsetY, BadgeImage, false, fBadgeScale);
|
||||
Back.Compose(OffsetX, OffsetY, *BadgeImage, false, fBadgeScale);
|
||||
if (free) delete BadgeImage;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2089,10 +2105,6 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
|
||||
}
|
||||
Back.DrawWithoutCompose(XPos, YPos);
|
||||
|
||||
Entry->Place.XPos = XPos;
|
||||
Entry->Place.YPos = YPos;
|
||||
Entry->Place.Width = MainImage.GetWidth();
|
||||
Entry->Place.Height = MainImage.GetHeight();
|
||||
|
||||
// draw BCS indicator
|
||||
// Needy: if Labels (Titles) are hidden there is no point to draw the indicator
|
||||
|
@ -336,13 +336,13 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
|
||||
SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
|
||||
//TODO make SelectionImages to be XIcon
|
||||
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG).GetBest(!Daylight);
|
||||
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL).GetBest(!Daylight);
|
||||
SelectionImages[4] = GetIcon(BUILTIN_ICON_SELECTION).GetBest(!Daylight);
|
||||
SelectionImages[0] = *GetIconP(BUILTIN_SELECTION_BIG)->GetBest(!Daylight);
|
||||
SelectionImages[2] = *GetIconP(BUILTIN_SELECTION_SMALL)->GetBest(!Daylight);
|
||||
SelectionImages[4] = *GetIconP(BUILTIN_ICON_SELECTION)->GetBest(!Daylight);
|
||||
|
||||
//buttons
|
||||
for (INTN i = BUILTIN_RADIO_BUTTON; i <= BUILTIN_CHECKBOX_CHECKED; ++i) {
|
||||
Buttons[i - BUILTIN_RADIO_BUTTON] = GetIcon(i).GetBest(!Daylight);
|
||||
Buttons[i - BUILTIN_RADIO_BUTTON] = *GetIconP(i)->GetBest(!Daylight);
|
||||
}
|
||||
//for (int i=0 ; i<6 ; i+=2 ) {
|
||||
//SelectionImages[i].Draw(i*100, 0);
|
||||
|
@ -88,7 +88,7 @@ EFI_STATUS XPointer::MouseBirth()
|
||||
PointerImage = nullptr;
|
||||
}
|
||||
// Now update image because of other theme has other image
|
||||
PointerImage = new XImage(ThemeX.GetIcon(BUILTIN_ICON_POINTER).GetBest(night));
|
||||
PointerImage = new XImage(*ThemeX.GetIconP(BUILTIN_ICON_POINTER)->GetBest(night));
|
||||
|
||||
oldImage.setSizeInPixels(PointerImage->GetWidth(), PointerImage->GetHeight());
|
||||
LastClickTime = 0;
|
||||
|
@ -245,9 +245,9 @@ EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName)
|
||||
return Status;
|
||||
}
|
||||
|
||||
const XImage& XIcon::GetBest(bool night) const
|
||||
XImage* XIcon::GetBest(bool night, bool *free)
|
||||
{
|
||||
#if 0
|
||||
#if 1
|
||||
if (ImageSVG) {
|
||||
NSVGimage* sImage = (NSVGimage*)ImageSVGnight;
|
||||
if (!night || !ImageSVGnight) sImage = (NSVGimage*)ImageSVG;
|
||||
@ -259,7 +259,8 @@ const XImage& XIcon::GetBest(bool night) const
|
||||
int iHeight = (int)(Height + 0.5f);
|
||||
XImage* NewImage = new XImage(iWidth, iHeight); //TODO doing new ximage we have to delete it after use
|
||||
if (sImage->shapes == NULL) {
|
||||
return *NewImage;
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
float bounds[4];
|
||||
nsvg__imageBounds(sImage, bounds);
|
||||
@ -275,10 +276,12 @@ const XImage& XIcon::GetBest(bool night) const
|
||||
// if (night) ImageNight = *NewImage;
|
||||
// else Image = *NewImage;
|
||||
// delete NewImage;
|
||||
return *NewImage;
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
#endif
|
||||
const XImage& RetImage = (night && !ImageNight.isEmpty())? ImageNight : Image;
|
||||
XImage* RetImage = (night && !ImageNight.isEmpty())? &ImageNight : &Image;
|
||||
if (free) *free = false;
|
||||
return RetImage;
|
||||
}
|
||||
|
||||
@ -390,6 +393,18 @@ const XIcon& XTheme::GetIcon(const XString8& Name)
|
||||
return NullIcon; //if name is not found
|
||||
}
|
||||
|
||||
XIcon* XTheme::GetIconP(const XString8& Name)
|
||||
{
|
||||
for (size_t i = 0; i < Icons.size(); i++)
|
||||
{
|
||||
if (Icons[i].Name == Name) //night icon has same name as daylight icon
|
||||
{
|
||||
return GetIconP(Icons[i].Id);
|
||||
}
|
||||
}
|
||||
return &NullIcon; //if name is not found
|
||||
}
|
||||
|
||||
bool XTheme::CheckNative(INTN Id)
|
||||
{
|
||||
for (size_t i = 0; i < Icons.size(); i++)
|
||||
@ -407,13 +422,18 @@ const XIcon& XTheme::GetIcon(INTN Id)
|
||||
return GetIconAlt(Id, -1);
|
||||
}
|
||||
|
||||
XIcon* XTheme::GetIconP(INTN Id)
|
||||
{
|
||||
return &GetIconAlt(Id, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get Icon with this ID=id, for example VOL_INTERNAL_HFS
|
||||
* if not found then search for ID=Alt with Native attribute set, for example VOL_INTERNAL
|
||||
* if not found then check embedded with ID=Id
|
||||
* if not found then check embedded with ID=Alt
|
||||
*/
|
||||
const XIcon& XTheme::GetIconAlt(INTN Id, INTN Alt) //if not found then take embedded
|
||||
XIcon& XTheme::GetIconAlt(INTN Id, INTN Alt) //if not found then take embedded
|
||||
{
|
||||
INTN IdFound = -1;
|
||||
INTN AltFound = -1;
|
||||
@ -727,17 +747,17 @@ void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
|
||||
SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
|
||||
SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
|
||||
//TODO - make them XIcon
|
||||
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL).GetBest(!Daylight);
|
||||
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG).GetBest(!Daylight);
|
||||
SelectionImages[2] = *GetIconP(BUILTIN_SELECTION_SMALL)->GetBest(!Daylight);
|
||||
SelectionImages[0] = *GetIconP(BUILTIN_SELECTION_BIG)->GetBest(!Daylight);
|
||||
if (BootCampStyle) {
|
||||
SelectionImages[4] = GetIcon(BUILTIN_ICON_SELECTION).GetBest(!Daylight);
|
||||
SelectionImages[4] = *GetIconP(BUILTIN_ICON_SELECTION)->GetBest(!Daylight);
|
||||
}
|
||||
|
||||
//and buttons
|
||||
Buttons[0] = GetIcon(BUILTIN_RADIO_BUTTON).GetBest(!Daylight);
|
||||
Buttons[1] = GetIcon(BUILTIN_RADIO_BUTTON_SELECTED).GetBest(!Daylight);
|
||||
Buttons[2] = GetIcon(BUILTIN_CHECKBOX).GetBest(!Daylight);
|
||||
Buttons[3] = GetIcon(BUILTIN_CHECKBOX_CHECKED).GetBest(!Daylight);
|
||||
Buttons[0] = *GetIconP(BUILTIN_RADIO_BUTTON)->GetBest(!Daylight);
|
||||
Buttons[1] = *GetIconP(BUILTIN_RADIO_BUTTON_SELECTED)->GetBest(!Daylight);
|
||||
Buttons[2] = *GetIconP(BUILTIN_CHECKBOX)->GetBest(!Daylight);
|
||||
Buttons[3] = *GetIconP(BUILTIN_CHECKBOX_CHECKED)->GetBest(!Daylight);
|
||||
|
||||
//load banner and background
|
||||
Banner.LoadXImage(ThemeDir, BannerFileName);
|
||||
@ -763,14 +783,14 @@ void XTheme::InitBar()
|
||||
UpButtonImage.LoadXImage(ThemeDir, "scrollbar\\up_button");
|
||||
DownButtonImage.LoadXImage(ThemeDir, "scrollbar\\down_button");
|
||||
} else {
|
||||
ScrollbarBackgroundImage = GetIcon("scrollbar_background"_XS8).GetBest(!Daylight);
|
||||
ScrollbarBackgroundImage = *GetIconP("scrollbar_background"_XS8)->GetBest(!Daylight);
|
||||
BarStartImage.setEmpty();
|
||||
BarEndImage.setEmpty();
|
||||
ScrollbarImage = GetIcon("scrollbar_holder"_XS8).GetBest(!Daylight); //"_night" is already accounting
|
||||
ScrollStartImage = GetIcon("scrollbar_start"_XS8).GetBest(!Daylight);
|
||||
ScrollEndImage = GetIcon("scrollbar_end"_XS8).GetBest(!Daylight);
|
||||
UpButtonImage = GetIcon("scrollbar_up_button"_XS8).GetBest(!Daylight);
|
||||
DownButtonImage = GetIcon("scrollbar_down_button"_XS8).GetBest(!Daylight);
|
||||
ScrollbarImage = *GetIconP("scrollbar_holder"_XS8)->GetBest(!Daylight); //"_night" is already accounting
|
||||
ScrollStartImage = *GetIconP("scrollbar_start"_XS8)->GetBest(!Daylight);
|
||||
ScrollEndImage = *GetIconP("scrollbar_end"_XS8)->GetBest(!Daylight);
|
||||
UpButtonImage = *GetIconP("scrollbar_up_button"_XS8)->GetBest(!Daylight);
|
||||
DownButtonImage = *GetIconP("scrollbar_down_button"_XS8)->GetBest(!Daylight);
|
||||
}
|
||||
|
||||
//some help with embedded scroll
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
// Icon(const Icon&) = delete;
|
||||
XIcon& operator=(const XIcon&); // = delete;
|
||||
void GetEmbedded();
|
||||
const XImage& GetBest(bool night) const;
|
||||
XImage* GetBest(bool night, bool *free = nullptr);
|
||||
};
|
||||
|
||||
class XTheme
|
||||
@ -142,8 +142,10 @@ public:
|
||||
// const XImage& GetIcon(const char* Name);
|
||||
// const XImage& GetIcon(const CHAR16* Name);
|
||||
const XIcon& GetIcon(const XString8& Name); //get by name
|
||||
XIcon* GetIconP(const XString8& Name);
|
||||
const XIcon& GetIcon(INTN Id); //get by id
|
||||
const XIcon& GetIconAlt(INTN Id, INTN Alt); //if id not found
|
||||
XIcon* GetIconP(INTN Id); //not const
|
||||
XIcon& GetIconAlt(INTN Id, INTN Alt); //if id not found
|
||||
const XIcon& LoadOSIcon(const CHAR16* OSIconName); //TODO make XString provider
|
||||
const XIcon& LoadOSIcon(const XString8& Full);
|
||||
bool CheckNative(INTN Id);
|
||||
|
Loading…
Reference in New Issue
Block a user