From 5b1c65486c04464bff6501dfac54933dbef98262 Mon Sep 17 00:00:00 2001 From: jief Date: Mon, 2 Mar 2020 18:43:54 +0300 Subject: [PATCH] XPointer revisited. --- rEFIt_UEFI/Platform/Pointer.h | 5 ----- rEFIt_UEFI/cpp_foundation/XArray.h | 2 +- rEFIt_UEFI/libeg/XImage.h | 15 ++++++++++++--- rEFIt_UEFI/libeg/XPointer.cpp | 31 +++++++++++++----------------- rEFIt_UEFI/libeg/XPointer.h | 8 ++++---- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/rEFIt_UEFI/Platform/Pointer.h b/rEFIt_UEFI/Platform/Pointer.h index 857686a0f..8b1378917 100644 --- a/rEFIt_UEFI/Platform/Pointer.h +++ b/rEFIt_UEFI/Platform/Pointer.h @@ -1,6 +1 @@ -EFI_STATUS -WaitForInputEventPoll ( - REFIT_MENU_SCREEN *Screen, - UINTN TimeoutDefault - ); diff --git a/rEFIt_UEFI/cpp_foundation/XArray.h b/rEFIt_UEFI/cpp_foundation/XArray.h index 20f8d6835..6ff160810 100755 --- a/rEFIt_UEFI/cpp_foundation/XArray.h +++ b/rEFIt_UEFI/cpp_foundation/XArray.h @@ -145,7 +145,7 @@ const XArray &XArray::operator =(const XArray &anArray) xsize ui; setEmpty(); - for ( ui=0 ; ui +//#include // -//#include "../cpp_foundation/XToolsCommon.h" -//#include "../cpp_foundation/XArray.h" + +extern "C" { +#include +} +#include "../cpp_foundation/XToolsCommon.h" +#include "../cpp_foundation/XArray.h" +#include "../libeg/libeg.h" //#include "lodepng.h" // //#include "nanosvg.h" @@ -63,6 +68,10 @@ public: UINTN GetWidth() const; UINTN GetHeight() const; + void setEmpty() { PixelData.setEmpty(); } + bool isEmpty() const { return PixelData.size() == 0; } + + 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); diff --git a/rEFIt_UEFI/libeg/XPointer.cpp b/rEFIt_UEFI/libeg/XPointer.cpp index 0e903fcd6..724ca374f 100644 --- a/rEFIt_UEFI/libeg/XPointer.cpp +++ b/rEFIt_UEFI/libeg/XPointer.cpp @@ -31,25 +31,21 @@ extern "C" { #define POINTER_HEIGHT 32 XPointer::XPointer() + : PointerImage(BuiltinIcon(BUILTIN_ICON_POINTER)), + newImage(POINTER_WIDTH, POINTER_HEIGHT), + oldImage(POINTER_WIDTH, POINTER_HEIGHT) { - PointerImage = new XImage(BuiltinIcon(BUILTIN_ICON_POINTER)); - - oldImage = new XImage(POINTER_WIDTH, POINTER_HEIGHT); - newImage = new XImage(POINTER_WIDTH, POINTER_HEIGHT); } XPointer::~XPointer() { - delete PointerImage; - delete newImage; - delete oldImage; } void XPointer::Hide() { if (SimplePointerProtocol) { - oldImage->Draw(oldPlace.XPos, oldPlace.YPos, 1.f); + oldImage.Draw(oldPlace.XPos, oldPlace.YPos, 1.f); } } @@ -83,9 +79,8 @@ EFI_STATUS XPointer::MouseBirth() gSettings.PointerEnabled = FALSE; return Status; } - - PointerImage = new XImage(BuiltinIcon(BUILTIN_ICON_POINTER)); - if (!PointerImage) { + + if ( PointerImage.isEmpty() ) { //this is impossible after BuiltinIcon DBG("No pointer image!\n"); SimplePointerProtocol = NULL; @@ -110,14 +105,14 @@ VOID XPointer::DrawPointer() { // take background image - oldImage->GetArea(newPlace); + oldImage.GetArea(newPlace); CopyMem(&oldPlace, &newPlace, sizeof(EG_RECT)); //can we use oldPlace = newPlace; ? // CopyMem(newImage->PixelData, oldImage->PixelData, (UINTN)(POINTER_WIDTH * POINTER_HEIGHT * sizeof(EG_PIXEL))); - newImage->CopyScaled(*oldImage, 1.f); + newImage.CopyScaled(oldImage, 1.f); - newImage->Compose(0, 0, *PointerImage, true); - newImage->Draw(newPlace.XPos, newPlace.YPos, 1.f); + newImage.Compose(0, 0, PointerImage, true); + newImage.Draw(newPlace.XPos, newPlace.YPos, 1.f); } VOID XPointer::KillMouse() @@ -127,10 +122,10 @@ VOID XPointer::KillMouse() return; } - delete newImage; - delete oldImage; + newImage.setEmpty(); + oldImage.setEmpty(); - delete PointerImage; +// delete PointerImage; MouseEvent = NoEvents; SimplePointerProtocol = NULL; diff --git a/rEFIt_UEFI/libeg/XPointer.h b/rEFIt_UEFI/libeg/XPointer.h index eb3b1daf0..464276b80 100644 --- a/rEFIt_UEFI/libeg/XPointer.h +++ b/rEFIt_UEFI/libeg/XPointer.h @@ -14,9 +14,9 @@ public: protected: EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol; - XImage *PointerImage; - XImage *newImage; - XImage *oldImage; + XImage PointerImage; + XImage newImage; + XImage oldImage; EG_RECT newPlace; EG_RECT oldPlace; @@ -37,4 +37,4 @@ public: protected: VOID DrawPointer(); -}; \ No newline at end of file +};