refactoring DrawText and Pixels

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-01 15:57:32 +03:00
parent fbfc206a41
commit f70c4e14d2
21 changed files with 358 additions and 131 deletions

View File

@ -804,7 +804,7 @@ struct RT_VARIABLES {
CHAR16 *Name; CHAR16 *Name;
EFI_GUID VarGuid; EFI_GUID VarGuid;
}; };
//no more used?
typedef struct CUSTOM_LOADER_ENTRY CUSTOM_LOADER_ENTRY; typedef struct CUSTOM_LOADER_ENTRY CUSTOM_LOADER_ENTRY;
struct CUSTOM_LOADER_ENTRY { struct CUSTOM_LOADER_ENTRY {
CUSTOM_LOADER_ENTRY *Next; CUSTOM_LOADER_ENTRY *Next;
@ -827,8 +827,12 @@ struct CUSTOM_LOADER_ENTRY {
UINT8 KernelScan; UINT8 KernelScan;
UINT8 CustomBoot; UINT8 CustomBoot;
EG_IMAGE *CustomLogo; EG_IMAGE *CustomLogo;
EG_PIXEL *BootBgColor; #if USE_XTHEME
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches; //zzzz EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
#else
EG_PIXEL *BootBgColor; //why it is array? It is one value!
#endif
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
}; };
typedef struct CUSTOM_LEGACY_ENTRY CUSTOM_LEGACY_ENTRY; typedef struct CUSTOM_LEGACY_ENTRY CUSTOM_LEGACY_ENTRY;

View File

@ -96,7 +96,7 @@ EG_IMAGE *Buttons[4] = {NULL, NULL, NULL, NULL};
INTN row0TileSize = 144; INTN row0TileSize = 144;
INTN row1TileSize = 64; INTN row1TileSize = 64;
#endif #endif
EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //non-trasparent //EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //define in lib.h
const INTN BCSMargin = 11; const INTN BCSMargin = 11;
BOOLEAN DayLight; BOOLEAN DayLight;
@ -1002,10 +1002,13 @@ CUSTOM_LOADER_ENTRY
if (Entry->DriveImagePath) { if (Entry->DriveImagePath) {
DuplicateEntry->DriveImagePath = EfiStrDuplicate (Entry->DriveImagePath); DuplicateEntry->DriveImagePath = EfiStrDuplicate (Entry->DriveImagePath);
} }
#if USE_XTHEME
DuplicateEntry->BootBgColor = Entry->BootBgColor;
#else
if (Entry->BootBgColor) { if (Entry->BootBgColor) {
DuplicateEntry->BootBgColor = (__typeof__(DuplicateEntry->BootBgColor))AllocateCopyPool (sizeof(EG_PIXEL), Entry->BootBgColor); DuplicateEntry->BootBgColor = (__typeof__(DuplicateEntry->BootBgColor))AllocateCopyPool (sizeof(Entry->BootBgColor), Entry->BootBgColor);
} }
#endif
DuplicateEntry->Image = Entry->Image; DuplicateEntry->Image = Entry->Image;
DuplicateEntry->DriveImage = Entry->DriveImage; DuplicateEntry->DriveImage = Entry->DriveImage;
@ -2105,11 +2108,19 @@ FillinCustomEntry (
if (Prop != NULL && Prop->type == kTagTypeString) { if (Prop != NULL && Prop->type == kTagTypeString) {
UINTN Color; UINTN Color;
Color = AsciiStrHexToUintn (Prop->string); Color = AsciiStrHexToUintn (Prop->string);
Entry->BootBgColor = (__typeof__(Entry->BootBgColor))AllocateZeroPool (sizeof(EG_PIXEL));
#if USE_XTHEME
Entry->BootBgColor.Red = (Color >> 24) & 0xFF;
Entry->BootBgColor.Green = (Color >> 16) & 0xFF;
Entry->BootBgColor.Blue = (Color >> 8) & 0xFF;
Entry->BootBgColor.Reserved = (Color >> 0) & 0xFF;
#else
Entry->BootBgColor = (__typeof__(Entry->BootBgColor))AllocateZeroPool (sizeof(Entry->BootBgColor));
Entry->BootBgColor->r = (Color >> 24) & 0xFF; Entry->BootBgColor->r = (Color >> 24) & 0xFF;
Entry->BootBgColor->g = (Color >> 16) & 0xFF; Entry->BootBgColor->g = (Color >> 16) & 0xFF;
Entry->BootBgColor->b = (Color >> 8) & 0xFF; Entry->BootBgColor->b = (Color >> 8) & 0xFF;
Entry->BootBgColor->a = (Color >> 0) & 0xFF; Entry->BootBgColor->a = (Color >> 0) & 0xFF;
#endif
} }
// Hidden Property, Values: // Hidden Property, Values:

View File

@ -149,7 +149,8 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
DBG(" sound channels=%d bits=%d freq=%d\n", WaveData.Format->Channels, WaveData.Format->BitsPerSample, WaveData.Format->SamplesPerSec); DBG(" sound channels=%d bits=%d freq=%d\n", WaveData.Format->Channels, WaveData.Format->BitsPerSample, WaveData.Format->SamplesPerSec);
if (!WaveData.SamplesLength || !OutputVolume) { if (!WaveData.SamplesLength || !OutputVolume) {
DBG("nothing to play\n"); // DBG("nothing to play\n");
Status = EFI_NOT_FOUND;
goto DONE_ERROR; goto DONE_ERROR;
} }
@ -162,7 +163,7 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
INT16 *Ptr = (INT16*)WaveData.Samples; INT16 *Ptr = (INT16*)WaveData.Samples;
if (!Ptr) { if (!Ptr) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
DBG("not found wave data\n"); // DBG("not found wave data\n");
goto DONE_ERROR; goto DONE_ERROR;
} }
TempData = (__typeof__(TempData))AllocateZeroPool(Len * sizeof(INT16)); TempData = (__typeof__(TempData))AllocateZeroPool(Len * sizeof(INT16));
@ -187,8 +188,8 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
} }
if (!AudioIo) { if (!AudioIo) {
Status = EFI_NOT_FOUND; Status = EFI_DEVICE_ERROR;
DBG("not found AudioIo to play\n"); // DBG("not found AudioIo to play\n");
goto DONE_ERROR; goto DONE_ERROR;
} }
@ -222,7 +223,7 @@ StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile)
DONE_ERROR: DONE_ERROR:
if (FileData && SoundFile) { //dont free embedded sound if (FileData && SoundFile) { //dont free embedded sound
DBG("free sound\n"); // DBG("free sound\n");
FreePool(FileData); FreePool(FileData);
} }
DBG("sound play end with status=%s\n", strerror(Status)); DBG("sound play end with status=%s\n", strerror(Status));

View File

