avoid memset generation

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-02 16:46:30 +03:00
parent 1acd6a43b4
commit dcdd8cc091
10 changed files with 34 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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