XPointer revisited.

This commit is contained in:
jief 2020-03-02 18:43:54 +03:00
parent dcdd8cc091
commit 5b1c65486c
5 changed files with 30 additions and 31 deletions

View File

@ -1,6 +1 @@
EFI_STATUS
WaitForInputEventPoll (
REFIT_MENU_SCREEN *Screen,
UINTN TimeoutDefault
);

View File

@ -145,7 +145,7 @@ const XArray<TYPE> &XArray<TYPE>::operator =(const XArray<TYPE> &anArray)
xsize ui;
setEmpty();
for ( ui=0 ; ui<anArray.Length() ; ui+=1 ) AddCopy(anArray.Data() );
for ( ui=0 ; ui<anArray.Length() ; ui+=1 ) Add(anArray[ui] );
return *this;
}

View File

@ -5,10 +5,15 @@ This class will replace EG_IMAGE structure and methods
#if !defined(__XIMAGE_H__)
#define __XIMAGE_H__
#include <Platform.h>
//#include <Platform.h>
//
//#include "../cpp_foundation/XToolsCommon.h"
//#include "../cpp_foundation/XArray.h"
extern "C" {
#include <Protocol/GraphicsOutput.h>
}
#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);

View File

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

View File

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