@ -729,7 +729,7 @@ CONST CHAR16 *CustomBootModeToStr(IN UINT8 Mode)
EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry) EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry)
{ {
EG_PIXEL *backgroundPixel = Entry->BootBgColor; EG_PIXEL *backgroundPixel = (EG_PIXEL *)&Entry->BootBgColor;
EG_IMAGE *logo = NULL; EG_IMAGE *logo = NULL;
INTN screenWidth, screenHeight; INTN screenWidth, screenHeight;
UINT8 customBoot = Entry->CustomBoot; UINT8 customBoot = Entry->CustomBoot;

View File

@ -404,6 +404,24 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
} }
return Status; return Status;
} }
#if USE_XTHEME
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST CHAR16 *LoaderOptions,
IN CONST CHAR16 *FullTitle,
IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume,
IN EG_IMAGE *Image,
IN EG_IMAGE *DriveImage,
IN UINT8 OSType,
IN UINT8 Flags,
IN CHAR16 Hotkey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor,
IN UINT8 CustomBoot,
IN EG_IMAGE *CustomLogo,
IN KERNEL_AND_KEXT_PATCHES *Patches,
IN BOOLEAN CustomEntry)
#else
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST CHAR16 *LoaderOptions, IN CONST CHAR16 *LoaderOptions,
@ -420,6 +438,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN EG_IMAGE *CustomLogo, IN EG_IMAGE *CustomLogo,
IN KERNEL_AND_KEXT_PATCHES *Patches, IN KERNEL_AND_KEXT_PATCHES *Patches,
IN BOOLEAN CustomEntry) IN BOOLEAN CustomEntry)
#endif
{ {
EFI_DEVICE_PATH *LoaderDevicePath; EFI_DEVICE_PATH *LoaderDevicePath;
CONST CHAR16 *LoaderDevicePathString; CONST CHAR16 *LoaderDevicePathString;
@ -729,6 +748,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
// DBG(" Show badge as OSImage."); // DBG(" Show badge as OSImage.");
} }
} }
Entry->BootBgColor = BootBgColor;
#else #else
if (GlobalConfig.HideBadges & HDBADGES_SHOW) { if (GlobalConfig.HideBadges & HDBADGES_SHOW) {
if (GlobalConfig.HideBadges & HDBADGES_SWAP) { if (GlobalConfig.HideBadges & HDBADGES_SWAP) {
@ -739,11 +759,12 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
// DBG(" Show badge as OSImage."); // DBG(" Show badge as OSImage.");
} }
} }
#endif
if (BootBgColor != NULL) { if (BootBgColor != NULL) {
Entry->BootBgColor = BootBgColor; Entry->BootBgColor = BootBgColor; //copy pointer
} }
#endif
Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches); Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches);
#ifdef DUMP_KERNEL_KEXT_PATCHES #ifdef DUMP_KERNEL_KEXT_PATCHES
DumpKernelAndKextPatches(Entry->KernelAndKextPatches); DumpKernelAndKextPatches(Entry->KernelAndKextPatches);
@ -1032,8 +1053,11 @@ STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *Load
} }
} }
} }
#if USE_XTHEME
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, NULL, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE); Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#else
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, NULL, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#endif
if (Entry != NULL) { if (Entry != NULL) {
if ((Entry->LoaderType == OSTYPE_OSX) || if ((Entry->LoaderType == OSTYPE_OSX) ||
(Entry->LoaderType == OSTYPE_OSX_INSTALLER ) || (Entry->LoaderType == OSTYPE_OSX_INSTALLER ) ||

View File

@ -79,7 +79,10 @@ public:
INTN TimeoutSeconds; INTN TimeoutSeconds;
#if USE_XTHEME #if USE_XTHEME
XStringW TimeoutText; XStringW TimeoutText;
XStringW ThemeName; XStringW ThemeName; //?
EG_RECT OldTextBufferRect;
XImage OldTextBufferImage;
BOOLEAN isBootScreen;
#else #else
CONST CHAR16 *TimeoutText; CONST CHAR16 *TimeoutText;
CONST CHAR16 *Theme; CONST CHAR16 *Theme;
@ -96,6 +99,9 @@ public:
UINTN mItemID; UINTN mItemID;
SCROLL_STATE ScrollState; SCROLL_STATE ScrollState;
BOOLEAN ScrollEnabled; BOOLEAN ScrollEnabled;
#if USE_XTHEME
INTN TextStyle;
#endif
// MENU_STYLE_FUNC StyleFunc; // MENU_STYLE_FUNC StyleFunc;
//TODO scroll positions should depends on REFIT_SCREEN? //TODO scroll positions should depends on REFIT_SCREEN?
@ -117,8 +123,9 @@ public:
#if USE_XTHEME #if USE_XTHEME
REFIT_MENU_SCREEN() REFIT_MENU_SCREEN()
: ID(0), Title(), TitleImage(), : ID(0), Title(), TitleImage(),
TimeoutSeconds(0), TimeoutText(), ThemeName(), AnimeRun(0), TimeoutSeconds(0), TimeoutText(), ThemeName(),
Once(0), LastDraw(0), CurrentFrame(0), OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{}; {};
@ -136,8 +143,9 @@ public:
#if USE_XTHEME #if USE_XTHEME
REFIT_MENU_SCREEN(UINTN ID, XStringW Title, XStringW TimeoutText) REFIT_MENU_SCREEN(UINTN ID, XStringW Title, XStringW TimeoutText)
: ID(ID), Title(Title), TitleImage(), : ID(ID), Title(Title), TitleImage(),
TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(), AnimeRun(0), TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(),
Once(0), LastDraw(0), CurrentFrame(0), OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{}; {};
@ -164,8 +172,9 @@ public:
#if USE_XTHEME #if USE_XTHEME
REFIT_MENU_SCREEN(UINTN ID, XStringW Title, XStringW TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2) REFIT_MENU_SCREEN(UINTN ID, XStringW Title, XStringW TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(Title), TitleImage(), : ID(ID), Title(Title), TitleImage(),
TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(), AnimeRun(0), TimeoutSeconds(0), TimeoutText(TimeoutText), ThemeName(),
Once(0), LastDraw(0), CurrentFrame(0), OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), Frames(0), FrameTime(0),
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{ {
@ -210,6 +219,13 @@ public:
UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc); UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc);
VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos); VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos);
#if USE_XTHEME
INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
void EraseTextXY();
VOID DrawTextCorner(UINTN TextC, UINT8 Align);
VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor);
#endif
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID CountItems(); VOID CountItems();
VOID InitAnime(); VOID InitAnime();
BOOLEAN GetAnime(); BOOLEAN GetAnime();

View File

@ -349,14 +349,26 @@ class REFIT_ABSTRACT_MENU_ENTRY
UINT8 LoaderType; UINT8 LoaderType;
CHAR8 *OSVersion; CHAR8 *OSVersion;
CHAR8 *BuildVersion; CHAR8 *BuildVersion;
EG_PIXEL *BootBgColor; #if USE_XTHEME
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
#else
EG_PIXEL *BootBgColor; //why it is array? It is one value!
#endif
UINT8 CustomBoot; UINT8 CustomBoot;
EG_IMAGE *CustomLogo; EG_IMAGE *CustomLogo;
KERNEL_AND_KEXT_PATCHES *KernelAndKextPatches; KERNEL_AND_KEXT_PATCHES *KernelAndKextPatches;
CONST CHAR16 *Settings; CONST CHAR16 *Settings;
LOADER_ENTRY() LOADER_ENTRY()
: REFIT_MENU_ITEM_BOOTNUM(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0), BootBgColor(0), CustomBoot(0), CustomLogo(0), KernelAndKextPatches(0), Settings(0) : REFIT_MENU_ITEM_BOOTNUM(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0),
#if USE_XTHEME
BootBgColor({0,0,0,0}),
#else
BootBgColor(0),
#endif
CustomBoot(0), CustomLogo(0), KernelAndKextPatches(0), Settings(0)
{}; {};
LOADER_ENTRY* getPartiallyDuplicatedEntry() const; LOADER_ENTRY* getPartiallyDuplicatedEntry() const;
virtual LOADER_ENTRY* getLOADER_ENTRY() { return this; }; virtual LOADER_ENTRY* getLOADER_ENTRY() { return this; };

View File

@ -1005,7 +1005,7 @@ VOID testSVG()
#endif #endif
#if TEST_SVG_IMAGE #if TEST_SVG_IMAGE
NSVGrasterizer* rast = nsvgCreateRasterizer(); NSVGrasterizer* rast = nsvgCreateRasterizer();
EG_IMAGE *NewImage; // EG_IMAGE *NewImage;
NSVGimage *SVGimage; NSVGimage *SVGimage;
float Scale, ScaleX, ScaleY; float Scale, ScaleX, ScaleY;
@ -1028,7 +1028,11 @@ VOID testSVG()
} }
*/ */
// Rasterize // Rasterize
NewImage = egCreateFilledImage(Width, Height, TRUE, &MenuBackgroundPixel); #if USE_XTHEME
XImage NewImage(Width, Height);
#else
EG_IMAGE *NewImage = egCreateFilledImage(Width, Height, TRUE, &MenuBackgroundPixel);
#endif
if (SVGimage->width <= 0) SVGimage->width = (float)Width; if (SVGimage->width <= 0) SVGimage->width = (float)Width;
if (SVGimage->height <= 0) SVGimage->height = (float)Height; if (SVGimage->height <= 0) SVGimage->height = (float)Height;
@ -1038,23 +1042,26 @@ VOID testSVG()
float tx = 0; //-SVGimage->realBounds[0] * Scale; float tx = 0; //-SVGimage->realBounds[0] * Scale;
float ty = 0; //-SVGimage->realBounds[1] * Scale; float ty = 0; //-SVGimage->realBounds[1] * Scale;
DBG("timing rasterize start tx=%f ty=%f\n", tx, ty); DBG("timing rasterize start tx=%f ty=%f\n", tx, ty);
#if USE_XTHEME
nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage.GetPixelPtr(0,0), (int)Width, (int)Height, (int)Width*4);
DBG("timing rasterize end\n");
NewImage.Draw((UGAWidth - Width) / 2,
(UGAHeight - Height) / 2);
#else
nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage->PixelData, (int)Width, (int)Height, (int)Width*4); nsvgRasterize(rast, SVGimage, tx,ty,Scale,Scale, (UINT8*)NewImage->PixelData, (int)Width, (int)Height, (int)Width*4);
DBG("timing rasterize end\n"); DBG("timing rasterize end\n");
//now show it! //now show it!
#if 1 //test XImage
XImage NewX(NewImage); XImage NewX(NewImage);
NewX.Draw((UGAWidth - Width) / 2, NewX.Draw((UGAWidth - Width) / 2,
(UGAHeight - Height) / 2); (UGAHeight - Height) / 2);
#else egFreeImage(NewImage);
BltImageAlpha(NewImage,
(UGAWidth - Width) / 2,
(UGAHeight - Height) / 2,
&MenuBackgroundPixel,
16);
#endif //test XImage #endif //test XImage
FreePool(FileData); FreePool(FileData);
FileData = NULL; FileData = NULL;
egFreeImage(NewImage); //
// nsvg__deleteParser(p); // nsvg__deleteParser(p);
nsvgDeleteRasterizer(rast); nsvgDeleteRasterizer(rast);

