clear screen in xtheme

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-03-16 22:47:02 +03:00
parent 0aefccfc82
commit 81f2b91b15
3 changed files with 115 additions and 9 deletions

View File

@ -73,6 +73,8 @@ public:
float CentreShift;
INTN row0TileSize;
INTN row1TileSize;
INTN BanHeight;
INTN LayoutHeight; //it was 376 before
void Init();
XImage Background; //Background and Banner will not be in array as they live own life
@ -85,6 +87,7 @@ public:
void AddIcon(Icon& NewIcon); //return EFI_STATUS?
void FillByEmbedded();
VOID ClearScreen();
XTheme(); //default constructor
~XTheme();
@ -93,4 +96,4 @@ protected:
//internal layout variables instead of globals in menu.cpp
};
#endif
#endif

View File

@ -36,7 +36,8 @@
#include "../Platform/Platform.h"
#include "screen.h"
#include "../libeg/libegint.h"
#include "../libeg/libegint.h" // included Platform.h
#include "../libeg/XTheme.h"
#ifndef DEBUG_ALL
#define DEBUG_SCR 1
@ -392,11 +393,11 @@ BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where)
// Graphics functions
//
VOID SwitchToGraphicsAndClear(VOID)
VOID SwitchToGraphicsAndClear(VOID) //called from MENU_FUNCTION_INIT
{
SwitchToGraphics();
SwitchToGraphics();
if (GraphicsScreenDirty) {
BltClearScreen(TRUE);
BltClearScreen();
}
}
@ -409,8 +410,110 @@ typedef struct {
} EG_RECT;
*/
#if USE_XTHEME
VOID XTheme::BltClearScreen()
{
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");
}
}
VOID BltClearScreen(IN BOOLEAN ShowBanner) //ShowBanner always TRUE
}
}
//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
{
EG_PIXEL *p1;
INTN i, j, x, x1, x2, y, y1, y2;
@ -573,7 +676,7 @@ VOID BltClearScreen(IN BOOLEAN ShowBanner) //ShowBanner always TRUE
}
// Draw banner
if (Banner && ShowBanner) {
if (Banner) {
BltImageAlpha(Banner, BannerPlace.XPos, BannerPlace.YPos, &MenuBackgroundPixel, 16);
}
//what is the idea for the conversion?
@ -583,7 +686,7 @@ VOID BltClearScreen(IN BOOLEAN ShowBanner) //ShowBanner always TRUE
InputBackgroundPixel.a = (MenuBackgroundPixel.a + 0) & 0xFF;
GraphicsScreenDirty = FALSE;
}
#endif
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
{
if (!Image) {

View File

@ -17,7 +17,7 @@ VOID FreeAnime(GUI_ANIME *Anime);
VOID SwitchToGraphicsAndClear(VOID);
VOID BltClearScreen(IN BOOLEAN ShowBanner);
VOID BltClearScreen();
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos);
VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *BackgroundPixel, INTN Scale);
VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos);