cleanup from EG_IMAGE, they remain in separate drivers/protocols

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-17 15:21:15 +03:00
parent 6ee56263ec
commit e1345d7ba0
13 changed files with 4 additions and 799 deletions

View File

@ -409,7 +409,7 @@
<key>#LegacyBiosDefaultEntry</key>
<integer>0</integer>
<key>CustomLogo</key>
<string>Apple</string>
<false/>
</dict>
<key>KernelAndKextPatches</key>
<dict>

View File

@ -54,50 +54,6 @@
extern CONST CHAR8* IconsNames[];
#if USE_EG_IMAGE
static CONST CHAR16 *BuiltinIconNames[] = {
/*
L"About",
L"Options",
L"Clover",
L"Reset",
L"Shutdown",
L"Help",
L"Shell",
L"Part",
L"Rescue",
L"Pointer",
*/
L"Internal",
L"External",
L"Optical",
L"FireWire",
L"Boot",
L"HFS",
L"APFS",
L"NTFS",
L"EXT",
L"Recovery",
};
static const UINTN BuiltinIconNamesCount = (sizeof(BuiltinIconNames) / sizeof(CHAR16 *));
EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName)
{
UINTN Index = 0;
if (IconName == NULL) {
return NULL;
}
while (Index < BuiltinIconNamesCount) {
if (StriCmp(IconName, BuiltinIconNames[Index]) == 0) {
XImage IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_INTERNAL + Index);
return IconX.ToEGImage();
}
++Index;
}
return NULL;
}
#endif
const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{

View File

@ -30,35 +30,6 @@ XImage::XImage(UINTN W, UINTN H)
// Height = H; //included below
setSizeInPixels(W, H);
}
#if USE_EG_IMAGE
XImage::XImage(EG_IMAGE* egImage)
{
if ( egImage) {
// Width = egImage->Width;
// Height = egImage->Height;
setSizeInPixels(egImage->Width, egImage->Height); // change the size, ie the number of element in the array. Reaalocate buffer if needed
CopyMem(&PixelData[0], egImage->PixelData, GetSizeInBytes());
}else{
// Width = 0;
// Height = 0;
setSizeInPixels(0, 0); // change the size, ie the number of element in the array. Reallocate buffer if needed
}
}
EFI_STATUS XImage::FromEGImage(const EG_IMAGE* egImage)
{
if ( egImage) {
setSizeInPixels(egImage->Width, egImage->Height);
CopyMem(&PixelData[0], egImage->PixelData, GetSizeInBytes());
} else {
setSizeInPixels(0, 0);
}
if (GetSizeInBytes() == 0) {
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
#endif
XImage& XImage::operator= (const XImage& other)
{
@ -735,18 +706,6 @@ void XImage::CopyRect(const XImage& Image, const EG_RECT& OwnPlace, const EG_REC
}
}
#if USE_EG_IMAGE
EG_IMAGE* XImage::ToEGImage()
{
if (isEmpty()) {
return NULL; // what is better, return NULL or empty image?
}
EG_IMAGE* Tmp = egCreateImage(Width, Height, TRUE); //memory leak
CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes());
return Tmp;
}
#endif
//
// Load an image from a .icns file
//

View File

@ -53,9 +53,6 @@ protected:
public:
XImage();
XImage(UINTN W, UINTN H);
#if USE_EG_IMAGE
XImage(EG_IMAGE* egImage);
#endif
XImage(const XImage& Image, float scale = 0.f); //the constructor can accept 0 scale as 1.f
virtual ~XImage();
@ -97,10 +94,7 @@ public:
EFI_STATUS ToPNG(UINT8** Data, UINTN& OutSize);
EFI_STATUS FromSVG(const CHAR8 *SVGData, float scale);
EFI_STATUS FromICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize);
#if USE_EG_IMAGE
EFI_STATUS FromEGImage(const EG_IMAGE* egImage);
EG_IMAGE* ToEGImage();
#endif
void GetArea(const EG_RECT& Rect);
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
void Draw(INTN x, INTN y, float scale, bool Opaque);

View File