View File

@ -15,6 +15,7 @@
#define DBG(...) DebugLog(DEBUG_XIMAGE, __VA_ARGS__) #define DBG(...) DebugLog(DEBUG_XIMAGE, __VA_ARGS__)
#endif #endif
EFI_GRAPHICS_OUTPUT_BLT_PIXEL NullColor = {0,0,0,0};
XImage::XImage() XImage::XImage()
{ {
@ -64,7 +65,7 @@ XImage& XImage::operator= (const XImage& other)
return *this; return *this;
} }
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale) UINT8 XImage::Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale)
{ {
return (UINT8)((*(p + a01) * (scale - dx) * 3.f + *(p + a10) * (scale - dy) * 3.f + *(p + a21) * dx * 3.f + return (UINT8)((*(p + a01) * (scale - dx) * 3.f + *(p + a10) * (scale - dy) * 3.f + *(p + a21) * dx * 3.f +
*(p + a12) * dy * 3.f + *(p) * 2.f *scale) / (scale * 8.f)); *(p + a12) * dy * 3.f + *(p) * 2.f *scale) / (scale * 8.f));
@ -370,6 +371,7 @@ EFI_STATUS XImage::FromSVG(const CHAR8 *SVGData, float scale)
NSVGrasterizer* rast = nsvgCreateRasterizer(); NSVGrasterizer* rast = nsvgCreateRasterizer();
if (!rast) return EFI_UNSUPPORTED; if (!rast) return EFI_UNSUPPORTED;
//we have to copy input data because nanosvg wants to change it
char *input = (__typeof__(input))AllocateCopyPool(AsciiStrSize(SVGData), SVGData); char *input = (__typeof__(input))AllocateCopyPool(AsciiStrSize(SVGData), SVGData);
if (!input) return EFI_DEVICE_ERROR; if (!input) return EFI_DEVICE_ERROR;
@ -398,6 +400,7 @@ EFI_STATUS XImage::FromSVG(const CHAR8 *SVGData, float scale)
* the rect will be clipped if it intersects the screen edge * the rect will be clipped if it intersects the screen edge
* *
* be careful about alpha. This procedure can produce alpha = 0 which means full transparent * be careful about alpha. This procedure can produce alpha = 0 which means full transparent
* No! Anuway alpha should be corrected to 0xFF
*/ */
void XImage::GetArea(const EG_RECT& Rect) void XImage::GetArea(const EG_RECT& Rect)
{ {
@ -448,6 +451,12 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
EfiUgaVideoToBltBuffer, EfiUgaVideoToBltBuffer,
x, y, 0, 0, Width, Height, 0); //Width*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); x, y, 0, 0, Width, Height, 0); //Width*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
} }
//fix alpha
UINTN ImageSize = (Width * Height);
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Pixel = GetPixelPtr(0,0);
for (UINTN i = 0; i < ImageSize; ++i) {
(Pixel++)->Reserved = 0xFF;
}
} }
void XImage::DrawWithoutCompose(INTN x, INTN y, UINTN width, UINTN height) void XImage::DrawWithoutCompose(INTN x, INTN y, UINTN width, UINTN height)
@ -602,6 +611,11 @@ EFI_STATUS XImage::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName)
//EnsureImageSize should create new object with new sizes //EnsureImageSize should create new object with new sizes
//while compose uses old object //while compose uses old object
void XImage::EnsureImageSize(IN UINTN NewWidth, IN UINTN NewHeight)
{
EnsureImageSize(NewWidth, NewHeight, NullColor);
}
void XImage::EnsureImageSize(IN UINTN NewWidth, IN UINTN NewHeight, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color) void XImage::EnsureImageSize(IN UINTN NewWidth, IN UINTN NewHeight, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color)
{ {
if (NewWidth == Width && NewHeight == Height) if (NewWidth == Width && NewHeight == Height)

View File

@ -106,8 +106,10 @@ public:
EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName); EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName);
EFI_STATUS LoadIcns(IN EFI_FILE *Dir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); EFI_STATUS LoadIcns(IN EFI_FILE *Dir, IN CONST CHAR16 *FileName, IN UINTN PixelSize);
void EnsureImageSize(IN UINTN Width, IN UINTN Height, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color); void EnsureImageSize(IN UINTN Width, IN UINTN Height, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color);
void EnsureImageSize(IN UINTN NewWidth, IN UINTN NewHeight);
void DummyImage(IN UINTN PixelSize); void DummyImage(IN UINTN PixelSize);
protected:
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale);
}; };
#endif //__XSTRINGW_H__ #endif //__XSTRINGW_H__

View File

