From dcdd8cc09179ead1fa8d9ef39b16d23480364a04 Mon Sep 17 00:00:00 2001 From: Sergey Isakov Date: Mon, 2 Mar 2020 16:46:30 +0300 Subject: [PATCH] avoid memset generation Signed-off-by: Sergey Isakov --- rEFIt_UEFI/Platform/Settings.cpp | 4 ++-- rEFIt_UEFI/entry_scan/common.cpp | 4 ++-- rEFIt_UEFI/entry_scan/loader.cpp | 4 ++-- rEFIt_UEFI/entry_scan/tool.cpp | 8 ++++---- rEFIt_UEFI/gui/menu_items/menu_items.h | 9 +++++---- rEFIt_UEFI/libeg/XImage.cpp | 4 ++-- rEFIt_UEFI/libeg/XImage.h | 4 ++-- rEFIt_UEFI/libeg/XPointer.cpp | 9 +++++++-- rEFIt_UEFI/refit/IO.cpp | 11 ++++++----- rEFIt_UEFI/refit/menu.cpp | 4 ++-- 10 files changed, 34 insertions(+), 27 deletions(-) diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 616929894..5b3dac858 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -5076,8 +5076,8 @@ GetUserSettings( for (INTN j = 0; j < PropCount; j++) { Prop3 = NULL; DevProps = *Child; - // *Child = (__typeof_am__(*Child))AllocateZeroPool(sizeof(**Child)); - *Child = new (__typeof_am__(**Child))(); + *Child = (__typeof_am__(*Child))AllocateZeroPool(sizeof(**Child)); + // *Child = new (__typeof_am__(**Child))(); (*Child)->Next = DevProps; if (EFI_ERROR(GetElement(Prop2, j, &Prop3))) { // Prop3 -> diff --git a/rEFIt_UEFI/entry_scan/common.cpp b/rEFIt_UEFI/entry_scan/common.cpp index 752f937f7..a50f9a18d 100644 --- a/rEFIt_UEFI/entry_scan/common.cpp +++ b/rEFIt_UEFI/entry_scan/common.cpp @@ -149,8 +149,8 @@ LOADER_ENTRY * DuplicateLoaderEntry(IN LOADER_ENTRY *Entry) return NULL; } -// DuplicateEntry = (__typeof__(DuplicateEntry))AllocateZeroPool(sizeof(LOADER_ENTRY)); - DuplicateEntry = new LOADER_ENTRY(); + DuplicateEntry = (__typeof__(DuplicateEntry))AllocateZeroPool(sizeof(LOADER_ENTRY)); +// DuplicateEntry = new LOADER_ENTRY(); if (DuplicateEntry) { // DuplicateEntry->Tag = Entry->Tag; DuplicateEntry->AtClick = ActionEnter; diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index d124aa388..bcd1f2dbb 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -556,8 +556,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, } // prepare the menu entry -// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); - Entry = new LOADER_ENTRY(); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); +// Entry = new LOADER_ENTRY(); // Entry->Tag = TAG_LOADER; Entry->Row = 0; Entry->Volume = Volume; diff --git a/rEFIt_UEFI/entry_scan/tool.cpp b/rEFIt_UEFI/entry_scan/tool.cpp index 95877482d..61606e200 100644 --- a/rEFIt_UEFI/entry_scan/tool.cpp +++ b/rEFIt_UEFI/entry_scan/tool.cpp @@ -83,8 +83,8 @@ STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTi return FALSE; } // Allocate the entry -// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); - Entry = new REFIT_MENU_ENTRY_LOADER_TOOL(); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); +// Entry = new REFIT_MENU_ENTRY_LOADER_TOOL(); if (Entry == NULL) { return FALSE; } @@ -121,8 +121,8 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT // EFI_STATUS Status; // prepare the menu entry -// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); - Entry = new REFIT_MENU_ENTRY_CLOVER(); + Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); +// Entry = new REFIT_MENU_ENTRY_CLOVER(); Entry->Title = LoaderTitle; // Entry->Tag = TAG_CLOVER; Entry->Row = 1; diff --git a/rEFIt_UEFI/gui/menu_items/menu_items.h b/rEFIt_UEFI/gui/menu_items/menu_items.h index c17489b43..7bdb6d9a9 100644 --- a/rEFIt_UEFI/gui/menu_items/menu_items.h +++ b/rEFIt_UEFI/gui/menu_items/menu_items.h @@ -395,13 +395,14 @@ public: ACTION mAction; UINTN mItemID; XPointer *mPointer; + bool PointerLive; REFIT_MENU_SCREEN() : ID(0), Title(0), TitleImage(0), TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0), Frames(0), FrameTime(0), FilmPlace({0,0,0,0}), - Film(0) + Film(0), PointerLive(false) {}; REFIT_MENU_SCREEN( UINTN ID_, @@ -425,7 +426,7 @@ public: TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_), Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_), Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_), - Film(Film_) + Film(Film_), PointerLive(false) {}; REFIT_MENU_SCREEN( UINTN ID_, @@ -450,7 +451,7 @@ public: TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_), Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_), Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_), - Film(Film_) + Film(Film_), PointerLive(false) { Entries.AddReference(entry, false); }; @@ -478,7 +479,7 @@ public: TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_), Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_), Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_), - Film(Film_) + Film(Film_), PointerLive(false) { Entries.AddReference(entry1, false); Entries.AddReference(entry2, false); diff --git a/rEFIt_UEFI/libeg/XImage.cpp b/rEFIt_UEFI/libeg/XImage.cpp index 44920259d..830e53a2d 100644 --- a/rEFIt_UEFI/libeg/XImage.cpp +++ b/rEFIt_UEFI/libeg/XImage.cpp @@ -197,7 +197,7 @@ void XImage::CopyScaled(const XImage& Image, float scale) } } -void XImage::Compose(int PosX, int PosY, const XImage& TopImage, bool Lowest) //lowest image is opaque +void XImage::Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest) //lowest image is opaque { UINT32 TopAlpha; UINT32 RevAlpha; @@ -365,7 +365,7 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H) Height = AreaHeight; } -void XImage::Draw(int x, int y, float scale) +void XImage::Draw(INTN x, INTN y, float scale) { //prepare images INTN ScreenWidth = 0; diff --git a/rEFIt_UEFI/libeg/XImage.h b/rEFIt_UEFI/libeg/XImage.h index 545868ed0..a1a581aae 100644 --- a/rEFIt_UEFI/libeg/XImage.h +++ b/rEFIt_UEFI/libeg/XImage.h @@ -66,14 +66,14 @@ public: void Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color = { 0, 0, 0, 0 }); void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, const EgRect& Rect); void CopyScaled(const XImage& Image, float scale); - void Compose(int PosX, int PosY, const XImage& TopImage, bool Lowest); //instead of compose we can Back.Draw(...) + Top.Draw(...) + void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we can Back.Draw(...) + Top.Draw(...) void FlipRB(bool WantAlpha); unsigned FromPNG(const UINT8 * Data, UINTN Lenght); unsigned ToPNG(UINT8** Data, UINTN& OutSize); unsigned FromSVG(const CHAR8 *SVGData, UINTN SVGDataLength, float scale); void GetArea(const EG_RECT& Rect); void GetArea(INTN x, INTN y, UINTN W, UINTN H); - void Draw(int x, int y, float scale); + void Draw(INTN x, INTN y, float scale); }; #endif //__XSTRINGW_H__ diff --git a/rEFIt_UEFI/libeg/XPointer.cpp b/rEFIt_UEFI/libeg/XPointer.cpp index 34fb255a9..0e903fcd6 100644 --- a/rEFIt_UEFI/libeg/XPointer.cpp +++ b/rEFIt_UEFI/libeg/XPointer.cpp @@ -1,8 +1,13 @@ /* * a class for mouse support */ - +#ifdef __cplusplus +extern "C" { +#endif #include "Library/BaseLib.h" +#ifdef __cplusplus +} +#endif #include "XPointer.h" #include "libegint.h" //this includes platform.h #include "../refit/screen.h" @@ -79,7 +84,7 @@ EFI_STATUS XPointer::MouseBirth() return Status; } - PointerImage = BuiltinIcon(BUILTIN_ICON_POINTER); + PointerImage = new XImage(BuiltinIcon(BUILTIN_ICON_POINTER)); if (!PointerImage) { //this is impossible after BuiltinIcon DBG("No pointer image!\n"); diff --git a/rEFIt_UEFI/refit/IO.cpp b/rEFIt_UEFI/refit/IO.cpp index bccf63f39..36888ff28 100644 --- a/rEFIt_UEFI/refit/IO.cpp +++ b/rEFIt_UEFI/refit/IO.cpp @@ -23,6 +23,7 @@ Revision History //#include "EfiShellLib.h" #include "Platform.h" +#include "screen.h" #define PRINT_STRING_LEN 1024 #define PRINT_ITEM_BUFFER_LEN 100 @@ -1061,7 +1062,7 @@ WaitFor2EventWithTsc ( // TimeoutDefault for a wait in seconds // return EFI_TIMEOUT if no inputs //the function must be in menu class -//so UpdatePointer(); => Pointer.Update(&gItemID, &gAction); +//so UpdatePointer(); => mPointer.Update(&gItemID, &gAction); EFI_STATUS WaitForInputEventPoll(REFIT_MENU_SCREEN *Screen, UINTN TimeoutDefault) { EFI_STATUS Status = EFI_SUCCESS; @@ -1075,7 +1076,7 @@ EFI_STATUS WaitForInputEventPoll(REFIT_MENU_SCREEN *Screen, UINTN TimeoutDefault if (Status != EFI_TIMEOUT) { break; } - UpdateAnime(Screen, &(Screen->FilmPlace)); + UpdateAnime(Screen, &(Screen->FilmPlace)); //should be moved to REFIT_MENU_SCREEN class if (gSettings.PlayAsync) { CheckSyncSound(); } @@ -1083,9 +1084,9 @@ EFI_STATUS WaitForInputEventPoll(REFIT_MENU_SCREEN *Screen, UINTN TimeoutDefault UpdateAnime(Screen->Entries[gItemID].SubScreen, &(Screen->Entries[gItemID].Place)); } */ TimeoutRemain--; - if (gPointer.SimplePointerProtocol) { - UpdatePointer(); - Status = CheckMouseEvent(Screen); //out: gItemID, gAction + if (Screen->PointerLive) { + Screen->mPointer->UpdatePointer(); + Status = Screen->mPointer->CheckMouseEvent(Screen); //out: gItemID, gAction if (Status != EFI_TIMEOUT) { //this check should return timeout if no mouse events occured break; } diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 5f519daa7..36678cf14 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -4400,8 +4400,8 @@ VOID NewEntry(REFIT_MENU_ENTRY_OTHER **Entry, REFIT_MENU_SCREEN **SubScreen, ACT VOID NewEntry(LOADER_ENTRY **Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title) { //create entry -// *Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof. - *Entry = new LOADER_ENTRY(); + *Entry = (__typeof_am__(*Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); // carefull, **Entry is not a LOADER_ENTRY. Don't use sizeof. +// *Entry = new LOADER_ENTRY(); NewEntry_(*Entry, SubScreen, AtClick, ID, Title); // cast ok because super class }