@ -51,140 +51,6 @@
#define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__)
#endif
//
// Basic image handling
//
#if USE_EG_IMAGE
EG_IMAGE * egCreateImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha)
{
EG_IMAGE *NewImage;
NewImage = (EG_IMAGE *) AllocatePool(sizeof(EG_IMAGE));
if (NewImage == NULL)
return NULL;
if (Width * Height == 0) {
FreePool(NewImage);
return NULL;
}
NewImage->PixelData = (EG_PIXEL *) AllocatePool((UINTN)(Width * Height * sizeof(EG_PIXEL)));
if (NewImage->PixelData == NULL) {
FreePool(NewImage);
return NULL;
}
NewImage->Width = Width;
NewImage->Height = Height;
NewImage->HasAlpha = HasAlpha;
return NewImage;
}
EG_IMAGE * egCreateFilledImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha, IN EG_PIXEL *Color)
{
EG_IMAGE *NewImage;
NewImage = egCreateImage(Width, Height, HasAlpha);
if (NewImage == NULL)
return NULL;
egFillImage(NewImage, Color);
return NewImage;
}
EG_IMAGE * egCopyImage(IN EG_IMAGE *Image)
{
EG_IMAGE *NewImage;
if (!Image || (Image->Width * Image->Height) == 0) {
return NULL;
}
NewImage = egCreateImage(Image->Width, Image->Height, Image->HasAlpha);
if (NewImage == NULL)
return NULL;
CopyMem(NewImage->PixelData, Image->PixelData, (UINTN)(Image->Width * Image->Height * sizeof(EG_PIXEL)));
return NewImage;
}
//Scaling functions
EG_IMAGE * egCopyScaledImage(IN EG_IMAGE *OldImage, IN INTN Ratio) //will be N/16
{
//(c)Slice 2012
BOOLEAN Grey = FALSE;
EG_IMAGE *NewImage;
INTN x, x0, x1, x2, y, y0, y1, y2;
INTN NewH, NewW;
EG_PIXEL *Dest;
EG_PIXEL *Src;
INTN OldW;
if (Ratio < 0) {
Ratio = -Ratio;
Grey = TRUE;
}
if (!OldImage) {
return NULL;
}
Src = OldImage->PixelData;
OldW = OldImage->Width;
NewW = (OldImage->Width * Ratio) >> 4;
NewH = (OldImage->Height * Ratio) >> 4;
if (Ratio == 16) {
NewImage = egCopyImage(OldImage);
} else {
NewImage = egCreateImage(NewW, NewH, OldImage->HasAlpha);
if (NewImage == NULL)
return NULL;
Dest = NewImage->PixelData;
for (y = 0; y < NewH; y++) {
y1 = (y << 4) / Ratio;
y0 = ((y1 > 0)?(y1-1):y1) * OldW;
y2 = ((y1 < (OldImage->Height - 1))?(y1+1):y1) * OldW;
y1 *= OldW;
for (x = 0; x < NewW; x++) {
x1 = (x << 4) / Ratio;
x0 = (x1 > 0)?(x1-1):x1;
x2 = (x1 < (OldW - 1))?(x1+1):x1;
Dest->b = (UINT8)(((INTN)Src[x1+y1].b * 2 + Src[x0+y1].b +
Src[x2+y1].b + Src[x1+y0].b + Src[x1+y2].b) / 6);
Dest->g = (UINT8)(((INTN)Src[x1+y1].g * 2 + Src[x0+y1].g +
Src[x2+y1].g + Src[x1+y0].g + Src[x1+y2].g) / 6);
Dest->r = (UINT8)(((INTN)Src[x1+y1].r * 2 + Src[x0+y1].r +
Src[x2+y1].r + Src[x1+y0].r + Src[x1+y2].r) / 6);
Dest->a = Src[x1+y1].a;
Dest++;
}
}
}
if (Grey) {
Dest = NewImage->PixelData;
for (y = 0; y < NewH; y++) {
for (x = 0; x < NewW; x++) {
Dest->b = (UINT8)((INTN)((UINTN)Dest->b + (UINTN)Dest->g + (UINTN)Dest->r) / 3);
Dest->g = Dest->r = Dest->b;
Dest++;
}
}
}
return NewImage;
}
VOID egFreeImage(IN EG_IMAGE *Image)
{
if (Image != NULL) {
if (Image->PixelData != NULL) {
FreePool(Image->PixelData);
Image->PixelData = NULL; //FreePool will not zero pointer
}
FreePool(Image);
}
}
#endif
//
// Basic file operations should be separated into separate file
//
@ -379,332 +245,6 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName)
return Status;
}
//will be replaced by Image.LoadXImage(BaseDir, Name);
//caller is responsible for free image
#if USE_EG_IMAGE
EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha)
{
EFI_STATUS Status;
UINT8 *FileData = NULL;
UINTN FileDataLength = 0;
EG_IMAGE *NewImage;
if (ThemeX.TypeSVG) {
return NULL;
}
if (BaseDir == NULL || FileName == NULL)
return NULL;
// load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
if (EFI_ERROR(Status))
return NULL;
// decode it
NewImage = egDecodePNG(FileData, FileDataLength, WantAlpha);
if (!NewImage) {
DBG("%ls not decoded\n", FileName);
}
FreePool(FileData);
return NewImage;
}
//
// Compositing
//
// take part of other procedures, not needed
//used in RunGenericMenu-> used in Anime
VOID egRestrictImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,
IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight)
{
if (!Image || !AreaWidth || !AreaHeight) {
return;
}
if (AreaPosX >= Image->Width || AreaPosY >= Image->Height) {
// out of bounds, operation has no effect
*AreaWidth = 0;
*AreaHeight = 0;
} else {
// calculate affected area
if (*AreaWidth > Image->Width - AreaPosX)
*AreaWidth = Image->Width - AreaPosX;
if (*AreaHeight > Image->Height - AreaPosY)
*AreaHeight = Image->Height - AreaPosY;
}
}
//TODO will be replaced by
// CompImage.Fill(Color)
VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color)
{
INTN i;
EG_PIXEL FillColor;
EG_PIXEL *PixelPtr;
if (!CompImage || !Color) {
return;
}
FillColor = *Color;
if (!CompImage->HasAlpha)
FillColor.a = 0;
PixelPtr = CompImage->PixelData;
for (i = 0; i < CompImage->Width * CompImage->Height; i++) {
*PixelPtr++ = FillColor;
}
}
//TODO will be replaced by
// CompImage.FillArea(Color, Rect)
// used in Anime
VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight,
IN EG_PIXEL *Color)
{
INTN x, y;
INTN xAreaWidth = AreaWidth;
INTN xAreaHeight = AreaHeight;
EG_PIXEL FillColor;
EG_PIXEL *PixelBasePtr;
if (!CompImage || !Color) {
return;
}
egRestrictImageArea(CompImage, AreaPosX, AreaPosY, &xAreaWidth, &xAreaHeight);
if (xAreaWidth > 0) {
FillColor = *Color;
if (!CompImage->HasAlpha)
FillColor.a = 0;
PixelBasePtr = CompImage->PixelData + AreaPosY * CompImage->Width + AreaPosX;
for (y = 0; y < xAreaHeight; y++) {
EG_PIXEL *PixelPtr = PixelBasePtr;
for (x = 0; x < xAreaWidth; x++) {
*PixelPtr++ = FillColor;
}
PixelBasePtr += CompImage->Width;
}
}
}
//TODO will be replaced by
// CompBase.CopyRect(TopBase, XPos, YPos);
VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset)
{
INTN x, y;
if (!CompBasePtr || !TopBasePtr) {
return;
}
for (y = 0; y < Height; y++) {
EG_PIXEL *TopPtr = TopBasePtr;
EG_PIXEL *CompPtr = CompBasePtr;
for (x = 0; x < Width; x++) {
*CompPtr = *TopPtr;
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
}
}
//will be replace by
// CompBase.Compose(
VOID egRawCompose(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset)
{
INT64 x, y;
EG_PIXEL *TopPtr, *CompPtr;
//To make native division we need INTN types
INTN TopAlpha;
INTN Alpha;
INTN CompAlpha;
INTN RevAlpha;
INTN TempAlpha;
// EG_PIXEL *CompUp;
if (!CompBasePtr || !TopBasePtr) {
return;
}
// CompUp = CompBasePtr + Width * Height;
//Slice - my opinion
//if TopAlpha=255 then draw Top - non transparent
//else if TopAlpha=0 then draw Comp - full transparent
//else draw mixture |-----comp---|--top--|
//final alpha =(1-(1-x)*(1-y)) =(255*255-(255-topA)*(255-compA))/255
for (y = 0; y < Height; y++) {
TopPtr = TopBasePtr;
CompPtr = CompBasePtr;
for (x = 0; x < Width; x++) {
TopAlpha = TopPtr->a & 0xFF; //exclude sign
if (TopAlpha == 255) {
CompPtr->b = TopPtr->b;
CompPtr->g = TopPtr->g;
CompPtr->r = TopPtr->r;
CompPtr->a = (UINT8)TopAlpha;
} else if (TopAlpha != 0) {
CompAlpha = CompPtr->a & 0xFF;
RevAlpha = 255 - TopAlpha;
TempAlpha = CompAlpha * RevAlpha;
TopAlpha *= 255;
Alpha = TopAlpha + TempAlpha;
CompPtr->b = (UINT8)((TopPtr->b * TopAlpha + CompPtr->b * TempAlpha) / Alpha);
CompPtr->g = (UINT8)((TopPtr->g * TopAlpha + CompPtr->g * TempAlpha) / Alpha);
CompPtr->r = (UINT8)((TopPtr->r * TopAlpha + CompPtr->r * TempAlpha) / Alpha);
CompPtr->a = (UINT8)(Alpha / 255);
}
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
}
}
// This is simplified image composing on solid background. egComposeImage will decide which method to use
VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset)
{
INT64 x, y;
EG_PIXEL *TopPtr, *CompPtr;
UINT32 TopAlpha;
UINT32 RevAlpha;
UINTN Temp;
if (!CompBasePtr || !TopBasePtr) {
return;
}
for (y = 0; y < Height; y++) {
TopPtr = TopBasePtr;
CompPtr = CompBasePtr;
for (x = 0; x < Width; x++) {
TopAlpha = TopPtr->a;
RevAlpha = 255 - TopAlpha;
Temp = ((UINT8)CompPtr->b * RevAlpha) + ((UINT8)TopPtr->b * TopAlpha);
CompPtr->b = (UINT8)(Temp / 255);
Temp = ((UINT8)CompPtr->g * RevAlpha) + ((UINT8)TopPtr->g * TopAlpha);
CompPtr->g = (UINT8)(Temp / 255);
Temp = ((UINT8)CompPtr->r * RevAlpha) + ((UINT8)TopPtr->r * TopAlpha);
CompPtr->r = (UINT8)(Temp / 255);
CompPtr->a = (UINT8)(255);
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
}
}
//TODO will be replaced by
// CompImage.Compose(IN XImage& TopImage, IN INTN PosX, IN INTN PosY)
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY)
{
INTN CompWidth, CompHeight;
if (!TopImage || !CompImage) {
return;
}
CompWidth = TopImage->Width;
CompHeight = TopImage->Height;
egRestrictImageArea(CompImage, PosX, PosY, &CompWidth, &CompHeight);
// compose
if (CompWidth > 0) {
if (CompImage->HasAlpha && ThemeX.Background.isEmpty()) {
CompImage->HasAlpha = FALSE;
}
if (TopImage->HasAlpha) {
if (CompImage->HasAlpha) { //aaaa
egRawCompose(CompImage->PixelData + PosY * CompImage->Width + PosX,
TopImage->PixelData,
CompWidth, CompHeight, CompImage->Width, TopImage->Width);
} else {
egRawComposeOnFlat(CompImage->PixelData + PosY * CompImage->Width + PosX,
TopImage->PixelData,
CompWidth, CompHeight, CompImage->Width, TopImage->Width);
}
} else {
egRawCopy(CompImage->PixelData + PosY * CompImage->Width + PosX,
TopImage->PixelData,
CompWidth, CompHeight, CompImage->Width, TopImage->Width);
}
}
}
//
// misc internal functions
//
EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha)
{
EG_IMAGE *NewImage = NULL;
UINTN Error, i, ImageSize;
size_t Width, Height;
EG_PIXEL *PixelData;
EG_PIXEL *Pixel, *PixelD;
Error = eglodepng_decode((UINT8**) &PixelData, &Width, &Height, (CONST UINT8*) FileData, (UINTN) FileDataLength);
if (Error) {
/*
* Error 28 incorrect PNG signature ok, because also called on ICNS files
*/
if (Error != 28U) {
DBG("egDecodePNG(%p, %llu, %c): eglodepng_decode failed with error %llu\n",
FileData, FileDataLength, WantAlpha?'Y':'N', Error);
}
return NULL;
}
if (!PixelData || Width > 4096U || Height > 4096U) {
DBG("egDecodePNG(%p, %llu, %c): eglodepng_decode returned suspect values, PixelData %p, Width %zu, Height %zu\n",
FileData, FileDataLength, WantAlpha?'Y':'N', PixelData, Width, Height);
}
NewImage = egCreateImage(Width, Height, WantAlpha);
if (NewImage == NULL) return NULL;
ImageSize = (Width * Height);
// CopyMem(NewImage->PixelData, PixelData, sizeof(EG_PIXEL) * ImageSize);
// lodepng_free(PixelData);
Pixel = (EG_PIXEL*)NewImage->PixelData;
PixelD = PixelData;
for (i = 0; i < ImageSize; i++) {
/* UINT8 Temp;
Temp = Pixel->b;
Pixel->b = Pixel->r;
Pixel->r = Temp; */
Pixel->b = PixelD->r; //change r <-> b
Pixel->r = PixelD->b;
Pixel->g = PixelD->g;
Pixel->a = PixelD->a; // 255 is opaque, 0 - transparent
Pixel++;
PixelD++;
}
lodepng_free(PixelData);
return NewImage;
}
#endif
/* EOF */

