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); ThemeDict = LoadTheme (TestTheme);
if (ThemeDict != NULL) { if (ThemeDict != NULL) {
DBG ("special theme %ls found and %ls parsed\n", TestTheme, CONFIG_THEME_FILENAME); 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 } else { // special theme not loaded
DBG ("special theme %ls not found, skipping\n", TestTheme/*, CONFIG_THEME_FILENAME*/); DBG ("special theme %ls not found, skipping\n", TestTheme/*, CONFIG_THEME_FILENAME*/);
FreePool (TestTheme); FreePool (TestTheme);
@ -4909,10 +4914,14 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
ThemeDict = LoadTheme (TestTheme); ThemeDict = LoadTheme (TestTheme);
if (ThemeDict != NULL) { if (ThemeDict != NULL) {
DBG ("theme %s defined in NVRAM found and %ls parsed\n", ChosenTheme, CONFIG_THEME_FILENAME); 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 } else { // theme from nvram not loaded
if (!ThemeX.Theme.isEmpty()) { if (GlobalConfig.Theme) {
DBG ("theme %s chosen from nvram is absent, using theme defined in config: %ls\n", ChosenTheme, ThemeX.Theme.data()); DBG ("theme %s chosen from nvram is absent, using theme defined in config: %ls\n", ChosenTheme, GlobalConfig.Theme);
} else { } else {
DBG ("theme %s chosen from nvram is absent, get first theme\n", ChosenTheme); 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); DBG ("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme);
} else { } else {
DBG("chosen theme %ls\n", GlobalConfig.Theme); DBG("chosen theme %ls\n", GlobalConfig.Theme);
ThemeX.Theme.takeValueFrom(GlobalConfig.Theme);
} }
} }
} }
@ -4971,6 +4979,8 @@ finish:
ThemeX.embedded = true; ThemeX.embedded = true;
Status = StartupSoundPlay(ThemeDir, NULL); Status = StartupSoundPlay(ThemeDir, NULL);
} else { // theme loaded successfully } else { // theme loaded successfully
ThemeX.embedded = false;
ThemeX.Theme.takeValueFrom(GlobalConfig.Theme);
// read theme settings // read theme settings
if (!ThemeX.TypeSVG) { if (!ThemeX.TypeSVG) {
TagPtr DictPointer = GetProperty(ThemeDict, "Theme"); TagPtr DictPointer = GetProperty(ThemeDict, "Theme");

View File

@ -438,7 +438,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
} }
float ScaleF = UGAHeight / SVGimage->height; float ScaleF = UGAHeight / SVGimage->height;
DBG("using scale %f\n", ScaleF); DBG("using scale %f\n", ScaleF);
/*ThemeX.*/ Scale = ScaleF; Scale = ScaleF;
CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f; CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f;
if (mainParser->font) { if (mainParser->font) {
@ -456,7 +456,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
Status = ParseSVGXIcon(mainParser, BUILTIN_ICON_BACKGROUND, "Background"_XS, Scale, &BigBack); 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 // --- Make Banner
Banner.setEmpty(); //for the case of theme switch Banner.setEmpty(); //for the case of theme switch
Status = EFI_NOT_FOUND; 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 Icon NewIcon(i); //initialize with embedded but further replace by loaded
ParseSVGXIcon(mainParser, i, NewIcon.Name, Scale, &NewIcon.Image); ParseSVGXIcon(mainParser, i, NewIcon.Name, Scale, &NewIcon.Image);
ParseSVGXIcon(mainParser, i, NewIcon.Name + "_night", Scale, &NewIcon.ImageNight); 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 #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 //temporary
extern INTN ScrollWidth; extern INTN ScrollWidth;
@ -340,6 +352,7 @@ void XTheme::ClearScreen() //and restore background and banner
if (BanHeight < 2) { if (BanHeight < 2) {
BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1); BanHeight = ((UGAHeight - (int)(LayoutHeight * Scale)) >> 1);
} }
egClearScreen(&DarkBackgroundPixel);
if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) { if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) {
//Banner image prepared before //Banner image prepared before
if (!Banner.isEmpty()) { if (!Banner.isEmpty()) {
@ -384,6 +397,7 @@ void XTheme::ClearScreen() //and restore background and banner
if (!BigBack.isEmpty()) { if (!BigBack.isEmpty()) {
switch (BackgroundScale) { switch (BackgroundScale) {
case imScale: case imScale:
DBG("back copy scaled\n");
Background.CopyScaled(BigBack, Scale); Background.CopyScaled(BigBack, Scale);
break; break;
case imCrop: case imCrop:
@ -410,10 +424,12 @@ void XTheme::ClearScreen() //and restore background and banner
y = UGAHeight; y = UGAHeight;
} }
//the function can be in XImage class //the function can be in XImage class
/* egRawCopy(Background.GetPixelPtr(x1, y1), egRawCopy((EG_PIXEL*)Background.GetPixelPtr(x1, y1),
BigBack.GetPixelPtr(x2, y2), (EG_PIXEL*)BigBack.GetPixelPtr(x2, y2),
x, y, Background.GetWidth(), BigBack.GetWidth()); */ x, y, Background.GetWidth(), BigBack.GetWidth());
Background.Compose(x, y, BigBack, true); // DBG("crop to x,y: %lld, %lld\n", x, y);
// Background.CopyRect(BigBack, x, y);
DBG("back copy cropped\n");
break; break;
} }
case imTile: 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()); *p1++ = BigBack.GetPixel((i + x) % BigBack.GetWidth(), (j + y) % BigBack.GetHeight());
} }
} }
DBG("back copy tiled\n");
break; break;
} }
case imNone: case imNone:
default: default:
// already scaled // already scaled
Background = BigBack; Background = BigBack;
DBG("back copy equal\n");
break; break;
} }
} }
Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight); // Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight);
Background.Draw(0,0,0,false);
//then draw banner //then draw banner
if (!Banner.isEmpty()) { if (!Banner.isEmpty()) {
Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale); Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);

View File

@ -686,7 +686,7 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
} }
//will be replaced by //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, VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height, 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); // TmpBuffer.CopyScaled(Background, 1.f);
INTN X = XPos - (Width >> 1); //X_IS_CENTRE INTN X = XPos - (Width >> 1); //X_IS_CENTRE
TmpBuffer.CopyRect(Background, X, YPos); TmpBuffer.CopyRect(Background, X, YPos);
TmpBuffer.Draw(X, YPos); TmpBuffer.DrawWithoutCompose(X, YPos);
} }
#else #else
VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color, IN UINT8 XAlign) 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(); SwitchToGraphics();
#if USE_XTHEME #if USE_XTHEME
DBG("clear screen and draw back\n");
ThemeX.ClearScreen(); ThemeX.ClearScreen();
#else #else
if (GraphicsScreenDirty) { //Invented in rEFIt 15 years ago if (GraphicsScreenDirty) { //Invented in rEFIt 15 years ago