mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
advance svg theme
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
parent
6aac20b758
commit
32d18af83e
@ -139,6 +139,8 @@ LogDataHub(IN EFI_GUID *TypeGuid,
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SetVariablesForOSX
|
||||
/** Installs our runtime services overrides. */
|
||||
/** Original runtime services. */
|
||||
|
@ -53,7 +53,7 @@ extern UINTN FrameTime;
|
||||
|
||||
textFaces textFace[4]; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id
|
||||
|
||||
EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image)
|
||||
EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage* Image, OUT void **SVGIcon)
|
||||
{
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
NSVGimage *SVGimage;
|
||||
@ -224,9 +224,13 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Ima
|
||||
|
||||
nsvgDeleteRasterizer(rast);
|
||||
// nsvg__deleteParser(p2);
|
||||
// nsvgDelete(p2->image);
|
||||
// nsvgDelete(p2->image); //somehow we can't delete them producing memory leaks
|
||||
// well, we will use them later
|
||||
*Image = NewImage;
|
||||
|
||||
if (SVGIcon) {
|
||||
*SVGIcon = (void*)IconImage;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -267,20 +271,20 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
}
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS8, &BigBack);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS8, &BigBack, NULL); //we should have a place for SVG background
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background"_XS8, &BigBack);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background"_XS8, &BigBack, NULL);
|
||||
}
|
||||
DBG(" Background parsed [%lld, %lld]\n", BigBack.GetWidth(), BigBack.GetHeight()); //Background parsed [1067, 133]
|
||||
// --- Make Banner
|
||||
Banner.setEmpty(); //for the case of theme switch
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS8, &Banner);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS8, &Banner, NULL);
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner"_XS8, &Banner);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner"_XS8, &Banner, NULL);
|
||||
}
|
||||
// DBG("Banner parsed\n");
|
||||
BanHeight = (int)(Banner.GetHeight() * Scale + 1.f);
|
||||
@ -292,11 +296,11 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
continue;
|
||||
}
|
||||
Icon* NewIcon = new Icon(i, false); //initialize without embedded
|
||||
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image);
|
||||
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
|
||||
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
|
||||
NewIcon->Native = !EFI_ERROR(Status);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight);
|
||||
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
|
||||
}
|
||||
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
|
||||
Icons.AddReference(NewIcon, true);
|
||||
@ -311,20 +315,20 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
for (INTN i = ICON_OTHER_OS; i < IconsNamesSize; ++i) {
|
||||
if (AsciiStrLen(IconsNames[i]) == 0) break;
|
||||
Icon* NewIcon = new Icon(i, false); //initialize without embedded
|
||||
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image);
|
||||
Status = ParseSVGXIcon(i, NewIcon->Name, &NewIcon->Image, &NewIcon->ImageSVG);
|
||||
// DBG("parse %s i=%lld status %s\n", NewIcon->Name.c_str(), i, strerror(Status));
|
||||
NewIcon->Native = !EFI_ERROR(Status);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight);
|
||||
ParseSVGXIcon(i, NewIcon->Name + "_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
|
||||
}
|
||||
Icons.AddReference(NewIcon, true);
|
||||
}
|
||||
|
||||
//selection for bootcampstyle
|
||||
Icon *NewIcon = new Icon(BUILTIN_ICON_SELECTION);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator"_XS8, &NewIcon->Image);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator"_XS8, &NewIcon->Image, &NewIcon->ImageSVG);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator_night"_XS8, &NewIcon->ImageNight);
|
||||
ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator_night"_XS8, &NewIcon->ImageNight, &NewIcon->ImageSVGnight);
|
||||
}
|
||||
Icons.AddReference(NewIcon, true);
|
||||
|
||||
@ -435,7 +439,7 @@ EFI_STATUS XTheme::LoadSvgFrame(INTN i, OUT XImage* XFrame)
|
||||
{
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
XString8 XFrameName = SPrintf("frame_%04lld", i+1);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_ANIME, XFrameName, XFrame);
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_ANIME, XFrameName, XFrame, NULL); //svg anime will be full redesigned
|
||||
if (EFI_ERROR(Status)) {
|
||||
DBG("frame '%s' not loaded, status=%s\n", XFrameName.c_str(), strerror(Status));
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ Icon::Icon(INTN Index, bool TakeEmbedded) : Image(), ImageNight()
|
||||
Id = Index;
|
||||
Name.setEmpty();
|
||||
Native = false;
|
||||
ImageSVG = nullptr;
|
||||
ImageSVGnight = nullptr;
|
||||
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index < IconsNamesSize) { //full table
|
||||
Name.takeValueFrom(IconsNames[Index]);
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ public:
|
||||
XImage Image;
|
||||
XImage ImageNight;
|
||||
bool Native;
|
||||
|
||||
void *ImageSVG; //NSVGimage*
|
||||
void *ImageSVGnight;
|
||||
|
||||
Icon(INTN Id, bool Embedded = false);
|
||||
~Icon();
|
||||
|
||||
@ -151,7 +153,7 @@ public:
|
||||
EFI_STATUS GetThemeTagSettings(void* DictPointer);
|
||||
void parseTheme(void* p, const char** dict); //in nano project
|
||||
EFI_STATUS ParseSVGXTheme(const CHAR8* buffer); // in VectorTheme
|
||||
EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image);
|
||||
EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image, void **SVGIcon);
|
||||
void* LoadTheme(const CHAR16 *TestTheme); //return TagPtr why?
|
||||
EFI_STATUS LoadSvgFrame(INTN i, OUT XImage* XFrame); // for animation
|
||||
|
||||
|
@ -52,6 +52,8 @@ extern "C" {
|
||||
#define NANOSVG_ALL_COLOR_KEYWORDS 1
|
||||
#define NSVG_RGBA(r, g, b, a) (((unsigned int)b) | ((unsigned int)g << 8) | ((unsigned int)r << 16) | ((unsigned int)a << 24))
|
||||
|
||||
#define kMaxIDLength 64
|
||||
#define kMaxTextLength 256
|
||||
|
||||
enum NSVGpaintType {
|
||||
NSVG_PAINT_NONE = 0,
|
||||
@ -91,7 +93,7 @@ enum NSVGflags {
|
||||
};
|
||||
*/
|
||||
typedef struct NSVGgradientLink {
|
||||
char id[64];
|
||||
char id[kMaxIDLength];
|
||||
float xform[6];
|
||||
} NSVGgradientLink;
|
||||
|
||||
@ -139,8 +141,6 @@ typedef struct NSVGclip
|
||||
char pad[7];
|
||||
} NSVGclip;
|
||||
|
||||
#define kMaxIDLength 64
|
||||
#define kMaxTextLength 256
|
||||
|
||||
typedef struct NSVGshape NSVGshape;
|
||||
|
||||
@ -194,7 +194,7 @@ typedef struct NSVGshape
|
||||
|
||||
typedef struct NSVGclipPath
|
||||
{
|
||||
char id[64]; // Unique id of this clip path (from SVG).
|
||||
char id[kMaxIDLength]; // Unique id of this clip path (from SVG).
|
||||
NSVGclipPathIndex index; // Unique internal index of this clip path.
|
||||
NSVGshape* shapes; // Linked list of shapes in this clip path.
|
||||
NSVGgroup* group; // Pointer to parent group or NULL
|
||||
|
@ -87,7 +87,7 @@ void nsvg_qsort(NSVGedge* Array, int Low, int High)
|
||||
{
|
||||
int i = Low, j = High;
|
||||
NSVGedge Temp;
|
||||
UINTN Size = sizeof(NSVGedge);
|
||||
// UINTN Size = sizeof(NSVGedge);
|
||||
int Imed;
|
||||
Imed = (Low + High) / 2; // Central element, just pointer
|
||||
float med = Array[Imed].y0;
|
||||
@ -98,9 +98,9 @@ void nsvg_qsort(NSVGedge* Array, int Low, int High)
|
||||
while (Array[j].y0 > med) j--;
|
||||
// Change
|
||||
if (i <= j) {
|
||||
memcpy(&Temp, &Array[i], Size);
|
||||
memcpy(&Array[i++], &Array[j], Size);
|
||||
memcpy(&Array[j--], &Temp, Size);
|
||||
memcpy(&Temp, &Array[i], sizeof(NSVGedge));
|
||||
memcpy(&Array[i++], &Array[j], sizeof(NSVGedge));
|
||||
memcpy(&Array[j--], &Temp, sizeof(NSVGedge));
|
||||
}
|
||||
}
|
||||
// FreePool(Temp);
|
||||
|
Loading…
Reference in New Issue
Block a user