View File

@ -9,14 +9,5 @@
#define LIBEG_IMAGE_H_
#ifdef USE_EG_IMAGE
EG_IMAGE
*egDecodePNG (
IN const UINT8 *FileData,
IN UINTN FileDataLength,
IN BOOLEAN WantAlpha
);
#endif
#endif /* LIBEG_IMAGE_H_ */

View File

@ -37,8 +37,6 @@
#ifndef __LIBEG_LIBEG_H__
#define __LIBEG_LIBEG_H__
#define USE_EG_IMAGE 0
#ifdef __cplusplus
extern "C" {
#endif
@ -382,14 +380,6 @@ typedef union {
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
*/
#if USE_EG_IMAGE
typedef struct {
INTN Width;
INTN Height;
EG_PIXEL *PixelData;
BOOLEAN HasAlpha; //moved here to avoid alignment issue
} EG_IMAGE;
#endif
#ifdef __cplusplus
class EG_RECT {
@ -446,46 +436,16 @@ VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable);
// call egSetGraphicsModeEnabled(FALSE) to ensure the system
// is running in text mode. egHasGraphicsMode() only determines
// if libeg can draw to the screen in graphics mode.
#if USE_EG_IMAGE
EG_IMAGE * egCreateImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha);
EG_IMAGE * egCreateFilledImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha, IN EG_PIXEL *Color);
EG_IMAGE * egCopyImage(IN EG_IMAGE *Image);
EG_IMAGE * egCopyScaledImage(IN EG_IMAGE *Image, IN INTN Ratio);
VOID egFreeImage(IN EG_IMAGE *Image);
VOID ScaleImage(OUT EG_IMAGE *NewImage, IN EG_IMAGE *OldImage);
EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha);
EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize);
EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color);
#endif
EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName,
OUT UINT8 **FileData, OUT UINTN *FileDataLength);
EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName,
IN CONST VOID *FileData, IN UINTN FileDataLength);
EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *DirName);
EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir);
#if USE_EG_IMAGE
VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color);
VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight,
IN EG_PIXEL *Color);
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY);
#endif
VOID egClearScreen(IN const void *Color);
#if USE_EG_IMAGE
//VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY);
// will be replaced by XImage.Draw(ScreenPosX, ScreenPosY, 1.f); assuming Area* = 0
VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight,
IN INTN ScreenPosX, IN INTN ScreenPosY);
VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
IN INTN AreaWidth, IN INTN AreaHeight);
#endif
EFI_STATUS egScreenShot(VOID);

