mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
draw in non-working state
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
5dbf1e0360
commit
c3103859b6
@ -19,34 +19,13 @@ XImage::XImage()
|
||||
{
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
#if USE_ARRAY
|
||||
PixelData = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
XImage::XImage(UINTN W, UINTN H)
|
||||
{
|
||||
Width = W;
|
||||
Height = H;
|
||||
#if !USE_ARRAY
|
||||
PixelData.CheckSize(GetWidth()*GetHeight()); // change the allocated size, but not the size. size is still 0 here. PixelData[0] won't work.
|
||||
PixelData.SetLength(GetWidth()*GetHeight());
|
||||
#else
|
||||
PixelData = (__typeof__(PixelData))AllocatePool(W * H * sizeof(*PixelData));
|
||||
#endif
|
||||
}
|
||||
|
||||
XImage::XImage(UINTN W, UINTN H, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Data)
|
||||
{
|
||||
Width = W;
|
||||
Height = H;
|
||||
#if !USE_ARRAY
|
||||
PixelData.CheckSize(GetWidth()*GetHeight()); // change the allocated size, but not the size. size is still 0 here. PixelData[0] won't work.
|
||||
PixelData.SetLength(GetWidth()*GetHeight());
|
||||
PixelData.AddArray(Data, W*H);
|
||||
#else
|
||||
PixelData = (__typeof__(PixelData))AllocateCopyPool(W * H * sizeof(*PixelData), Data);
|
||||
#endif
|
||||
PixelData.CheckSize(GetWidth()*GetHeight());
|
||||
}
|
||||
|
||||
XImage::XImage(EG_IMAGE* egImage)
|
||||
@ -58,15 +37,11 @@ XImage::XImage(EG_IMAGE* egImage)
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
}
|
||||
#if !USE_ARRAY
|
||||
PixelData.CheckSize(GetWidth()*GetHeight()); // change the allocated size, but not the size.
|
||||
PixelData.SetLength(GetWidth()*GetHeight()); // change the size, ie the number of element in the array
|
||||
if ( GetWidth()*GetHeight() > 0 ) {
|
||||
CopyMem(&PixelData[0], egImage->PixelData, PixelData.size() * sizeof(*egImage->PixelData));
|
||||
}
|
||||
#else
|
||||
PixelData = (__typeof__(PixelData))AllocateCopyPool(Width * Height * sizeof(*egImage->PixelData), egImage->PixelData);
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale)
|
||||
@ -81,10 +56,9 @@ XImage::XImage(const XImage& Image, float scale)
|
||||
UINTN SrcHeight = Image.GetHeight();
|
||||
Width = (UINTN)(SrcWidth * scale);
|
||||
Height = (UINTN)(SrcHeight * scale);
|
||||
#if !USE_ARRAY
|
||||
PixelData.CheckSize(GetWidth()*GetHeight());
|
||||
PixelData.SetLength(GetWidth()*GetHeight());
|
||||
#endif
|
||||
|
||||
if (scale < 1.e-4) return;
|
||||
CopyScaled(Image, scale);
|
||||
}
|
||||
@ -153,22 +127,12 @@ do { \
|
||||
|
||||
XImage::~XImage()
|
||||
{
|
||||
#if USE_ARRAY
|
||||
FreePool(PixelData);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !USE_ARRAY
|
||||
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& XImage::GetData() const
|
||||
{
|
||||
return PixelData;
|
||||
}
|
||||
#else
|
||||
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL* XImage::GetData() const
|
||||
{
|
||||
return &PixelData[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* XImage::GetPixelPtr(UINTN x, UINTN y)
|
||||
{
|
||||
@ -219,15 +183,9 @@ void XImage::CopyScaled(const XImage& Image, float scale)
|
||||
|
||||
int Pixel = sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
int Row = (int)SrcWidth * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
#if !USE_ARRAY
|
||||
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& Source = Image.GetData();
|
||||
#else
|
||||
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Source = Image.GetData();
|
||||
#endif
|
||||
|
||||
#if !USE_ARRAY
|
||||
PixelData.SetLength(Width*Height); // setLength BEFORE, so GetPixelPtr(x, y)
|
||||
#endif
|
||||
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& Source = Image.GetData();
|
||||
|
||||
for (UINTN y = 0; y < Height; y++)
|
||||
{
|
||||
int ly = (int)(y / scale);
|
||||
@ -393,15 +351,9 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
|
||||
|
||||
INTN AreaWidth = (x + W > (UINTN)UGAWidth) ? (UGAWidth - x) : W;
|
||||
INTN AreaHeight = (y + H > (UINTN)UGAHeight) ? ((UINTN)UGAHeight - y) : H;
|
||||
// INTN AreaWidth = (W > Width) ? W : Width;
|
||||
// INTN AreaHeight = (H > Height) ? H : Height;
|
||||
DBG("area is {%d, %d, %d, %d}\n", x, y, W, H);
|
||||
DBG("own width %d and area %d\n", Width, AreaWidth);
|
||||
|
||||
if (GraphicsOutput != NULL) {
|
||||
#if !USE_ARRAY
|
||||
PixelData.SetLength(AreaWidth*AreaHeight); // setLength BEFORE, so &PixelData[0]
|
||||
#endif
|
||||
INTN LineBytes = GraphicsOutput->Mode->Info->HorizontalResolution * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
GraphicsOutput->Blt(GraphicsOutput,
|
||||
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&PixelData[0],
|
||||
@ -417,9 +369,8 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
|
||||
if (EFI_ERROR(Status)) {
|
||||
return; // graphics not available
|
||||
}
|
||||
#if !USE_ARRAY
|
||||
|
||||
PixelData.SetLength(AreaWidth*AreaHeight); // setLength BEFORE, so &PixelData[0]
|
||||
#endif
|
||||
UgaDraw->Blt(UgaDraw,
|
||||
(EFI_UGA_PIXEL *)&PixelData[0],
|
||||
EfiUgaVideoToBltBuffer,
|
||||
@ -432,27 +383,14 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
|
||||
|
||||
void XImage::Draw(INTN x, INTN y, float scale)
|
||||
{
|
||||
// const EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueColor = { 200, 0, 0, 160 };
|
||||
//prepare images
|
||||
// INTN ScreenWidth = 0;
|
||||
// INTN ScreenHeight = 0;
|
||||
// egGetScreenSize(&ScreenWidth, &ScreenHeight);
|
||||
// DBG("1\n");
|
||||
// XImage* Background = new XImage(Width, Height);
|
||||
// DBG("2\n");
|
||||
// Background->GetArea(x, y, Width, Height); //from screen
|
||||
// DBG("3\n");
|
||||
// XImage Top(*this, 1.f);
|
||||
// XImage* Top = new XImage(Width, Height, GetData());
|
||||
// DBG("4\n");
|
||||
// Top.CopyScaled(*this, 1.f);
|
||||
// Top.Fill(BlueColor);
|
||||
// DBG("5\n");
|
||||
// Background.Compose(0, 0, Top, true);
|
||||
// DBG("6\n");
|
||||
XImage Top(*this, scale);
|
||||
XImage Background(UGAWidth, UGAHeight);
|
||||
Background.GetArea(x, y, Width, Height);
|
||||
|
||||
Background.Compose(0, 0, Top, false);
|
||||
UINTN AreaWidth = (x + Width > (UINTN)UGAWidth) ? (UGAWidth - x) : Width;
|
||||
UINTN AreaHeight = (y + Height > (UINTN)UGAHeight) ? (UGAHeight - y) : Height;
|
||||
// DBG("width: own=%d, Background=%d, Area=%d\n", Width, Background.GetWidth(), AreaWidth);
|
||||
|
||||
// prepare protocols
|
||||
EFI_STATUS Status;
|
||||
@ -469,19 +407,15 @@ void XImage::Draw(INTN x, INTN y, float scale)
|
||||
UgaDraw = NULL;
|
||||
}
|
||||
//output combined image
|
||||
// DBG("7\n");
|
||||
if (GraphicsOutput != NULL) {
|
||||
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GetPixelPtr(0,0),
|
||||
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Top.GetPixelPtr(0, 0),
|
||||
EfiBltBufferToVideo,
|
||||
0, 0, //source x,y
|
||||
x, y, //destination x,y
|
||||
0, 0, x, y,
|
||||
AreaWidth, AreaHeight, UGAWidth * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
}
|
||||
else if (UgaDraw != NULL) {
|
||||
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,
|
||||
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Background.GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,
|
||||
0, 0, x, y,
|
||||
AreaWidth, AreaHeight, UGAWidth * sizeof(EFI_UGA_PIXEL));
|
||||
}
|
||||
// delete Background;
|
||||
// delete Top;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ extern "C" {
|
||||
//#include "nanosvg.h"
|
||||
//#include "FloatLib.h"
|
||||
|
||||
#define USE_ARRAY 0
|
||||
|
||||
#if 0 //ndef EFI_GRAPHICS_OUTPUT_BLT_PIXEL
|
||||
typedef struct {
|
||||
@ -48,47 +47,30 @@ class XImage
|
||||
protected:
|
||||
UINTN Width;
|
||||
UINTN Height;
|
||||
#if USE_ARRAY
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelData;
|
||||
#else
|
||||
XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL> PixelData;
|
||||
#endif
|
||||
|
||||
public:
|
||||
XImage();
|
||||
XImage(UINTN W, UINTN H);
|
||||
XImage(EG_IMAGE* egImage);
|
||||
XImage(const XImage& Image, float scale);
|
||||
XImage(UINTN W, UINTN H, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Data);
|
||||
~XImage();
|
||||
|
||||
protected:
|
||||
UINTN GetSize() const; //in bytes
|
||||
|
||||
public:
|
||||
#if !USE_ARRAY
|
||||
|
||||
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const;
|
||||
#else
|
||||
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetData() const;
|
||||
#endif
|
||||
|
||||
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& GetPixel(UINTN x, UINTN y) const;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetPixelPtr(UINTN x, UINTN y);
|
||||
UINTN GetWidth() const;
|
||||
UINTN GetHeight() const;
|
||||
|
||||
#if USE_ARRAY
|
||||
void setEmpty() {
|
||||
Width = 0; Height = 0; if (PixelData) {
|
||||
FreePool(PixelData); PixelData = nullptr;
|
||||
}
|
||||
}
|
||||
bool isEmpty() const { return PixelData == nullptr; }
|
||||
#else
|
||||
void setEmpty() { Width=0; Height=0; PixelData.setEmpty(); }
|
||||
bool isEmpty() const { return PixelData.size() == 0; }
|
||||
#endif
|
||||
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user