@ -8,6 +8,7 @@ extern "C" {
#include "libegint.h" #include "libegint.h"
#include "../refit/screen.h" #include "../refit/screen.h"
#include "../refit/lib.h"
#include "XTheme.h" #include "XTheme.h"
@ -47,6 +48,7 @@ extern EG_RECT ScrollbarOldPointerPlace;
extern EG_RECT ScrollbarNewPointerPlace; extern EG_RECT ScrollbarNewPointerPlace;
extern INTN ScrollbarYMovement; extern INTN ScrollbarYMovement;
//extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel;
CONST CHAR8* IconsNames[] = { CONST CHAR8* IconsNames[] = {
@ -352,7 +354,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); egClearScreen(&MenuBackgroundPixel);
if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) { if (!(HideUIFlags & HIDEUI_FLAG_BANNER)) {
//Banner image prepared before //Banner image prepared before
if (!Banner.isEmpty()) { if (!Banner.isEmpty()) {
@ -392,12 +394,12 @@ void XTheme::ClearScreen() //and restore background and banner
if (Background.isEmpty()) { if (Background.isEmpty()) {
Background = XImage(UGAWidth, UGAHeight); Background = XImage(UGAWidth, UGAHeight);
Background.Fill((EFI_GRAPHICS_OUTPUT_BLT_PIXEL&)BlueBackgroundPixel); Background.Fill(BlueBackgroundPixel);
} }
if (!BigBack.isEmpty()) { if (!BigBack.isEmpty()) {
switch (BackgroundScale) { switch (BackgroundScale) {
case imScale: case imScale:
DBG("back copy scaled\n"); // DBG("back copy scaled\n");
Background.CopyScaled(BigBack, Scale); Background.CopyScaled(BigBack, Scale);
break; break;
case imCrop: case imCrop:
@ -429,7 +431,7 @@ void XTheme::ClearScreen() //and restore background and banner
x, y, Background.GetWidth(), BigBack.GetWidth()); x, y, Background.GetWidth(), BigBack.GetWidth());
// DBG("crop to x,y: %lld, %lld\n", x, y); // DBG("crop to x,y: %lld, %lld\n", x, y);
// Background.CopyRect(BigBack, x, y); // Background.CopyRect(BigBack, x, y);
DBG("back copy cropped\n"); // DBG("back copy cropped\n");
break; break;
} }
case imTile: case imTile:
@ -442,14 +444,14 @@ 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"); // 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"); // DBG("back copy equal\n");
break; break;
} }
} }
@ -468,10 +470,10 @@ void XTheme::InitSelection() //for PNG theme
if (!AllowGraphicsMode) if (!AllowGraphicsMode)
return; return;
//used to fill TextBuffer if selected //used to fill TextBuffer if selected
SelectionBackgroundPixel.r = (SelectionColor >> 24) & 0xFF; SelectionBackgroundPixel.Red = (SelectionColor >> 24) & 0xFF;
SelectionBackgroundPixel.g = (SelectionColor >> 16) & 0xFF; SelectionBackgroundPixel.Green = (SelectionColor >> 16) & 0xFF;
SelectionBackgroundPixel.b = (SelectionColor >> 8) & 0xFF; SelectionBackgroundPixel.Blue = (SelectionColor >> 8) & 0xFF;
SelectionBackgroundPixel.a = (SelectionColor >> 0) & 0xFF; SelectionBackgroundPixel.Reserved = (SelectionColor >> 0) & 0xFF;
if (!SelectionImages[0].isEmpty()) { //already presents if (!SelectionImages[0].isEmpty()) { //already presents
return; return;
@ -511,7 +513,7 @@ void XTheme::InitSelection() //for PNG theme
SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big)); SelectionImages[0].FromPNG(ACCESS_EMB_DATA(emb_dark_selection_big), ACCESS_EMB_SIZE(emb_dark_selection_big));
} }
// SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons // SelectionImages[0]->HasAlpha = FALSE; // support transparensy for selection icons
CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EG_PIXEL)); CopyMem(&BlueBackgroundPixel, &StdBackgroundPixel, sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (SelectionImages[0].isEmpty()) { if (SelectionImages[0].isEmpty()) {
SelectionImages[2].setEmpty(); SelectionImages[2].setEmpty();
return; return;
@ -537,14 +539,14 @@ void XTheme::InitSelection() //for PNG theme
// SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize, // SelectionImages[4] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &StdBackgroundPixel); // TRUE, &StdBackgroundPixel);
SelectionImages[4] = XImage(ScaledIndicatorSize, ScaledIndicatorSize); SelectionImages[4] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
SelectionImages[4].Fill((EFI_GRAPHICS_OUTPUT_BLT_PIXEL&)StdBackgroundPixel); SelectionImages[4].Fill(StdBackgroundPixel);
} }
// SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize, // SelectionImages[5] = egCreateFilledImage(ScaledIndicatorSize, ScaledIndicatorSize,
// TRUE, &MenuBackgroundPixel); // TRUE, &MenuBackgroundPixel);
SelectionImages[5] = XImage(ScaledIndicatorSize, ScaledIndicatorSize); SelectionImages[5] = XImage(ScaledIndicatorSize, ScaledIndicatorSize);
SelectionImages[5].Fill((EFI_GRAPHICS_OUTPUT_BLT_PIXEL&)MenuBackgroundPixel); SelectionImages[5].Fill(MenuBackgroundPixel);
} }

View File

@ -102,6 +102,8 @@ public:
XImage UpButtonImage; XImage UpButtonImage;
XImage DownButtonImage; XImage DownButtonImage;
EG_RECT BannerPlace; //TODO exclude BanHeight = BannerPlace.Height
//fill the theme //fill the theme
const XImage& GetIcon(const XString& Name); //get by name const XImage& GetIcon(const XString& Name); //get by name
const XImage& GetIcon(const char* Name); const XImage& GetIcon(const char* Name);

View File

@ -609,6 +609,7 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
// //
// take part of other procedures, not needed // take part of other procedures, not needed
//used in RunGenericMenu-> used in Anime
VOID egRestrictImageArea(IN EG_IMAGE *Image, VOID egRestrictImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight) IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight)
@ -630,7 +631,7 @@ VOID egRestrictImageArea(IN EG_IMAGE *Image,
} }
} }
//will be replaced by //TODO will be replaced by
// CompImage.Fill(Color) // CompImage.Fill(Color)
VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color) VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color)
{ {
@ -651,8 +652,9 @@ VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color)
} }
} }
//will be replaced by //TODO will be replaced by
// CompImage.FillArea(Color, Rect) // CompImage.FillArea(Color, Rect)
// used in Anime
VOID egFillImageArea(IN OUT EG_IMAGE *CompImage, VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight, IN INTN AreaWidth, IN INTN AreaHeight,
@ -685,7 +687,7 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
} }
} }
//will be replaced by //TODO will be replaced by
// CompBase.CopyRect(TopBase, 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,
@ -803,7 +805,7 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
} }
} }
//will be replaced by //TODO will be replaced by
// CompImage.Compose(IN XImage& TopImage, IN INTN PosX, IN INTN PosY) // CompImage.Compose(IN XImage& TopImage, IN INTN PosX, IN INTN PosY)
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY) VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY)
{ {
@ -818,9 +820,15 @@ VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN P
// compose // compose
if (CompWidth > 0) { if (CompWidth > 0) {
if (CompImage->HasAlpha && !BackgroundImage) { #if USE_XTHEME
CompImage->HasAlpha = FALSE; if (CompImage->HasAlpha && ThemeX.Background.isEmpty()) {
CompImage->HasAlpha = FALSE;
} }
#else
if (CompImage->HasAlpha && !BackgroundImage) {
CompImage->HasAlpha = FALSE;
}
#endif
if (TopImage->HasAlpha) { if (TopImage->HasAlpha) {
if (CompImage->HasAlpha) { //aaaa if (CompImage->HasAlpha) { //aaaa
@ -839,7 +847,7 @@ VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN P
} }
} }
} }
#if !USE_XTHEME
EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color) EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color)
{ {
EG_IMAGE *NewImage; EG_IMAGE *NewImage;
@ -859,7 +867,7 @@ EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height,
return NewImage; return NewImage;
} }
#endif
// //
// misc internal functions // misc internal functions
// //

View File