View File

@ -149,35 +149,6 @@ DECLARE_EMB_EXTERN_WITH_SIZE(emb_dark_checkbox_checked)
/* types */
//typedef EG_IMAGE * (*EG_DECODE_FUNC)(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
/* functions */
#if USE_EG_IMAGE
VOID egRestrictImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,
IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight);
VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset);
VOID egRawCompose(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset);
VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset);
//#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname))
//VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINT64 PixelCount);
//VOID egCopyPlane(IN UINT8 *SrcPlanePtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha);
#endif
//VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);

View File

@ -531,91 +531,6 @@ VOID egClearScreen(IN const void *Color)
}
}
#if USE_EG_IMAGE
VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight,
IN INTN ScreenPosX, IN INTN ScreenPosY)
{
if (!egHasGraphics || !Image) return;
if (ScreenPosX < 0 || ScreenPosX >= UGAWidth || ScreenPosY < 0 || ScreenPosY >= UGAHeight) {
// This is outside of screen area
return;
}
if (AreaWidth == 0) {
AreaWidth = Image->Width;
}
if (AreaHeight == 0) {
AreaHeight = Image->Height;
}
if ((AreaPosX != 0) || (AreaPosY != 0)) {
egRestrictImageArea(Image, AreaPosX, AreaPosY, &AreaWidth, &AreaHeight);
if (AreaWidth == 0)
return;
}
// if (Image->HasAlpha) { // It shouldn't harm Blt
// //Image->HasAlpha = FALSE;
// egSetPlane(PLPTR(Image, a), 255, Image->Width * Image->Height);
// }
if (ScreenPosX + AreaWidth > UGAWidth)
{
AreaWidth = UGAWidth - ScreenPosX;
}
if (ScreenPosY + AreaHeight > UGAHeight)
{
AreaHeight = UGAHeight - ScreenPosY;
}
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData,
EfiBltBufferToVideo,
(UINTN)AreaPosX, (UINTN)AreaPosY, (UINTN)ScreenPosX, (UINTN)ScreenPosY,
(UINTN)AreaWidth, (UINTN)AreaHeight, (UINTN)Image->Width * 4);
} else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo,
(UINTN)AreaPosX, (UINTN)AreaPosY, (UINTN)ScreenPosX, (UINTN)ScreenPosY,
(UINTN)AreaWidth, (UINTN)AreaHeight, (UINTN)Image->Width * 4);
}
}
// Blt(this, Buffer, mode, srcX, srcY, destX, destY, w, h, deltaSrc);
VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
IN INTN AreaWidth, IN INTN AreaHeight)
{
// if (GraphicsOutput != NULL) {
if (ScreenPosX + AreaWidth > UGAWidth)
{
AreaWidth = UGAWidth - ScreenPosX;
}
if (ScreenPosY + AreaHeight > UGAHeight)
{
AreaHeight = UGAHeight - ScreenPosY;
}
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData,
EfiBltVideoToBltBuffer,
ScreenPosX,
ScreenPosY,
0, 0, AreaWidth, AreaHeight, (UINTN)Image->Width * 4);
} else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw,
(EFI_UGA_PIXEL *)Image->PixelData,
EfiUgaVideoToBltBuffer,
ScreenPosX,
ScreenPosY,
0, 0, AreaWidth, AreaHeight, (UINTN)Image->Width * 4);
}
// }
}
#endif
//
// Make a screenshot
//

