mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-24 16:27:42 +01:00
introduce loadImage
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
0eb9528089
commit
5ed385d3fa
@ -111,7 +111,6 @@
|
|||||||
A5816DED24180F4D003BA66C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DEC24180F4C003BA66C /* panic.cpp */; };
|
A5816DED24180F4D003BA66C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DEC24180F4C003BA66C /* panic.cpp */; };
|
||||||
A5816DF024180F82003BA66C /* global_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DEE24180F81003BA66C /* global_test.cpp */; };
|
A5816DF024180F82003BA66C /* global_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DEE24180F81003BA66C /* global_test.cpp */; };
|
||||||
A5816DF22418101C003BA66C /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF12418101C003BA66C /* XStringWP.cpp */; };
|
A5816DF22418101C003BA66C /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF12418101C003BA66C /* XStringWP.cpp */; };
|
||||||
A5816DF424181023003BA66C /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF324181023003BA66C /* XStringWP.cpp */; };
|
|
||||||
A5816DF62418103A003BA66C /* menu_items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF52418103A003BA66C /* menu_items.cpp */; };
|
A5816DF62418103A003BA66C /* menu_items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF52418103A003BA66C /* menu_items.cpp */; };
|
||||||
A5816DF924181050003BA66C /* REFIT_MENU_SCREEN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF72418104F003BA66C /* REFIT_MENU_SCREEN.cpp */; };
|
A5816DF924181050003BA66C /* REFIT_MENU_SCREEN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5816DF72418104F003BA66C /* REFIT_MENU_SCREEN.cpp */; };
|
||||||
A59CB66921BC14AB0054A7CF /* SmbiosGen.c in Sources */ = {isa = PBXBuildFile; fileRef = A59CB66521BC14AA0054A7CF /* SmbiosGen.c */; };
|
A59CB66921BC14AB0054A7CF /* SmbiosGen.c in Sources */ = {isa = PBXBuildFile; fileRef = A59CB66521BC14AA0054A7CF /* SmbiosGen.c */; };
|
||||||
@ -2537,7 +2536,6 @@
|
|||||||
A5816DEE24180F81003BA66C /* global_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = global_test.cpp; sourceTree = "<group>"; };
|
A5816DEE24180F81003BA66C /* global_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = global_test.cpp; sourceTree = "<group>"; };
|
||||||
A5816DEF24180F82003BA66C /* global_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = "<group>"; };
|
A5816DEF24180F82003BA66C /* global_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = "<group>"; };
|
||||||
A5816DF12418101C003BA66C /* XStringWP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWP.cpp; sourceTree = "<group>"; };
|
A5816DF12418101C003BA66C /* XStringWP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWP.cpp; sourceTree = "<group>"; };
|
||||||
A5816DF324181023003BA66C /* XStringWP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWP.cpp; sourceTree = "<group>"; };
|
|
||||||
A5816DF52418103A003BA66C /* menu_items.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_items.cpp; sourceTree = "<group>"; };
|
A5816DF52418103A003BA66C /* menu_items.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_items.cpp; sourceTree = "<group>"; };
|
||||||
A5816DF72418104F003BA66C /* REFIT_MENU_SCREEN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = REFIT_MENU_SCREEN.cpp; sourceTree = "<group>"; };
|
A5816DF72418104F003BA66C /* REFIT_MENU_SCREEN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = REFIT_MENU_SCREEN.cpp; sourceTree = "<group>"; };
|
||||||
A5816DF82418104F003BA66C /* REFIT_MENU_SCREEN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REFIT_MENU_SCREEN.h; sourceTree = "<group>"; };
|
A5816DF82418104F003BA66C /* REFIT_MENU_SCREEN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = REFIT_MENU_SCREEN.h; sourceTree = "<group>"; };
|
||||||
@ -8272,7 +8270,6 @@
|
|||||||
A571C2722405749900B6A2C5 /* XStringWArray.cpp */,
|
A571C2722405749900B6A2C5 /* XStringWArray.cpp */,
|
||||||
A571C26F2405749900B6A2C5 /* XStringWArray.h */,
|
A571C26F2405749900B6A2C5 /* XStringWArray.h */,
|
||||||
A5816DF12418101C003BA66C /* XStringWP.cpp */,
|
A5816DF12418101C003BA66C /* XStringWP.cpp */,
|
||||||
A5816DF324181023003BA66C /* XStringWP.cpp */,
|
|
||||||
A571C2772405749900B6A2C5 /* XToolsCommon.cpp */,
|
A571C2772405749900B6A2C5 /* XToolsCommon.cpp */,
|
||||||
A571C2702405749900B6A2C5 /* XToolsCommon.h */,
|
A571C2702405749900B6A2C5 /* XToolsCommon.h */,
|
||||||
A57CF7B32419F4F8006DE51E /* XUINTN.cpp */,
|
A57CF7B32419F4F8006DE51E /* XUINTN.cpp */,
|
||||||
@ -16668,7 +16665,6 @@
|
|||||||
A5456CFC23FC5AB8000BF18C /* egemb_font.cpp in Sources */,
|
A5456CFC23FC5AB8000BF18C /* egemb_font.cpp in Sources */,
|
||||||
A5AAFB66237F13B3009CD413 /* AmlString.c in Sources */,
|
A5AAFB66237F13B3009CD413 /* AmlString.c in Sources */,
|
||||||
A5AA05F0237F13C1009CD413 /* SetMem.nasm in Sources */,
|
A5AA05F0237F13C1009CD413 /* SetMem.nasm in Sources */,
|
||||||
A5816DF424181023003BA66C /* XStringWP.cpp in Sources */,
|
|
||||||
A5AA06FE237F13C2009CD413 /* IoFifoSev.nasm in Sources */,
|
A5AA06FE237F13C2009CD413 /* IoFifoSev.nasm in Sources */,
|
||||||
A5AA0547237F13C1009CD413 /* WriteDr1.c in Sources */,
|
A5AA0547237F13C1009CD413 /* WriteDr1.c in Sources */,
|
||||||
A5AAFD4C237F13B4009CD413 /* SmmSmiHandlerProfileLib.c in Sources */,
|
A5AAFD4C237F13B4009CD413 /* SmmSmiHandlerProfileLib.c in Sources */,
|
||||||
|
@ -281,6 +281,8 @@ void XImage::FlipRB(bool WantAlpha)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The function converted plain array into XImage object
|
* The function converted plain array into XImage object
|
||||||
|
* Error = 0 - Success
|
||||||
|
* Error = 28 - invalid signature
|
||||||
*/
|
*/
|
||||||
unsigned XImage::FromPNG(const UINT8 * Data, UINTN Length)
|
unsigned XImage::FromPNG(const UINT8 * Data, UINTN Length)
|
||||||
{
|
{
|
||||||
@ -440,18 +442,13 @@ void XImage::DrawWithoutCompose(INTN x, INTN y, UINTN width, UINTN height)
|
|||||||
void XImage::Draw(INTN x, INTN y, float scale)
|
void XImage::Draw(INTN x, INTN y, float scale)
|
||||||
{
|
{
|
||||||
//prepare images
|
//prepare images
|
||||||
// DBG("1\n");
|
|
||||||
XImage Top(*this, scale);
|
XImage Top(*this, scale);
|
||||||
// DBG("2\n");
|
|
||||||
XImage Background(Width, Height);
|
XImage Background(Width, Height);
|
||||||
// DBG("3\n");
|
|
||||||
Background.GetArea(x, y, Width, Height);
|
Background.GetArea(x, y, Width, Height);
|
||||||
// DBG("4\n");
|
|
||||||
Background.Compose(0, 0, Top, true);
|
Background.Compose(0, 0, Top, true);
|
||||||
// DBG("5\n");
|
|
||||||
UINTN AreaWidth = (x + Width > (UINTN)UGAWidth) ? (UGAWidth - x) : Width;
|
UINTN AreaWidth = (x + Width > (UINTN)UGAWidth) ? (UGAWidth - x) : Width;
|
||||||
UINTN AreaHeight = (y + Height > (UINTN)UGAHeight) ? (UGAHeight - y) : Height;
|
UINTN AreaHeight = (y + Height > (UINTN)UGAHeight) ? (UGAHeight - y) : Height;
|
||||||
// DBG("area=%d,%d\n", AreaWidth, AreaHeight);
|
|
||||||
// prepare protocols
|
// prepare protocols
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_GUID UgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
|
EFI_GUID UgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
|
||||||
@ -477,3 +474,33 @@ void XImage::Draw(INTN x, INTN y, float scale)
|
|||||||
0, 0, x, y, AreaWidth, AreaHeight, 0);
|
0, 0, x, y, AreaWidth, AreaHeight, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFI_STATUS XImage::LoadImage(EFI_FILE *BaseDir, XStringW& FileName)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||||
|
UINT8 *FileData = NULL;
|
||||||
|
UINTN FileDataLength = 0;
|
||||||
|
|
||||||
|
if (TypeSVG) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BaseDir == NULL || FileName.isEmpty())
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
|
||||||
|
// load file
|
||||||
|
Status = egLoadFile(BaseDir, FileName.data(), &FileData, &FileDataLength);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
// decode it
|
||||||
|
unsigned ret = FromPNG(FileData, FileDataLength);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
DBG("%s not decoded\n", FileName);
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
FreePool(FileData);
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
void Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color = { 0, 0, 0, 0 });
|
void Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color = { 0, 0, 0, 0 });
|
||||||
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, const EgRect& Rect);
|
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, const EgRect& Rect);
|
||||||
void CopyScaled(const XImage& Image, float scale);
|
void CopyScaled(const XImage& Image, float scale);
|
||||||
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we can Back.Draw(...) + Top.Draw(...)
|
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we often can Back.Draw(...) + Top.Draw(...)
|
||||||
void FlipRB(bool WantAlpha);
|
void FlipRB(bool WantAlpha);
|
||||||
unsigned FromPNG(const UINT8 * Data, UINTN Lenght);
|
unsigned FromPNG(const UINT8 * Data, UINTN Lenght);
|
||||||
unsigned ToPNG(UINT8** Data, UINTN& OutSize);
|
unsigned ToPNG(UINT8** Data, UINTN& OutSize);
|
||||||
@ -90,6 +90,8 @@ public:
|
|||||||
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
|
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
|
||||||
void Draw(INTN x, INTN y, float scale);
|
void Draw(INTN x, INTN y, float scale);
|
||||||
void DrawWithoutCompose(INTN x, INTN y, UINTN width = 0, UINTN height = 0);
|
void DrawWithoutCompose(INTN x, INTN y, UINTN width = 0, UINTN height = 0);
|
||||||
|
|
||||||
|
EFI_STATUS LoadImage(EFI_FILE *Dir, XStringW FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__XSTRINGW_H__
|
#endif //__XSTRINGW_H__
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* a class to keep definitions for all theme settings
|
* a class to keep definitions for all theme settings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <Protocol/GraphicsOutput.h>
|
||||||
|
}
|
||||||
|
|
||||||
#include "libegint.h"
|
#include "libegint.h"
|
||||||
#include "XTheme.h"
|
#include "XTheme.h"
|
||||||
|
|
||||||
@ -186,7 +191,7 @@ void XTheme::AddIcon(Icon& NewIcon)
|
|||||||
|
|
||||||
|
|
||||||
void XTheme::FillByEmbedded()
|
void XTheme::FillByEmbedded()
|
||||||
{
|
{
|
||||||
DEC_BUILTIN_ICON2(0, emb_func_about, emb_dark_func_about)
|
DEC_BUILTIN_ICON2(0, emb_func_about, emb_dark_func_about)
|
||||||
DEC_BUILTIN_ICON2(1, emb_func_options, emb_dark_func_options)
|
DEC_BUILTIN_ICON2(1, emb_func_options, emb_dark_func_options)
|
||||||
DEC_BUILTIN_ICON2(2, emb_func_clover, emb_dark_func_clover)
|
DEC_BUILTIN_ICON2(2, emb_func_clover, emb_dark_func_clover)
|
||||||
@ -206,8 +211,285 @@ void XTheme::FillByEmbedded()
|
|||||||
DEC_BUILTIN_ICON(19, emb_vol_internal_ntfs)
|
DEC_BUILTIN_ICON(19, emb_vol_internal_ntfs)
|
||||||
DEC_BUILTIN_ICON(20, emb_vol_internal_ext)
|
DEC_BUILTIN_ICON(20, emb_vol_internal_ext)
|
||||||
DEC_BUILTIN_ICON(21, emb_vol_internal_recovery)
|
DEC_BUILTIN_ICON(21, emb_vol_internal_recovery)
|
||||||
DEC_BUILTIN_ICON(22, emb_logo, emb_dark_logo)
|
DEC_BUILTIN_ICON2(22, emb_logo, emb_dark_logo)
|
||||||
DEC_BUILTIN_ICON2(23, emb_selection_small, emb_dark_selection_small)
|
DEC_BUILTIN_ICON2(23, emb_selection_small, emb_dark_selection_small)
|
||||||
DEC_BUILTIN_ICON2(24, emb_selection_big, emb_dark_selection_big)
|
DEC_BUILTIN_ICON2(24, emb_selection_big, emb_dark_selection_big)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XTheme::ClearScreen() //and restore background and banner
|
||||||
|
{
|
||||||
|
if (BanHeight < 2) {
|
||||||
|
BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1);
|
||||||
|
}
|
||||||
|
if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) {
|
||||||
|
//Banner image prepared before
|
||||||
|
if (!Banner.isEmpty()) {
|
||||||
|
BannerPlace.Width = Banner->Width;
|
||||||
|
BannerPlace.Height = (BanHeight >= Banner->Height) ? (INTN)Banner->Height : BanHeight;
|
||||||
|
BannerPlace.XPos = BannerPosX;
|
||||||
|
BannerPlace.YPos = BannerPosY;
|
||||||
|
if (!TypeSVG) {
|
||||||
|
// Check if new style placement value was used for banner in theme.plist
|
||||||
|
|
||||||
|
if ((BannerPosX >=0 && BannerPosX <=1000) && (BannerPosY >=0 && BannerPosY <=1000)) {
|
||||||
|
// Check if screen size being used is different from theme origination size.
|
||||||
|
// If yes, then recalculate the placement % value.
|
||||||
|
// This is necessary because screen can be a different size, but banner is not scaled.
|
||||||
|
BannerPlace.XPos = HybridRepositioning(BannerEdgeHorizontal, BannerPosX, BannerPlace.Width, UGAWidth, ThemeDesignWidth );
|
||||||
|
BannerPlace.YPos = HybridRepositioning(BannerEdgeVertical, BannerPosY, BannerPlace.Height, UGAHeight, ThemeDesignHeight);
|
||||||
|
// Check if banner is required to be nudged.
|
||||||
|
BannerPlace.XPos = CalculateNudgePosition(BannerPlace.XPos, BannerNudgeX, Banner->Width, UGAWidth);
|
||||||
|
BannerPlace.YPos = CalculateNudgePosition(BannerPlace.YPos, BannerNudgeY, Banner->Height, UGAHeight);
|
||||||
|
// DBG("banner position new style\n");
|
||||||
|
} else {
|
||||||
|
// Use rEFIt default (no placement values speicifed)
|
||||||
|
BannerPlace.XPos = (UGAWidth - Banner->Width) >> 1;
|
||||||
|
BannerPlace.YPos = (BanHeight >= Banner->Height) ? (BanHeight - Banner->Height) : 0;
|
||||||
|
// DBG("banner position old style\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Then prepare Background from BigBack
|
||||||
|
if (!Background.isEmpty() && (Background.GetWidth() != UGAWidth || Background.GetHeight() != UGAHeight)) {
|
||||||
|
// Resolution changed
|
||||||
|
Background.setEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Background.isEmpty()) {
|
||||||
|
Background = XImage(UGAWidth, UGAHeight);
|
||||||
|
Background.Fill(&BlueBackgroundPixel);
|
||||||
|
}
|
||||||
|
if (!BigBack.isEmpty()) {
|
||||||
|
switch (BackgroundScale) {
|
||||||
|
case imScale:
|
||||||
|
Background.CopyScaled(BigBack, Scale);
|
||||||
|
break;
|
||||||
|
case imCrop:
|
||||||
|
INTN x = UGAWidth - BigBack.GetWidth();
|
||||||
|
INTN x1, x2, y1, y2;
|
||||||
|
if (x >= 0) {
|
||||||
|
x1 = x >> 1;
|
||||||
|
x2 = 0;
|
||||||
|
x = BigBack.GetWidth();
|
||||||
|
} else {
|
||||||
|
x1 = 0;
|
||||||
|
x2 = (-x) >> 1;
|
||||||
|
x = UGAWidth;
|
||||||
|
}
|
||||||
|
INTN y = UGAHeight - BigBack.GetHeight();
|
||||||
|
if (y >= 0) {
|
||||||
|
y1 = y >> 1;
|
||||||
|
y2 = 0;
|
||||||
|
y = BigBack.GetHeight();
|
||||||
|
} else {
|
||||||
|
y1 = 0;
|
||||||
|
y2 = (-y) >> 1;
|
||||||
|
y = UGAHeight;
|
||||||
|
}
|
||||||
|
//the function can be in XImage class
|
||||||
|
/* egRawCopy(Background.GetPixelPtr(x1, y1),
|
||||||
|
BigBack.GetPixelPtr(x2, y2),
|
||||||
|
x, y, Background.GetWidth(), BigBack.GetWidth()); */
|
||||||
|
Background.Compose(x, y, BigBack, true);
|
||||||
|
break;
|
||||||
|
case imTile:
|
||||||
|
x = (BigBack.GetWidth() * ((UGAWidth - 1) / BigBack.GetWidth() + 1) - UGAWidth) >> 1;
|
||||||
|
y = (BigBack.GetHeight() * ((UGAHeight - 1) / BigBack.GetHeight() + 1) - UGAHeight) >> 1;
|
||||||
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* p1 = Background.GetPixelPtr(0, 0)
|
||||||
|
for (j = 0; j < UGAHeight; j++) {
|
||||||
|
for (i = 0; i < UGAWidth; i++) {
|
||||||
|
*p1++ = BigBack.GetPixel((i + x) % BigBack.GetWidth(), (j + y) % BigBack.GetHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case imNone:
|
||||||
|
default:
|
||||||
|
// already scaled
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Background.Draw(0, 0, 1.f);
|
||||||
|
//then draw banner
|
||||||
|
if (Banner) {
|
||||||
|
Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void XTheme::InitSelection()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!AllowGraphicsMode)
|
||||||
|
return;
|
||||||
|
SelectionBackgroundPixel.r = (SelectionColor >> 24) & 0xFF;
|
||||||
|
SelectionBackgroundPixel.g = (SelectionColor >> 16) & 0xFF;
|
||||||
|
SelectionBackgroundPixel.b = (SelectionColor >> 8) & 0xFF;
|
||||||
|
SelectionBackgroundPixel.a = (SelectionColor >> 0) & 0xFF;
|
||||||
|
|
||||||
|
if (!SelectionImages[0].isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// load small selection image
|
||||||
|
if (GlobalConfig.SelectionSmallFileName != NULL){
|
||||||
|
SelectionImages[2].LoadImage(ThemeDir, SelectionSmallFileName.data());
|
||||||
|
}
|
||||||
|
if (SelectionImages[2].isEmpty()){
|
||||||
|
// SelectionImages[2] = BuiltinIcon(BUILTIN_SELECTION_SMALL);
|
||||||
|
// SelectionImages[2]->HasAlpha = FALSE; // support transparensy for selection icons
|
||||||
|
SelectionImages[2].FromPNG(ACCESS_EMB_DATA(emb_selection_small), ACCESS_EMB_SIZE(emb_selection_small));
|
||||||
|
// CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); //why???
|
||||||
|
}
|
||||||
|
//cut or extend the image by Compose
|
||||||
|
/* SelectionImages[2] = egEnsureImageSize(SelectionImages[2],
|
||||||
|
row1TileSize, row1TileSize, &MenuBackgroundPixel);
|
||||||
|
if (SelectionImages[2] == NULL) {
|
||||||
|
return;
|
||||||
|
} */
|
||||||
|
//TODO - to be continued
|
||||||
|
// load big selection image
|
||||||
|
if (!GlobalConfig.TypeSVG && GlobalConfig.SelectionBigFileName != NULL) {
|
||||||
|
SelectionImages[0] = egLoadImage(ThemeDir, GlobalConfig.SelectionBigFileName, FALSE);
|
||||||
|
SelectionImages[0] = egEnsureImageSize(SelectionImages[0],
|
||||||
|
row0TileSize, row0TileSize,
|
||||||
|
&MenuBackgroundPixel);
|
||||||
|
}
|
||||||
|
if (SelectionImages[0] == NULL) {
|
||||||
|
// calculate big selection image from small one
|
||||||
|
SelectionImages[0] = BuiltinIcon(BUILTIN_SELECTION_BIG);
|
||||||
|
SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
|
||||||
|
CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL));
|
||||||
|
if (SelectionImages[0] == NULL) {
|
||||||
|
egFreeImage(SelectionImages[2]);
|
||||||
|
SelectionImages[2] = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (GlobalConfig.SelectionOnTop) {
|
||||||
|
SelectionImages[0]->HasAlpha = TRUE;
|
||||||
|
SelectionImages[2]->HasAlpha = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BootCampStyle indicator image
|
||||||
|
if (GlobalConfig.BootCampStyle) {
|
||||||
|
// load indicator selection image
|
||||||
|
if (GlobalConfig.SelectionIndicatorName != NULL) {
|
||||||
|
SelectionImages[4] = egLoadImage(ThemeDir, GlobalConfig.SelectionIndicatorName, TRUE);
|
||||||
|
}
|
||||||
|
if (!SelectionImages[4]) {
|
||||||
|
SelectionImages[4] = egDecodePNG(ACCESS_EMB_DATA(emb_selection_indicator), ACCESS_EMB_SIZE(emb_selection_indicator), TRUE);
|
||||||
|
|
||||||
|
}
|
||||||
|
INTN ScaledIndicatorSize = (INTN)(INDICATOR_SIZE * GlobalConfig.Scale);
|
||||||
|
SelectionImages[4] = egEnsureImageSize(SelectionImages[4], ScaledIndicatorSize, ScaledIndicatorSize, &MenuBackgroundPixel);
|
||||||
|
if (!SelectionImages[4]) {
|
||||||
|
SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
|
||||||
|
TRUE, &StdBackgroundPixel);
|
||||||
|
|
||||||
|
}
|
||||||
|
SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
|
||||||
|
TRUE, &MenuBackgroundPixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Button & radio, or any other next icons with builtin icon as fallback should synced to:
|
||||||
|
- BUILTIN_ICON_* in lib.h
|
||||||
|
- BuiltinIconTable in icns.c
|
||||||
|
- Data in egemb_icons.h / scroll_images.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Radio buttons
|
||||||
|
//it was a nonsense egLoadImage is just inluded into egLoadIcon.
|
||||||
|
// will be corrected with XTheme support
|
||||||
|
//the procedure loadIcon should also check embedded icons
|
||||||
|
#if USE_XTHEME
|
||||||
|
Button[0] = Theme.loadIcon("radio_button.png");
|
||||||
|
Button[1] = Theme.loadIcon("radio_button_selected.png");
|
||||||
|
Button[2] = Theme.loadIcon("checkbox.png");
|
||||||
|
Button[3] = Theme.loadIcon("checkbox_checked.png");
|
||||||
|
#else
|
||||||
|
Buttons[0] = egLoadImage(ThemeDir, GetIconsExt(L"radio_button", L"png"), TRUE); //memory leak
|
||||||
|
Buttons[1] = egLoadImage(ThemeDir, GetIconsExt(L"radio_button_selected", L"png"), TRUE);
|
||||||
|
if (!Buttons[0]) {
|
||||||
|
Buttons[0] = egLoadIcon(ThemeDir, L"radio_button.png", 48);
|
||||||
|
}
|
||||||
|
if (!Buttons[0]) {
|
||||||
|
Buttons[0] = egDecodePNG(ACCESS_EMB_DATA(emb_radio_button), ACCESS_EMB_SIZE(emb_radio_button), TRUE);
|
||||||
|
}
|
||||||
|
if (!Buttons[1]) {
|
||||||
|
Buttons[1] = egLoadIcon(ThemeDir, L"radio_button_selected.png", 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Buttons[1]) {
|
||||||
|
Buttons[1] = egDecodePNG(ACCESS_EMB_DATA(emb_radio_button_selected), ACCESS_EMB_SIZE(emb_radio_button_selected), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checkbox
|
||||||
|
Buttons[2] = egLoadImage(ThemeDir, GetIconsExt(L"checkbox", L"png"), TRUE);
|
||||||
|
Buttons[3] = egLoadImage(ThemeDir, GetIconsExt(L"checkbox_checked", L"png"), TRUE);
|
||||||
|
if (!Buttons[2]) {
|
||||||
|
// DBG("egLoadIcon checkbox\n");
|
||||||
|
Buttons[2] = egLoadIcon(ThemeDir, L"checkbox.png", 48);
|
||||||
|
}
|
||||||
|
if (!Buttons[3]) {
|
||||||
|
// DBG("egLoadIcon checkbox_checked\n");
|
||||||
|
Buttons[3] = egLoadIcon(ThemeDir, L"checkbox_checked.png", 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Buttons[2]) {
|
||||||
|
// DBG("embedded checkbox\n");
|
||||||
|
Buttons[2] = egDecodePNG(ACCESS_EMB_DATA(emb_checkbox), ACCESS_EMB_SIZE(emb_checkbox), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Buttons[3]) {
|
||||||
|
// DBG("embedded checkbox_checked\n");
|
||||||
|
Buttons[3] = egDecodePNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked), TRUE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// non-selected background images
|
||||||
|
#if USE_XTHEME
|
||||||
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL& BackgroundPixel = StdBackgroundPixel;
|
||||||
|
if (Theme.SelectionBigFileName != NULL) {
|
||||||
|
BackgroundPixel = &MenuBackgroundPixel;
|
||||||
|
} else if (GlobalConfig.DarkEmbedded || GlobalConfig.TypeSVG) {
|
||||||
|
BackgroundPixel = &DarkEmbeddedBackgroundPixel;
|
||||||
|
} else {
|
||||||
|
BackgroundPixel = &StdBackgroundPixel;
|
||||||
|
}
|
||||||
|
SelectionImages[1] = XImage(row0TileSize, row0TileSize, BackgroundPixel);
|
||||||
|
SelectionImages[3] = XImage(row1TileSize, row1TileSize, BackgroundPixel);
|
||||||
|
#else
|
||||||
|
//totally wrong
|
||||||
|
if (GlobalConfig.SelectionBigFileName != NULL) {
|
||||||
|
SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize,
|
||||||
|
TRUE, &MenuBackgroundPixel);
|
||||||
|
SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize,
|
||||||
|
TRUE, &MenuBackgroundPixel);
|
||||||
|
} else { // using embedded theme (this is an assumption but a better check is required)
|
||||||
|
EG_PIXEL BackgroundPixel;
|
||||||
|
if (GlobalConfig.DarkEmbedded || GlobalConfig.TypeSVG) {
|
||||||
|
BackgroundPixel = DarkEmbeddedBackgroundPixel;
|
||||||
|
BackgroundPixel.a = 0x00;
|
||||||
|
} else {
|
||||||
|
BackgroundPixel = StdBackgroundPixel;
|
||||||
|
BackgroundPixel.a = 0xff;
|
||||||
|
}
|
||||||
|
if (GlobalConfig.DarkEmbedded) { //nonsense then equal else
|
||||||
|
SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize,
|
||||||
|
TRUE, &BackgroundPixel);
|
||||||
|
SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize,
|
||||||
|
TRUE, &BackgroundPixel);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SelectionImages[1] = egCreateFilledImage(row0TileSize, row0TileSize,
|
||||||
|
TRUE, &BackgroundPixel); //&StdBackgroundPixel);
|
||||||
|
SelectionImages[3] = egCreateFilledImage(row1TileSize, row1TileSize,
|
||||||
|
TRUE, &BackgroundPixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// DBG("selections inited\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -24,6 +24,7 @@ class XTheme
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XObjArray<Icon> Icons;
|
XObjArray<Icon> Icons;
|
||||||
|
EFI_FILE *ThemeDir;
|
||||||
|
|
||||||
UINTN DisableFlags;
|
UINTN DisableFlags;
|
||||||
UINTN HideBadges;
|
UINTN HideBadges;
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
XImage Background; //Background and Banner will not be in array as they live own life
|
XImage Background; //Background and Banner will not be in array as they live own life
|
||||||
XImage BigBack; //it size is not equal to screen size will be scaled or cropped
|
XImage BigBack; //it size is not equal to screen size will be scaled or cropped
|
||||||
XImage Banner; //same as logo in the array, make a link?
|
XImage Banner; //same as logo in the array, make a link?
|
||||||
|
XImage SelectionImages[6];
|
||||||
|
|
||||||
//fill the theme
|
//fill the theme
|
||||||
XImage& GetIcon(XStringW& Name, BOOLEAN Night); //get by name
|
XImage& GetIcon(XStringW& Name, BOOLEAN Night); //get by name
|
||||||
@ -90,7 +92,8 @@ public:
|
|||||||
|
|
||||||
//screen operations
|
//screen operations
|
||||||
void ClearScreen();
|
void ClearScreen();
|
||||||
VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height);
|
void FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height);
|
||||||
|
void InitSelection();
|
||||||
|
|
||||||
XTheme(); //default constructor
|
XTheme(); //default constructor
|
||||||
~XTheme();
|
~XTheme();
|
||||||
|
@ -232,8 +232,8 @@ typedef struct {
|
|||||||
|
|
||||||
VOID egInitScreen(IN BOOLEAN SetMaxResolution);
|
VOID egInitScreen(IN BOOLEAN SetMaxResolution);
|
||||||
VOID egDumpGOPVideoModes(VOID);
|
VOID egDumpGOPVideoModes(VOID);
|
||||||
EFI_STATUS egSetScreenResolution(IN CHAR16 *WidthHeight);
|
//EFI_STATUS egSetScreenResolution(IN CHAR16 *WidthHeight);
|
||||||
EFI_STATUS egSetMaxResolution(VOID);
|
//EFI_STATUS egSetMaxResolution(VOID);
|
||||||
EFI_STATUS egSetMode(INT32 Next);
|
EFI_STATUS egSetMode(INT32 Next);
|
||||||
|
|
||||||
VOID egGetScreenSize(OUT INTN *ScreenWidth, OUT INTN *ScreenHeight);
|
VOID egGetScreenSize(OUT INTN *ScreenWidth, OUT INTN *ScreenHeight);
|
||||||
|
@ -360,7 +360,7 @@ VOID egInitScreen(IN BOOLEAN SetMaxResolution)
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 Width, Height, Depth, RefreshRate;
|
UINT32 Width, Height, Depth, RefreshRate;
|
||||||
CHAR16 *Resolution;
|
// CHAR16 *Resolution;
|
||||||
|
|
||||||
// get protocols
|
// get protocols
|
||||||
Status = EfiLibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **) &ConsoleControl);
|
Status = EfiLibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **) &ConsoleControl);
|
||||||
@ -385,10 +385,11 @@ VOID egInitScreen(IN BOOLEAN SetMaxResolution)
|
|||||||
|
|
||||||
// if it not the first run, just restore resolution
|
// if it not the first run, just restore resolution
|
||||||
if (egScreenWidth != 0 && egScreenHeight != 0) {
|
if (egScreenWidth != 0 && egScreenHeight != 0) {
|
||||||
Resolution = PoolPrint(L"%dx%d",egScreenWidth,egScreenHeight);
|
// Resolution = PoolPrint(L"%dx%d",egScreenWidth,egScreenHeight);
|
||||||
|
XStringW Resolution = WPrintf("%lux%lu", egScreenWidth, egScreenHeight);
|
||||||
if (Resolution) {
|
if (Resolution) {
|
||||||
Status = egSetScreenResolution(Resolution);
|
Status = egSetScreenResolution(Resolution.data());
|
||||||
FreePool(Resolution);
|
// FreePool(Resolution);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1950,7 +1950,7 @@ VOID InitSelection(VOID)
|
|||||||
#endif
|
#endif
|
||||||
// non-selected background images
|
// non-selected background images
|
||||||
#if USE_XTHEME
|
#if USE_XTHEME
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL& BackgroundPixel;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL& BackgroundPixel = StdBackgroundPixel;
|
||||||
if (Theme.SelectionBigFileName != NULL) {
|
if (Theme.SelectionBigFileName != NULL) {
|
||||||
BackgroundPixel = &MenuBackgroundPixel;
|
BackgroundPixel = &MenuBackgroundPixel;
|
||||||
} else if (GlobalConfig.DarkEmbedded || GlobalConfig.TypeSVG) {
|
} else if (GlobalConfig.DarkEmbedded || GlobalConfig.TypeSVG) {
|
||||||
|
@ -415,109 +415,7 @@ typedef struct {
|
|||||||
//same as EgRect but INTN <-> UINTN
|
//same as EgRect but INTN <-> UINTN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if USE_XTHEME
|
|
||||||
VOID XTheme::ClearScreen()
|
|
||||||
{
|
|
||||||
if (BanHeight < 2) {
|
|
||||||
BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1);
|
|
||||||
}
|
|
||||||
if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) {
|
|
||||||
//Banner image prepared before
|
|
||||||
if (!Banner.isEmpty()) {
|
|
||||||
BannerPlace.Width = Banner->Width;
|
|
||||||
BannerPlace.Height = (BanHeight >= Banner->Height) ? (INTN)Banner->Height : BanHeight;
|
|
||||||
BannerPlace.XPos = BannerPosX;
|
|
||||||
BannerPlace.YPos = BannerPosY;
|
|
||||||
if (!TypeSVG) {
|
|
||||||
// Check if new style placement value was used for banner in theme.plist
|
|
||||||
|
|
||||||
if ((BannerPosX >=0 && BannerPosX <=1000) && (BannerPosY >=0 && BannerPosY <=1000)) {
|
|
||||||
// Check if screen size being used is different from theme origination size.
|
|
||||||
// If yes, then recalculate the placement % value.
|
|
||||||
// This is necessary because screen can be a different size, but banner is not scaled.
|
|
||||||
BannerPlace.XPos = HybridRepositioning(BannerEdgeHorizontal, BannerPosX, BannerPlace.Width, UGAWidth, ThemeDesignWidth );
|
|
||||||
BannerPlace.YPos = HybridRepositioning(BannerEdgeVertical, BannerPosY, BannerPlace.Height, UGAHeight, ThemeDesignHeight);
|
|
||||||
// Check if banner is required to be nudged.
|
|
||||||
BannerPlace.XPos = CalculateNudgePosition(BannerPlace.XPos, BannerNudgeX, Banner->Width, UGAWidth);
|
|
||||||
BannerPlace.YPos = CalculateNudgePosition(BannerPlace.YPos, BannerNudgeY, Banner->Height, UGAHeight);
|
|
||||||
// DBG("banner position new style\n");
|
|
||||||
} else {
|
|
||||||
// Use rEFIt default (no placement values speicifed)
|
|
||||||
BannerPlace.XPos = (UGAWidth - Banner->Width) >> 1;
|
|
||||||
BannerPlace.YPos = (BanHeight >= Banner->Height) ? (BanHeight - Banner->Height) : 0;
|
|
||||||
// DBG("banner position old style\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Then prepare Background from BigBack
|
|
||||||
if (!Background.isEmpty() && (Background.GetWidth() != UGAWidth || Background.GetHeight() != UGAHeight)) {
|
|
||||||
// Resolution changed
|
|
||||||
Background.setEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Background.isEmpty()) {
|
|
||||||
Background = XImage(UGAWidth, UGAHeight);
|
|
||||||
Background.Fill(&BlueBackgroundPixel);
|
|
||||||
}
|
|
||||||
if (!BigBack.isEmpty()) {
|
|
||||||
switch (BackgroundScale) {
|
|
||||||
case imScale:
|
|
||||||
Background.CopyScaled(BigBack, Scale);
|
|
||||||
break;
|
|
||||||
case imCrop:
|
|
||||||
x = UGAWidth - BigBack.GetWidth();
|
|
||||||
if (x >= 0) {
|
|
||||||
x1 = x >> 1;
|
|
||||||
x2 = 0;
|
|
||||||
x = BigBack.GetWidth();
|
|
||||||
} else {
|
|
||||||
x1 = 0;
|
|
||||||
x2 = (-x) >> 1;
|
|
||||||
x = UGAWidth;
|
|
||||||
}
|
|
||||||
y = UGAHeight - BigBack.GetHeight();
|
|
||||||
if (y >= 0) {
|
|
||||||
y1 = y >> 1;
|
|
||||||
y2 = 0;
|
|
||||||
y = BigBack.GetHeight();
|
|
||||||
} else {
|
|
||||||
y1 = 0;
|
|
||||||
y2 = (-y) >> 1;
|
|
||||||
y = UGAHeight;
|
|
||||||
}
|
|
||||||
//the function can be in XImage class
|
|
||||||
egRawCopy(Background.GetPixelPtr(x1, y1),
|
|
||||||
BigBack.GetPixelPtr(x2, y2),
|
|
||||||
x, y, Background.GetWidth(), BigBack.GetWidth());
|
|
||||||
break;
|
|
||||||
case imTile:
|
|
||||||
x = (BigBack.GetWidth() * ((UGAWidth - 1) / BigBack.GetWidth() + 1) - UGAWidth) >> 1;
|
|
||||||
y = (BigBack.GetHeight() * ((UGAHeight - 1) / BigBack.GetHeight() + 1) - UGAHeight) >> 1;
|
|
||||||
p1 = Background.GetPixelPtr(0, 0)
|
|
||||||
for (j = 0; j < UGAHeight; j++) {
|
|
||||||
// y2 = ((j + y) % BigBack.GetHeight()) * BigBack.GetWidth();
|
|
||||||
for (i = 0; i < UGAWidth; i++) {
|
|
||||||
*p1++ = BigBack.GetPixel((i + x) % BigBack.GetWidth(), (j + y) % BigBack.GetHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case imNone:
|
|
||||||
default:
|
|
||||||
// already scaled
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Background.Draw(0, 0, 1.f);
|
|
||||||
//then draw banner
|
|
||||||
if (Banner) {
|
|
||||||
Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
VOID BltClearScreen() //ShowBanner always TRUE. Called from line 400
|
VOID BltClearScreen() //ShowBanner always TRUE. Called from line 400
|
||||||
{
|
{
|
||||||
EG_PIXEL *p1;
|
EG_PIXEL *p1;
|
||||||
@ -691,7 +589,7 @@ VOID BltClearScreen() //ShowBanner always TRUE. Called from line 400
|
|||||||
InputBackgroundPixel.a = (MenuBackgroundPixel.a + 0) & 0xFF;
|
InputBackgroundPixel.a = (MenuBackgroundPixel.a + 0) & 0xFF;
|
||||||
GraphicsScreenDirty = FALSE;
|
GraphicsScreenDirty = FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
|
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
|
||||||
{
|
{
|
||||||
if (!Image) {
|
if (!Image) {
|
||||||
|
Loading…
Reference in New Issue
Block a user