@ -496,8 +496,13 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY); VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY);
VOID PrepareFont(VOID); VOID PrepareFont(VOID);
VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height); VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height);
#if USE_XTHEME
VOID egClearScreen(IN void *Color);
#else
VOID egClearScreen(IN EG_PIXEL *Color); VOID egClearScreen(IN EG_PIXEL *Color);
#endif
//VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY); //VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY);
// will be replaced by XImage.Draw(ScreenPosX, ScreenPosY, 1.f); assuming Area* = 0 // will be replaced by XImage.Draw(ScreenPosX, ScreenPosY, 1.f); assuming Area* = 0
VOID egDrawImageArea(IN EG_IMAGE *Image, VOID egDrawImageArea(IN EG_IMAGE *Image,

View File

@ -514,31 +514,52 @@ VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable)
// //
// Drawing to the screen // Drawing to the screen
// //
#if USE_XTHEME
VOID egClearScreen(IN void *Color)
{
if (!egHasGraphics)
return;
if (GraphicsOutput != NULL) {
// EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same
// layout, and the header from TianoCore actually defines them
// to be the same type.
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Color, EfiBltVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
} else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)Color, EfiUgaVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
}
}
#else
VOID egClearScreen(IN EG_PIXEL *Color) VOID egClearScreen(IN EG_PIXEL *Color)
{ {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColor; EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColor;
if (!egHasGraphics) if (!egHasGraphics)
return; return;
FillColor.Red = Color->r; FillColor.Red = Color->r;
FillColor.Green = Color->g; FillColor.Green = Color->g;
FillColor.Blue = Color->b; FillColor.Blue = Color->b;
FillColor.Reserved = 0; FillColor.Reserved = 0;
if (GraphicsOutput != NULL) { if (GraphicsOutput != NULL) {
// EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same // EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same
// layout, and the header from TianoCore actually defines them // layout, and the header from TianoCore actually defines them
// to be the same type. // to be the same type.
GraphicsOutput->Blt(GraphicsOutput, &FillColor, EfiBltVideoFill, GraphicsOutput->Blt(GraphicsOutput, &FillColor, EfiBltVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0); 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
} else if (UgaDraw != NULL) { } else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)&FillColor, EfiUgaVideoFill, UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL*)&FillColor, EfiUgaVideoFill,
0, 0, 0, 0, egScreenWidth, egScreenHeight, 0); 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
} }
} }
#endif
VOID egDrawImageArea(IN EG_IMAGE *Image, VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight, IN INTN AreaWidth, IN INTN AreaHeight,

View File

@ -239,7 +239,12 @@ VOID PrepareFont()
// load the font // load the font
if (FontImage == NULL){ if (FontImage == NULL){
DBG("load font image type %d\n", GlobalConfig.Font); #if USE_XTHEME
DBG("load font image type %d\n", ThemeX.Font);
#else
DBG("load font image type %d\n", GlobalConfig.Font);
#endif
FontImage = egLoadFontImage(TRUE, 16, 16); //anyway success FontImage = egLoadFontImage(TRUE, 16, 16); //anyway success
} }
@ -257,6 +262,8 @@ VOID PrepareFont()
} }
} }
} }
DBG("Font %d prepared WxH=%lldx%lld CharWidth=%lld\n", ThemeX.Font, FontWidth, FontHeight, ThemeX.CharWidth);
#else #else
if (GlobalConfig.Font == FONT_GRAY) { if (GlobalConfig.Font == FONT_GRAY) {
//invert the font. embedded is dark //invert the font. embedded is dark
@ -270,10 +277,11 @@ VOID PrepareFont()
} }
} }
} }
DBG("Font %d prepared WxH=%lldx%lld CharWidth=%lld\n", GlobalConfig.Font, FontWidth, FontHeight, GlobalConfig.CharWidth);
#endif #endif
// TextHeight = FontHeight + TEXT_YMARGIN * 2; // TextHeight = FontHeight + TEXT_YMARGIN * 2;
DBG("Font %d prepared WxH=%lldx%lld CharWidth=%lld\n", GlobalConfig.Font, FontWidth, FontHeight, GlobalConfig.CharWidth);
} else { } else {
DBG("Failed to load font\n"); DBG("Failed to load font\n");
} }

View File

@ -513,8 +513,20 @@ extern INTN row0TileSize;
extern INTN row1TileSize; extern INTN row1TileSize;
#endif #endif
extern const INTN BCSMargin; extern const INTN BCSMargin;
#if USE_XTHEME
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueBackgroundPixel;
//extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel;
extern EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel;
#if !USE_XTHEME
#else
extern INTN LayoutBannerOffset; extern INTN LayoutBannerOffset;
extern INTN LayoutButtonOffset; extern INTN LayoutButtonOffset;
extern INTN LayoutTextOffset; extern INTN LayoutTextOffset;
@ -529,11 +541,12 @@ extern INTN UGAWidth;
extern INTN UGAHeight; extern INTN UGAHeight;
extern BOOLEAN AllowGraphicsMode; extern BOOLEAN AllowGraphicsMode;
#if !USE_XTHEME
extern EG_PIXEL StdBackgroundPixel; extern EG_PIXEL StdBackgroundPixel;
extern EG_PIXEL MenuBackgroundPixel; extern EG_PIXEL MenuBackgroundPixel;
extern EG_PIXEL InputBackgroundPixel; extern EG_PIXEL InputBackgroundPixel;
extern EG_PIXEL BlueBackgroundPixel; extern EG_PIXEL BlueBackgroundPixel;
extern EG_PIXEL DarkBackgroundPixel; //extern EG_PIXEL DarkBackgroundPixel;
extern EG_PIXEL SelectionBackgroundPixel; extern EG_PIXEL SelectionBackgroundPixel;
extern EG_PIXEL DarkEmbeddedBackgroundPixel; extern EG_PIXEL DarkEmbeddedBackgroundPixel;
extern EG_PIXEL DarkSelectionPixel; extern EG_PIXEL DarkSelectionPixel;
@ -542,7 +555,7 @@ extern EG_PIXEL BlackPixel;
extern EG_RECT BannerPlace; extern EG_RECT BannerPlace;
extern EG_IMAGE *BackgroundImage; extern EG_IMAGE *BackgroundImage;
#endif
#if REFIT_DEBUG > 0 #if REFIT_DEBUG > 0
VOID DebugPause(VOID); VOID DebugPause(VOID);

View File