View File

@ -48,11 +48,8 @@
#else
#define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__)
#endif
#if USE_EG_IMAGE
#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname))
#else
#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar).GetPixelPtr(0,0)->colorname))
#endif
//these functions used for icns, not with png
@ -154,7 +151,6 @@ VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT
EFI_STATUS XImage::FromICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize)
{
// EG_IMAGE *NewImage;
UINT8 *Ptr, *BufferEnd, *DataPtr, *MaskPtr;
UINT32 BlockLen, DataLen, MaskLen;
UINTN FetchPixelSize, PixelCount, i;

View File

@ -198,21 +198,7 @@ typedef enum {
MouseMove
} MOUSE_EVENT;
*/
/*
typedef struct _pointers {
EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
EG_IMAGE *Pointer;
EG_IMAGE *newImage;
EG_IMAGE *oldImage;
EG_RECT newPlace;
EG_RECT oldPlace;
UINT64 LastClickTime; //not EFI_TIME
EFI_SIMPLE_POINTER_STATE State;
MOUSE_EVENT MouseEvent;
} POINTERS;
*/
//GUI types

View File

@ -71,9 +71,6 @@ static BOOLEAN IsImageWithinScreenLimits(INTN Value, INTN ImageDimension, INTN S
static INTN RepositionFixedByCenter(INTN Value, INTN ScreenDimension, INTN DesignScreenDimension);
static INTN RepositionRelativeByGapsOnEdges(INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
#if USE_EG_IMAGE
EG_IMAGE * LoadSvgFrame(INTN i);
#endif
// UGA defines and variables
INTN UGAWidth;
@ -341,59 +338,6 @@ typedef struct {
// moreover it is class EG_RECT;
//same as EgRect but INTN <-> UINTN
*/
#if USE_EG_IMAGE
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
{
if (!Image) {
return;
}
egDrawImageArea(Image, 0, 0, 0, 0, XPos, YPos);
GraphicsScreenDirty = TRUE;
}
VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *BackgroundPixel, INTN Scale)
{
EG_IMAGE *CompImage;
EG_IMAGE *NewImage = NULL;
INTN Width = Scale << 3;
INTN Height = Width;
GraphicsScreenDirty = TRUE;
if (Image) {
NewImage = egCopyScaledImage(Image, Scale); //will be Scale/16
Width = NewImage->Width;
Height = NewImage->Height;
}
// DBG("w=%d, h=%d\n", Width, Height);
// compose on background
CompImage = egCreateFilledImage(Width, Height, !ThemeX.Background.isEmpty(), BackgroundPixel); //no matter
egComposeImage(CompImage, NewImage, 0, 0);
if (NewImage) {
egFreeImage(NewImage);
}
if (ThemeX.Background.isEmpty()) {
egDrawImageArea(CompImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(CompImage);
return;
}
NewImage = egCreateImage(Width, Height, FALSE);
if (!NewImage) return;
// DBG("draw on background\n");
egRawCopy(NewImage->PixelData,
(EG_PIXEL*)ThemeX.Background.GetPixelPtr(0,0) + YPos * ThemeX.Background.GetWidth() + XPos,
Width, Height,
Width,
ThemeX.Background.GetWidth());
egComposeImage(NewImage, CompImage, 0, 0);
egFreeImage(CompImage);
// blit to screen and clean up
egDrawImageArea(NewImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(NewImage);
}
#endif
/*
--------------------------------------------------------------------
Pos : Bottom -> Mid -> Top

View File

@ -11,13 +11,6 @@ VOID SetNextScreenMode(INT32);
VOID SwitchToGraphicsAndClear(VOID);
VOID BltClearScreen();
#if USE_EG_IMAGE
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos);
VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *BackgroundPixel, INTN Scale);
//VOID BltImageComposite(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos);
VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG_IMAGE *BadgeImage, IN INTN XPos, IN INTN YPos, INTN Scale);
//VOID BltImageCompositeIndicator(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN INTN XPos, IN INTN YPos, INTN Scale);
#endif
INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
INTN CalculateNudgePosition(INTN Position, INTN NudgeValue, INTN ImageDimension, INTN ScreenDimension);