diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 91bddecbe..696370b3c 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -4884,7 +4884,12 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time) ThemeDict = LoadTheme (TestTheme); if (ThemeDict != NULL) { DBG ("special theme %ls found and %ls parsed\n", TestTheme, CONFIG_THEME_FILENAME); - ThemeX.Theme.takeValueFrom(TestTheme); +// ThemeX.Theme.takeValueFrom(TestTheme); + if (GlobalConfig.Theme) { + FreePool (GlobalConfig.Theme); + } + GlobalConfig.Theme = TestTheme; + } else { // special theme not loaded DBG ("special theme %ls not found, skipping\n", TestTheme/*, CONFIG_THEME_FILENAME*/); FreePool (TestTheme); @@ -4909,10 +4914,14 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time) ThemeDict = LoadTheme (TestTheme); if (ThemeDict != NULL) { DBG ("theme %s defined in NVRAM found and %ls parsed\n", ChosenTheme, CONFIG_THEME_FILENAME); - ThemeX.Theme.takeValueFrom(TestTheme); +// ThemeX.Theme.takeValueFrom(TestTheme); + if (GlobalConfig.Theme) { + FreePool (GlobalConfig.Theme); + } + GlobalConfig.Theme = TestTheme; } else { // theme from nvram not loaded - if (!ThemeX.Theme.isEmpty()) { - DBG ("theme %s chosen from nvram is absent, using theme defined in config: %ls\n", ChosenTheme, ThemeX.Theme.data()); + if (GlobalConfig.Theme) { + DBG ("theme %s chosen from nvram is absent, using theme defined in config: %ls\n", ChosenTheme, GlobalConfig.Theme); } else { DBG ("theme %s chosen from nvram is absent, get first theme\n", ChosenTheme); } @@ -4943,7 +4952,6 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time) DBG ("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme); } else { DBG("chosen theme %ls\n", GlobalConfig.Theme); - ThemeX.Theme.takeValueFrom(GlobalConfig.Theme); } } } @@ -4971,6 +4979,8 @@ finish: ThemeX.embedded = true; Status = StartupSoundPlay(ThemeDir, NULL); } else { // theme loaded successfully + ThemeX.embedded = false; + ThemeX.Theme.takeValueFrom(GlobalConfig.Theme); // read theme settings if (!ThemeX.TypeSVG) { TagPtr DictPointer = GetProperty(ThemeDict, "Theme"); diff --git a/rEFIt_UEFI/libeg/VectorGraphics.cpp b/rEFIt_UEFI/libeg/VectorGraphics.cpp index 79af46a7d..3d2f18cd3 100755 --- a/rEFIt_UEFI/libeg/VectorGraphics.cpp +++ b/rEFIt_UEFI/libeg/VectorGraphics.cpp @@ -438,7 +438,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer) } float ScaleF = UGAHeight / SVGimage->height; DBG("using scale %f\n", ScaleF); - /*ThemeX.*/ Scale = ScaleF; + Scale = ScaleF; CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f; if (mainParser->font) { @@ -456,7 +456,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer) if (EFI_ERROR(Status)) { Status = ParseSVGXIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background"_XS, Scale, &BigBack); } - DBG(" Background parsed\n"); + DBG(" Background parsed [%lld, %lld]\n", BigBack.GetWidth(), BigBack.GetHeight()); // --- Make Banner Banner.setEmpty(); //for the case of theme switch Status = EFI_NOT_FOUND; @@ -479,7 +479,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer) Icon NewIcon(i); //initialize with embedded but further replace by loaded ParseSVGXIcon(mainParser, i, NewIcon.Name, Scale, &NewIcon.Image); ParseSVGXIcon(mainParser, i, NewIcon.Name + "_night", Scale, &NewIcon.ImageNight); - ThemeX.Icons.AddCopy(NewIcon); + Icons.AddCopy(NewIcon); } diff --git a/rEFIt_UEFI/libeg/XTheme.cpp b/rEFIt_UEFI/libeg/XTheme.cpp index 337d7d439..2c302ff90 100644 --- a/rEFIt_UEFI/libeg/XTheme.cpp +++ b/rEFIt_UEFI/libeg/XTheme.cpp @@ -13,6 +13,18 @@ extern "C" { #if USE_XTHEME +#ifndef DEBUG_ALL +#define DEBUG_XTHEME 1 +#else +#define DEBUG_XTHEME DEBUG_ALL +#endif + +#if DEBUG_XTHEME == 0 +#define DBG(...) +#else +#define DBG(...) DebugLog(DEBUG_XTHEME, __VA_ARGS__) +#endif + //temporary extern INTN ScrollWidth; @@ -340,6 +352,7 @@ void XTheme::ClearScreen() //and restore background and banner if (BanHeight < 2) { BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1); } + egClearScreen(&DarkBackgroundPixel); if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) { //Banner image prepared before if (!Banner.isEmpty()) { @@ -384,6 +397,7 @@ void XTheme::ClearScreen() //and restore background and banner if (!BigBack.isEmpty()) { switch (BackgroundScale) { case imScale: + DBG("back copy scaled\n"); Background.CopyScaled(BigBack, Scale); break; case imCrop: @@ -410,10 +424,12 @@ void XTheme::ClearScreen() //and restore background and banner 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); + egRawCopy((EG_PIXEL*)Background.GetPixelPtr(x1, y1), + (EG_PIXEL*)BigBack.GetPixelPtr(x2, y2), + x, y, Background.GetWidth(), BigBack.GetWidth()); +// DBG("crop to x,y: %lld, %lld\n", x, y); +// Background.CopyRect(BigBack, x, y); + DBG("back copy cropped\n"); break; } case imTile: @@ -426,16 +442,19 @@ void XTheme::ClearScreen() //and restore background and banner *p1++ = BigBack.GetPixel((i + x) % BigBack.GetWidth(), (j + y) % BigBack.GetHeight()); } } + DBG("back copy tiled\n"); break; } case imNone: default: // already scaled Background = BigBack; + DBG("back copy equal\n"); break; } } - Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight); +// Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight); + Background.Draw(0,0,0,false); //then draw banner if (!Banner.isEmpty()) { Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale); diff --git a/rEFIt_UEFI/libeg/image.cpp b/rEFIt_UEFI/libeg/image.cpp index 14136b9aa..159d9be3c 100644 --- a/rEFIt_UEFI/libeg/image.cpp +++ b/rEFIt_UEFI/libeg/image.cpp @@ -686,7 +686,7 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage, } //will be replaced by -// TmpBuffer.CopyRect(Background, XPos, YPos); +// CompBase.CopyRect(TopBase, XPos, YPos); VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr, IN INTN Width, IN INTN Height, diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index f4fe4315b..63c72efbc 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -4536,7 +4536,7 @@ VOID XTheme::FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN // TmpBuffer.CopyScaled(Background, 1.f); INTN X = XPos - (Width >> 1); //X_IS_CENTRE TmpBuffer.CopyRect(Background, X, YPos); - TmpBuffer.Draw(X, YPos); + TmpBuffer.DrawWithoutCompose(X, YPos); } #else VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign) diff --git a/rEFIt_UEFI/refit/screen.cpp b/rEFIt_UEFI/refit/screen.cpp index 721b3c6b4..038aeebf3 100644 --- a/rEFIt_UEFI/refit/screen.cpp +++ b/rEFIt_UEFI/refit/screen.cpp @@ -334,6 +334,7 @@ VOID SwitchToGraphicsAndClear(VOID) //called from MENU_FUNCTION_INIT { SwitchToGraphics(); #if USE_XTHEME + DBG("clear screen and draw back\n"); ThemeX.ClearScreen(); #else if (GraphicsScreenDirty) { //Invented in rEFIt 15 years ago