repair background draw

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-31 17:25:07 +03:00
parent 0c62865b22
commit a37196ab8c
6 changed files with 45 additions and 15 deletions

View File

@ -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");

View File

@ -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);
}

View File

@ -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);

View File

@ -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,

View File

@ -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)

View File

@ -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