@ -533,7 +533,7 @@ NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CONST CHAR16
// //
// EFI OS loader functions // EFI OS loader functions
// //
EG_PIXEL DarkBackgroundPixel = { 0x0, 0x0, 0x0, 0xFF }; //EG_PIXEL DarkBackgroundPixel = { 0x0, 0x0, 0x0, 0xFF };
VOID CheckEmptyFB() VOID CheckEmptyFB()
{ {
@ -645,8 +645,12 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
DBG("Image is not loaded, status=%s\n", strerror(Status)); DBG("Image is not loaded, status=%s\n", strerror(Status));
return; // no reason to continue if loading image failed return; // no reason to continue if loading image failed
} }
#if USE_XTHEME
egClearScreen(&Entry->BootBgColor); //if not set then it is already MenuBackgroundPixel
#else
egClearScreen(Entry->BootBgColor ? Entry->BootBgColor : &MenuBackgroundPixel);
#endif
egClearScreen(Entry->BootBgColor ? Entry->BootBgColor : &DarkBackgroundPixel);
// KillMouse(); // KillMouse();
// if (Entry->LoaderType == OSTYPE_OSX) { // if (Entry->LoaderType == OSTYPE_OSX) {
@ -1021,14 +1025,17 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
RemoveStartupDiskVolume(); RemoveStartupDiskVolume();
} }
egClearScreen(&DarkBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
#if USE_XTHEME #if USE_XTHEME
egClearScreen(&MenuBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
XImage BootLogoX; XImage BootLogoX;
BootLogoX.LoadXImage(ThemeDir, Entry->Volume->LegacyOS->IconName); BootLogoX.LoadXImage(ThemeDir, Entry->Volume->LegacyOS->IconName);
BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1, BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1,
(UGAHeight - BootLogoX.GetHeight()) >> 1); (UGAHeight - BootLogoX.GetHeight()) >> 1);
#else #else
egClearScreen(&MenuBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
EG_IMAGE *BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE); EG_IMAGE *BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE);
if (BootLogoImage != NULL) { if (BootLogoImage != NULL) {
BltImageAlpha(BootLogoImage, BltImageAlpha(BootLogoImage,
@ -1073,7 +1080,7 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
static VOID StartTool(IN REFIT_MENU_ENTRY_LOADER_TOOL *Entry) static VOID StartTool(IN REFIT_MENU_ENTRY_LOADER_TOOL *Entry)
{ {
DBG("Start Tool: %ls\n", Entry->LoaderPath); DBG("Start Tool: %ls\n", Entry->LoaderPath);
egClearScreen(&DarkBackgroundPixel); egClearScreen(&MenuBackgroundPixel);
// assumes "Start <title>" as assigned below // assumes "Start <title>" as assigned below
BeginExternalScreen(OSFLAG_ISSET(Entry->Flags, OSFLAG_USEGRAPHICS)/*, &Entry->Title[6]*/); // Shouldn't we check that length of Title is at least 6 ? BeginExternalScreen(OSFLAG_ISSET(Entry->Flags, OSFLAG_USEGRAPHICS)/*, &Entry->Title[6]*/); // Shouldn't we check that length of Title is at least 6 ?
StartEFIImage(Entry->DevicePath, Entry->LoadOptions, Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), NULL, NULL); StartEFIImage(Entry->DevicePath, Entry->LoadOptions, Basename(Entry->LoaderPath), Basename(Entry->LoaderPath), NULL, NULL);
@ -2022,7 +2029,10 @@ RefitMain (IN EFI_HANDLE ImageHandle,
BOOLEAN UniteConfigs = FALSE; BOOLEAN UniteConfigs = FALSE;
EFI_TIME Now; EFI_TIME Now;
BOOLEAN HaveDefaultVolume; BOOLEAN HaveDefaultVolume;
#if !USE_XTHEME #if USE_XTHEME
REFIT_MENU_SCREEN BootScreen;
BootScreen.isBootScreen = true; //other screens will be constructed as false
#else
CHAR16 *FirstMessage; CHAR16 *FirstMessage;
#endif #endif
// CHAR16 *InputBuffer; //, *Y; // CHAR16 *InputBuffer; //, *Y;
@ -2085,7 +2095,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif #endif
construct_globals_objects(); // do this after SelfLoadedImage is initialized construct_globals_objects(); // do this after SelfLoadedImage is initialized
all_tests(); // all_tests();
//dumping SETTING structure //dumping SETTING structure
// if you change something in Platform.h, please uncomment and test that all offsets // if you change something in Platform.h, please uncomment and test that all offsets
@ -2322,8 +2332,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) { if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME #if USE_XTHEME
XStringW Message = SWPrintf(" Welcome to Clover %ls ", gFirmwareRevision); XStringW Message = SWPrintf(" Welcome to Clover %ls ", gFirmwareRevision);
DrawTextXY(Message, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER); BootScreen.DrawTextXY(Message, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER);
DrawTextXY(L"... testing hardware ..."_XSW, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); BootScreen.DrawTextXY(L"... testing hardware ..."_XSW, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else #else
FirstMessage = PoolPrint(L" Welcome to Clover %s ", gFirmwareRevision); FirstMessage = PoolPrint(L" Welcome to Clover %s ", gFirmwareRevision);
DrawTextXY(FirstMessage, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER); DrawTextXY(FirstMessage, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER);
@ -2393,7 +2403,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) { if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME #if USE_XTHEME
XStringW Message = SWPrintf("... user settings ..."); XStringW Message = SWPrintf("... user settings ...");
DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); BootScreen.EraseTextXY();
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else #else
FirstMessage = PoolPrint(L"... user settings ..."); FirstMessage = PoolPrint(L"... user settings ...");
// i = (UGAWidth - StrLen(FirstMessage) * GlobalConfig.CharWidth) >> 1; // i = (UGAWidth - StrLen(FirstMessage) * GlobalConfig.CharWidth) >> 1;
@ -2470,7 +2481,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) { if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME #if USE_XTHEME
XStringW Message = SWPrintf("... scan entries ..."); XStringW Message = SWPrintf("... scan entries ...");
DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); BootScreen.EraseTextXY();
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else #else
FirstMessage = PoolPrint(L"... scan entries ..."); FirstMessage = PoolPrint(L"... scan entries ...");
DrawTextXY(FirstMessage, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); DrawTextXY(FirstMessage, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
@ -2662,8 +2674,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// font already changed and this message very quirky, clear line here // font already changed and this message very quirky, clear line here
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) { if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
#if USE_XTHEME #if USE_XTHEME
XStringW Message = L" "_XSW; // XStringW Message = L" "_XSW;
DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); BootScreen.EraseTextXY();
// DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#else #else
DrawTextXY(L" ", (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); DrawTextXY(L" ", (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
#endif #endif
@ -2678,7 +2691,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif #endif
DefaultIndex = FindDefaultEntry(); DefaultIndex = FindDefaultEntry();
DBG("DefaultIndex=%lld and MainMenu.Entries.size()=%llu\n", DefaultIndex, MainMenu.Entries.size()); // DBG("DefaultIndex=%lld and MainMenu.Entries.size()=%llu\n", DefaultIndex, MainMenu.Entries.size());
if ((DefaultIndex >= 0) && (DefaultIndex < (INTN)MainMenu.Entries.size())) { if ((DefaultIndex >= 0) && (DefaultIndex < (INTN)MainMenu.Entries.size())) {
DefaultEntry = &MainMenu.Entries[DefaultIndex]; DefaultEntry = &MainMenu.Entries[DefaultIndex];
} else { } else {
@ -2715,7 +2728,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MainMenu.AnimeRun = MainAnime; MainMenu.AnimeRun = MainAnime;
MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry); MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry);
} }
DBG("exit from MainMenu %llu\n", MenuExit); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3 // DBG("exit from MainMenu %llu\n", MenuExit); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3
// disable default boot - have sense only in the first run // disable default boot - have sense only in the first run
GlobalConfig.Timeout = -1; GlobalConfig.Timeout = -1;
if ((DefaultEntry != NULL) && (MenuExit == MENU_EXIT_TIMEOUT)) { if ((DefaultEntry != NULL) && (MenuExit == MENU_EXIT_TIMEOUT)) {

View File

@ -209,8 +209,9 @@ INTN OldChosenDsdt;
UINTN OldChosenAudio; UINTN OldChosenAudio;
UINT8 DefaultAudioVolume = 70; UINT8 DefaultAudioVolume = 70;
//INTN NewChosenTheme; //INTN NewChosenTheme;
INTN TextStyle; //why global? #if !USE_XTHEME
INTN TextStyle; //why global? It will be class SCREEN member
#endif
BOOLEAN mGuiReady = FALSE; BOOLEAN mGuiReady = FALSE;
@ -3132,7 +3133,7 @@ VOID REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
#if USE_XTHEME #if USE_XTHEME
INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) INTN REFIT_MENU_SCREEN::DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign)
{ {
INTN TextWidth = 0; INTN TextWidth = 0;
INTN XText = 0; INTN XText = 0;
@ -3144,6 +3145,8 @@ INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XA
if (Text.isEmpty()) { if (Text.isEmpty()) {
return 0; return 0;
} }
//TODO assume using embedded font for BootScreen
//messages must be TextXYStyle = 1 if it is provided by theme
if (!textFace[1].valid) { if (!textFace[1].valid) {
if (textFace[2].valid) { if (textFace[2].valid) {
TextXYStyle = 2; TextXYStyle = 2;
@ -3151,7 +3154,12 @@ INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XA
TextXYStyle = 0; TextXYStyle = 0;
} }
} }
/*
* here we want to know how many place is needed for the graphical text
* the procedure worked for fixed width font but the problem appears with proportional fonts
* as well we not know yet the font using but egRenderText calculate later real width
* so make a place to be large enoungh
*/
egMeasureText(Text.data(), &TextWidth, NULL); egMeasureText(Text.data(), &TextWidth, NULL);
if (XAlign == X_IS_LEFT) { if (XAlign == X_IS_LEFT) {
@ -3159,7 +3167,7 @@ INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XA
XText = XPos; XText = XPos;
} }
if (ThemeX.TypeSVG) { if (!isBootScreen && ThemeX.TypeSVG) {
TextWidth += TextHeight * 2; //give more place for buffer TextWidth += TextHeight * 2; //give more place for buffer
if (!textFace[TextXYStyle].valid) { if (!textFace[TextXYStyle].valid) {
DBG("no vaid text face for message!\n"); DBG("no vaid text face for message!\n");
@ -3173,21 +3181,39 @@ INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XA
// TextBufferXY = egCreateFilledImage(TextWidth, Height, TRUE, &MenuBackgroundPixel); // TextBufferXY = egCreateFilledImage(TextWidth, Height, TRUE, &MenuBackgroundPixel);
TextBufferXY.setSizeInPixels(TextWidth, Height); TextBufferXY.setSizeInPixels(TextWidth, Height);
TextBufferXY.Fill(&MenuBackgroundPixel); TextBufferXY.Fill(MenuBackgroundPixel);
// render the text // render the text
TextWidth = egRenderText(Text, &TextBufferXY, 0, 0, 0xFFFF, TextXYStyle); INTN TextWidth2 = egRenderText(Text, &TextBufferXY, 0, 0, 0xFFFF, TextXYStyle);
/* there is real text width but we already have an array with Width = TextWidth
*/
TextBufferXY.EnsureImageSize(TextWidth2, Height); //assume color = MenuBackgroundPixel
if (XAlign != X_IS_LEFT) { if (XAlign != X_IS_LEFT) {
// shift 64 is prohibited // shift 64 is prohibited
XText = XPos - (TextWidth >> XAlign); //X_IS_CENTER = 1 XText = XPos - (TextWidth2 >> XAlign); //X_IS_CENTER = 1
} }
OldTextBufferRect.XPos = XText;
OldTextBufferRect.YPos = YPos;
OldTextBufferRect.Width = TextWidth2;
OldTextBufferRect.Height = Height;
OldTextBufferImage.GetArea(OldTextBufferRect);
//GetArea may change sizes
OldTextBufferRect.Width = OldTextBufferImage.GetWidth();
OldTextBufferRect.Height = OldTextBufferImage.GetHeight();
// DBG("draw text %ls\n", Text); // DBG("draw text %ls\n", Text);
// DBG("pos=%d width=%d xtext=%d Height=%d Y=%d\n", XPos, TextWidth, XText, Height, YPos); // DBG("pos=%d width=%d xtext=%d Height=%d Y=%d\n", XPos, TextWidth, XText, Height, YPos);
// BltImageAlpha(TextBufferXY, XText, YPos, &MenuBackgroundPixel, 16); // TextBufferXY.Draw(XText, YPos);
// egFreeImage(TextBufferXY); TextBufferXY.DrawWithoutCompose(XText, YPos);
TextBufferXY.Draw(XText, YPos); return TextWidth2;
return TextWidth; }
void REFIT_MENU_SCREEN::EraseTextXY()
{
OldTextBufferImage.Draw(OldTextBufferRect.XPos, OldTextBufferRect.YPos);
} }
#else #else
@ -3251,7 +3277,7 @@ INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAli
* Helper function to draw text for Boot Camp Style. * Helper function to draw text for Boot Camp Style.
* @author: Needy * @author: Needy
*/ */
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign)
{ {
// check if text was provided // check if text was provided
if (!Text) { if (!Text) {
@ -3339,14 +3365,14 @@ VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAl
} }
#if USE_XTHEME #if USE_XTHEME
VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor)
{ {
XImage TextBufferX(UGAWidth-XPos, TextHeight); XImage TextBufferX(UGAWidth-XPos, TextHeight);
if (Cursor != 0xFFFF) { if (Cursor != 0xFFFF) {
TextBufferX.Fill(&MenuBackgroundPixel); TextBufferX.Fill(MenuBackgroundPixel);
} else { } else {
TextBufferX.Fill(&InputBackgroundPixel); TextBufferX.Fill(InputBackgroundPixel);
} }
@ -3355,12 +3381,12 @@ VOID DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INT
EG_RECT TextRect; EG_RECT TextRect;
TextRect.Width = SelectedWidth; TextRect.Width = SelectedWidth;
TextRect.Height = TextHeight; TextRect.Height = TextHeight;
TextBufferX.FillArea(&SelectionBackgroundPixel, TextRect); TextBufferX.FillArea(SelectionBackgroundPixel, TextRect);
} }
// render the text // render the text
if (ThemeX.TypeSVG) { if (ThemeX.TypeSVG) {
//clovy - text veltically centred on Height //clovy - text vertically centred on Height
egRenderText(Text, &TextBufferX, 0, egRenderText(Text, &TextBufferX, 0,
(INTN)((TextHeight - (textFace[TextStyle].size * ThemeX.Scale)) / 2), (INTN)((TextHeight - (textFace[TextStyle].size * ThemeX.Scale)) / 2),
Cursor, TextStyle); Cursor, TextStyle);
@ -3758,6 +3784,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
if (InfoLines.size() > 0) { if (InfoLines.size() > 0) {
// DrawMenuText(NULL, 0, 0, 0, 0); // DrawMenuText(NULL, 0, 0, 0, 0);
//EraseTextXY(); //but we should make it complementare to DrawMenuText
for (UINTN i = 0; i < InfoLines.size(); i++) { for (UINTN i = 0; i < InfoLines.size(); i++) {
DrawMenuText(InfoLines[i], 0, EntriesPosX, EntriesPosY, 0xFFFF); DrawMenuText(InfoLines[i], 0, EntriesPosX, EntriesPosY, 0xFFFF);
EntriesPosY += TextHeight; EntriesPosY += TextHeight;
@ -3774,11 +3801,11 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
case MENU_FUNCTION_PAINT_ALL: case MENU_FUNCTION_PAINT_ALL:
// DrawMenuText(NULL, 0, 0, 0, 0); //should clean every line to avoid artefacts // DrawMenuText(NULL, 0, 0, 0, 0); //should clean every line to avoid artefacts
DBG("PAINT_ALL: EntriesPosY=%lld MaxVisible=%lld\n", EntriesPosY, ScrollState.MaxVisible); // DBG("PAINT_ALL: EntriesPosY=%lld MaxVisible=%lld\n", EntriesPosY, ScrollState.MaxVisible);
DBG("DownButton.Height=%lld TextHeight=%lld\n", DownButton.Height, TextHeight); // DBG("DownButton.Height=%lld TextHeight=%lld\n", DownButton.Height, TextHeight);
t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height; t2 = EntriesPosY + (ScrollState.MaxVisible + 1) * TextHeight - DownButton.Height;
t1 = EntriesPosX + TextHeight + MenuWidth + (INTN)((TEXT_XMARGIN + 16) * ThemeX.Scale); t1 = EntriesPosX + TextHeight + MenuWidth + (INTN)((TEXT_XMARGIN + 16) * ThemeX.Scale);
DBG("PAINT_ALL: %lld %lld\n", t1, t2); // DBG("PAINT_ALL: %lld %lld\n", t1, t2);
SetBar(t1, EntriesPosY, t2, &ScrollState); //823 302 554 SetBar(t1, EntriesPosY, t2, &ScrollState); //823 302 554
// blackosx swapped this around so drawing of selection comes before drawing scrollbar. // blackosx swapped this around so drawing of selection comes before drawing scrollbar.
@ -3834,10 +3861,11 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
} }
} else if (Entry->getREFIT_MENU_CHECKBIT()) { } else if (Entry->getREFIT_MENU_CHECKBIT()) {
// DrawMenuText(XStringW().takeValueFrom(" "), 0, EntriesPosX, Entry->Place.YPos, 0xFFFF); //clean the place // DrawMenuText(XStringW().takeValueFrom(" "), 0, EntriesPosX, Entry->Place.YPos, 0xFFFF); //clean the place
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0, ThemeX.FillRectAreaOfScreen(ctrlTextX, Entry->Place.YPos, MenuWidth, TextHeight);
DrawMenuText(ResultString, (i == ScrollState.CurrentSelection) ? (MenuWidth) : 0,
ctrlTextX, ctrlTextX,
Entry->Place.YPos, 0xFFFF); Entry->Place.YPos, 0xFFFF);
ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->IValue & Entry->Row)?3:2].Draw(ctrlX, ctrlY); ThemeX.Buttons[(((REFIT_INPUT_DIALOG*)(Entry))->Item->IValue & Entry->Row)?3:2].Draw(ctrlX, ctrlY);
} else if (Entry->getREFIT_MENU_SWITCH()) { } else if (Entry->getREFIT_MENU_SWITCH()) {
if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 3) { if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 3) {
//OldChosenItem = OldChosenTheme; //OldChosenItem = OldChosenTheme;
@ -3898,7 +3926,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
DrawMenuText(ResultString, 0, DrawMenuText(ResultString, 0,
ctrlTextX, ctrlTextX,
EntryL->Place.YPos, 0xFFFF); EntryL->Place.YPos, 0xFFFF);
ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre); ThemeX.Buttons[(inputDialogEntry->Item->BValue)?3:2].Draw(ctrlX, EntryL->Place.YPos + PlaceCentre);
// DBG("se:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale), // DBG("se:X=%d, Y=%d, ImageY=%d\n", EntriesPosX + (INTN)(TEXT_XMARGIN * GlobalConfig.Scale),
// EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre); // EntryL->Place.YPos, EntryL->Place.YPos + PlaceCentre);
} else { } else {
@ -4657,7 +4685,7 @@ VOID REFIT_MENU_SCREEN::CountItems()
} }
} }
#if USE_XTHEME #if USE_XTHEME
VOID DrawTextCorner(UINTN TextC, UINT8 Align) VOID REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align)
{ {
INTN Xpos; INTN Xpos;
// CHAR16 *Text = NULL; // CHAR16 *Text = NULL;
@ -4843,7 +4871,7 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16
// Update FilmPlace only if not set by InitAnime // Update FilmPlace only if not set by InitAnime
if (FilmPlace.Width == 0 || FilmPlace.Height == 0) { if (FilmPlace.Width == 0 || FilmPlace.Height == 0) {
// CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace)); // CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace));
FilmPlace = BannerPlace; FilmPlace = ThemeX.BannerPlace;
} }
ThemeX.InitBar(); ThemeX.InitBar();
@ -5169,7 +5197,7 @@ VOID REFIT_MENU_SCREEN::MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT
// Update FilmPlace only if not set by InitAnime // Update FilmPlace only if not set by InitAnime
if (FilmPlace.Width == 0 || FilmPlace.Height == 0) { if (FilmPlace.Width == 0 || FilmPlace.Height == 0) {
// CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace)); // CopyMem(&FilmPlace, &BannerPlace, sizeof(BannerPlace));
FilmPlace = BannerPlace; FilmPlace = ThemeX.BannerPlace;
} }
//DBG("main menu inited\n"); //DBG("main menu inited\n");

View File

@ -10,7 +10,8 @@
VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry); VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
VOID FreeScrollBar(VOID); VOID FreeScrollBar(VOID);
#if USE_XTHEME #if USE_XTHEME
INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); //it will be REFIT_SCREEN MEMBER, others as well?
//INTN DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor); VOID DrawMenuText(IN const XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor);
#else #else
INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);

View File

@ -80,6 +80,18 @@ INTN UGAHeight;
BOOLEAN AllowGraphicsMode; BOOLEAN AllowGraphicsMode;
EG_RECT BannerPlace; // default ctor called, so it's zero EG_RECT BannerPlace; // default ctor called, so it's zero
#if USE_XTHEME
EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueBackgroundPixel = { 0x7f, 0x0f, 0x0f, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL EmbeddedBackgroundPixel = { 0xaa, 0xaa, 0xaa, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkSelectionPixel = { 66, 66, 66, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
EFI_GRAPHICS_OUTPUT_BLT_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
#else
EG_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff}; EG_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
EG_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00}; EG_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
@ -90,10 +102,12 @@ EG_PIXEL DarkSelectionPixel = { 66, 66, 66, 0xff};
EG_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff}; EG_PIXEL DarkEmbeddedBackgroundPixel = { 0x33, 0x33, 0x33, 0xff};
EG_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff}; EG_PIXEL WhitePixel = { 0xff, 0xff, 0xff, 0xff};
EG_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff}; EG_PIXEL BlackPixel = { 0x00, 0x00, 0x00, 0xff};
EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
EG_IMAGE *BackgroundImage = NULL; EG_IMAGE *BackgroundImage = NULL;
EG_IMAGE *Banner = NULL; EG_IMAGE *Banner = NULL;
EG_IMAGE *BigBack = NULL; EG_IMAGE *BigBack = NULL;
#endif
static BOOLEAN GraphicsScreenDirty; static BOOLEAN GraphicsScreenDirty;
@ -334,7 +348,7 @@ VOID SwitchToGraphicsAndClear(VOID) //called from MENU_FUNCTION_INIT
{ {
SwitchToGraphics(); SwitchToGraphics();
#if USE_XTHEME #if USE_XTHEME
DBG("clear screen and draw back\n"); // 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
@ -553,24 +567,45 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *
} }
// DBG("w=%d, h=%d\n", Width, Height); // DBG("w=%d, h=%d\n", Width, Height);
// compose on background // compose on background
#if USE_XTHEME
CompImage = egCreateFilledImage(Width, Height, !ThemeX.Background.isEmpty(), BackgroundPixel); //no matter
#else
CompImage = egCreateFilledImage(Width, Height, (BackgroundImage != NULL), BackgroundPixel); CompImage = egCreateFilledImage(Width, Height, (BackgroundImage != NULL), BackgroundPixel);
#endif
egComposeImage(CompImage, NewImage, 0, 0); egComposeImage(CompImage, NewImage, 0, 0);
if (NewImage) { if (NewImage) {
egFreeImage(NewImage); egFreeImage(NewImage);
} }
#if USE_XTHEME
if (ThemeX.Background.isEmpty()) {
egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(CompImage);
return;
}
#else
if (!BackgroundImage) { if (!BackgroundImage) {
egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos); egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(CompImage); egFreeImage(CompImage);
return; return;
} }
#endif
NewImage = egCreateImage(Width, Height, FALSE); NewImage = egCreateImage(Width, Height, FALSE);
if (!NewImage) return; if (!NewImage) return;
// DBG("draw on background\n"); // DBG("draw on background\n");
#if USE_XTHEME
egRawCopy(NewImage->PixelData,
(EG_PIXEL*)ThemeX.Background.GetPixelPtr(0,0) + YPos * ThemeX.Background.GetWidth() + XPos,
Width, Height,
Width,
ThemeX.Background.GetWidth());
#else
egRawCopy(NewImage->PixelData, egRawCopy(NewImage->PixelData,
BackgroundImage->PixelData + YPos * BackgroundImage->Width + XPos, BackgroundImage->PixelData + YPos * BackgroundImage->Width + XPos,
Width, Height, Width, Height,
Width, Width,
BackgroundImage->Width); BackgroundImage->Width);
#endif
egComposeImage(NewImage, CompImage, 0, 0); egComposeImage(NewImage, CompImage, 0, 0);
egFreeImage(CompImage); egFreeImage(CompImage);
@ -934,7 +969,7 @@ VOID REFIT_MENU_SCREEN::UpdateAnime()
Now = AsmReadTsc(); Now = AsmReadTsc();
if (LastDraw == 0) { if (LastDraw == 0) {
//first start, we should save background into last frame //first start, we should save background into last frame
egFillImageArea(AnimeImage, 0, 0, AnimeImage->Width, AnimeImage->Height, &MenuBackgroundPixel); egFillImageArea(AnimeImage, 0, 0, AnimeImage->Width, AnimeImage->Height, (EG_PIXEL*)&MenuBackgroundPixel);
egTakeImage(Film[Frames], egTakeImage(Film[Frames],
x, y, x, y,
Film[Frames]->Width, Film[Frames]->Width,