separated EG_IMAGE to exclude them

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-16 14:42:14 +03:00
parent 509981b16c
commit 79af8de0a0
18 changed files with 97 additions and 111 deletions

View File

@ -2288,6 +2288,7 @@
A51F63C922DFB81700086DB7 /* AppleApfsInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleApfsInfo.h; sourceTree = "<group>"; }; A51F63C922DFB81700086DB7 /* AppleApfsInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleApfsInfo.h; sourceTree = "<group>"; };
A51F63CA22DFB84500086DB7 /* ApfsEfiBootRecordInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApfsEfiBootRecordInfo.h; sourceTree = "<group>"; }; A51F63CA22DFB84500086DB7 /* ApfsEfiBootRecordInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApfsEfiBootRecordInfo.h; sourceTree = "<group>"; };
A51F63CB22DFB86F00086DB7 /* ApplePartitionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePartitionInfo.h; sourceTree = "<group>"; }; A51F63CB22DFB86F00086DB7 /* ApplePartitionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePartitionInfo.h; sourceTree = "<group>"; };
A523130F2448792B00421FB2 /* image.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = image.h; sourceTree = "<group>"; };
A5429219233538250001F42A /* Clover */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Clover; sourceTree = BUILT_PRODUCTS_DIR; }; A5429219233538250001F42A /* Clover */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Clover; sourceTree = BUILT_PRODUCTS_DIR; };
A5456CC423FC5A81000BF18C /* CanonicalDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanonicalDB.h; sourceTree = "<group>"; }; A5456CC423FC5A81000BF18C /* CanonicalDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanonicalDB.h; sourceTree = "<group>"; };
A5456CC623FC5A81000BF18C /* securemenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = securemenu.cpp; sourceTree = "<group>"; }; A5456CC623FC5A81000BF18C /* securemenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = securemenu.cpp; sourceTree = "<group>"; };
@ -6182,6 +6183,7 @@
A5456CE723FC5AB0000BF18C /* FloatLib.h */, A5456CE723FC5AB0000BF18C /* FloatLib.h */,
A5456CF623FC5AB7000BF18C /* ftol.asm */, A5456CF623FC5AB7000BF18C /* ftol.asm */,
A5456CE823FC5AB0000BF18C /* image.cpp */, A5456CE823FC5AB0000BF18C /* image.cpp */,
A523130F2448792B00421FB2 /* image.h */,
A5456CE423FC5AAE000BF18C /* libeg.h */, A5456CE423FC5AAE000BF18C /* libeg.h */,
A5456CE523FC5AAF000BF18C /* libegint.h */, A5456CE523FC5AAF000BF18C /* libegint.h */,
A5456CE223FC5AAE000BF18C /* libscreen.cpp */, A5456CE223FC5AAE000BF18C /* libscreen.cpp */,

View File

@ -54,7 +54,7 @@
extern CONST CHAR8* IconsNames[]; extern CONST CHAR8* IconsNames[];
#if 0 #if USE_EG_IMAGE
static CONST CHAR16 *BuiltinIconNames[] = { static CONST CHAR16 *BuiltinIconNames[] = {
/* /*
L"About", L"About",

View File

@ -84,25 +84,7 @@ VOID AddSecureBootTool(VOID)
Entry->AtRightClick = ActionHelp; Entry->AtRightClick = ActionHelp;
MainMenu.AddMenuEntry(Entry); MainMenu.AddMenuEntry(Entry);
} }
/*
typedef struct _refit_menu_entry {
CHAR16 *Title;
UINTN Tag;
UINTN Row;
CHAR16 ShortcutDigit;
CHAR16 ShortcutLetter;
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
EG_IMAGE *BadgeImage;
EG_RECT Place;
ACTION AtClick;
ACTION AtDoubleClick;
ACTION AtRightClick;
ACTION AtMouseOver;
REFIT_MENU_SCREEN *SubScreen;
} REFIT_MENU_ENTRY;
*/
STATIC REFIT_MENU_ENTRY QueryEntry[] = { STATIC REFIT_MENU_ENTRY QueryEntry[] = {
{ L"Deny authentication"_XSW, SECURE_BOOT_POLICY_DENY, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL }, { L"Deny authentication"_XSW, SECURE_BOOT_POLICY_DENY, 0, 0, 0, NULL, NULL, NULL, {0, 0, 0, 0}, ActionEnter, ActionNone, ActionNone, ActionNone, NULL },

View File

@ -150,7 +150,7 @@ static INTN row1Count, row1PosX, row1PosXRunning;
static INTN *itemPosX = NULL; static INTN *itemPosX = NULL;
static INTN *itemPosY = NULL; static INTN *itemPosY = NULL;
static INTN row0PosY, row1PosY, textPosY, FunctextPosY; static INTN row0PosY, row1PosY, textPosY, FunctextPosY;
////static EG_IMAGE* MainImage;
static INTN OldX = 0, OldY = 0; static INTN OldX = 0, OldY = 0;
static INTN OldTextWidth = 0; static INTN OldTextWidth = 0;
static UINTN OldRow = 0; static UINTN OldRow = 0;
@ -1293,7 +1293,6 @@ INTN REFIT_MENU_SCREEN::DrawTextXY(IN const XStringW& Text, IN INTN XPos, IN INT
INTN XText = 0; INTN XText = 0;
INTN Height; INTN Height;
INTN TextXYStyle = 1; INTN TextXYStyle = 1;
// EG_IMAGE *TextBufferXY = NULL;
XImage TextBufferXY(0,0); XImage TextBufferXY(0,0);
if (Text.isEmpty()) { if (Text.isEmpty()) {

View File

@ -30,7 +30,7 @@ XImage::XImage(UINTN W, UINTN H)
// Height = H; //included below // Height = H; //included below
setSizeInPixels(W, H); setSizeInPixels(W, H);
} }
#if USE_EG_IMAGE
XImage::XImage(EG_IMAGE* egImage) XImage::XImage(EG_IMAGE* egImage)
{ {
if ( egImage) { if ( egImage) {
@ -58,6 +58,7 @@ EFI_STATUS XImage::FromEGImage(const EG_IMAGE* egImage)
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
#endif
XImage& XImage::operator= (const XImage& other) XImage& XImage::operator= (const XImage& other)
{ {
@ -734,7 +735,7 @@ void XImage::CopyRect(const XImage& Image, const EG_RECT& OwnPlace, const EG_REC
} }
} }
#if USE_EG_IMAGE
EG_IMAGE* XImage::ToEGImage() EG_IMAGE* XImage::ToEGImage()
{ {
if (isEmpty()) { if (isEmpty()) {
@ -744,6 +745,7 @@ EG_IMAGE* XImage::ToEGImage()
CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes()); CopyMem(&Tmp->PixelData[0], &PixelData[0], GetSizeInBytes());
return Tmp; return Tmp;
} }
#endif
// //
// Load an image from a .icns file // Load an image from a .icns file
@ -757,7 +759,8 @@ EFI_STATUS XImage::LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileNam
UINT8 *FileData = NULL; UINT8 *FileData = NULL;
UINTN FileDataLength = 0; UINTN FileDataLength = 0;
//TODO - make XImage //TODO - make XImage
EG_IMAGE *NewImage; // EG_IMAGE *NewImage;
// load file // load file
Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength); Status = egLoadFile(BaseDir, FileName, &FileData, &FileDataLength);
@ -766,8 +769,9 @@ EFI_STATUS XImage::LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileNam
} }
// decode it // decode it
NewImage = egDecodeICNS(FileData, FileDataLength, PixelSize, TRUE); // NewImage = egDecodeICNS(FileData, FileDataLength, PixelSize, TRUE);
Status = FromEGImage(NewImage); // Status = FromEGImage(NewImage);
Status = FromICNS(FileData, FileDataLength, PixelSize);
FreePool(FileData); FreePool(FileData);
return Status; return Status;

View File

@ -53,7 +53,9 @@ protected:
public: public:
XImage(); XImage();
XImage(UINTN W, UINTN H); XImage(UINTN W, UINTN H);
#if USE_EG_IMAGE
XImage(EG_IMAGE* egImage); XImage(EG_IMAGE* egImage);
#endif
XImage(const XImage& Image, float scale = 0.f); //the constructor can accept 0 scale as 1.f XImage(const XImage& Image, float scale = 0.f); //the constructor can accept 0 scale as 1.f
virtual ~XImage(); virtual ~XImage();
@ -94,8 +96,11 @@ public:
EFI_STATUS FromPNG(const UINT8 * Data, UINTN Lenght); EFI_STATUS FromPNG(const UINT8 * Data, UINTN Lenght);
EFI_STATUS ToPNG(UINT8** Data, UINTN& OutSize); EFI_STATUS ToPNG(UINT8** Data, UINTN& OutSize);
EFI_STATUS FromSVG(const CHAR8 *SVGData, float scale); 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); EFI_STATUS FromEGImage(const EG_IMAGE* egImage);
EG_IMAGE* ToEGImage(); EG_IMAGE* ToEGImage();
#endif
void GetArea(const EG_RECT& Rect); void GetArea(const EG_RECT& Rect);
void GetArea(INTN x, INTN y, UINTN W, UINTN H); void GetArea(INTN x, INTN y, UINTN W, UINTN H);
void Draw(INTN x, INTN y, float scale, bool Opaque); void Draw(INTN x, INTN y, float scale, bool Opaque);

View File

@ -93,7 +93,7 @@ Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico)); \
ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \ ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
} }
Icon::Icon(INTN Index, bool TakeEmbedded) : Image(0), ImageNight(0) Icon::Icon(INTN Index, bool TakeEmbedded) : Image(), ImageNight()
{ {
Id = Index; Id = Index;
Name.setEmpty(); Name.setEmpty();

View File

@ -54,7 +54,7 @@
// //
// Basic image handling // Basic image handling
// //
#if USE_EG_IMAGE
EG_IMAGE * egCreateImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha) EG_IMAGE * egCreateImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha)
{ {
EG_IMAGE *NewImage; EG_IMAGE *NewImage;
@ -184,7 +184,7 @@ VOID egFreeImage(IN EG_IMAGE *Image)
FreePool(Image); FreePool(Image);
} }
} }
#endif
// //
// Basic file operations should be separated into separate file // Basic file operations should be separated into separate file
// //
@ -381,6 +381,7 @@ EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName)
//will be replaced by Image.LoadXImage(BaseDir, Name); //will be replaced by Image.LoadXImage(BaseDir, Name);
//caller is responsible for free image //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) EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha)
{ {
EFI_STATUS Status; EFI_STATUS Status;
@ -704,6 +705,6 @@ EG_IMAGE * egDecodePNG(IN const UINT8 *FileData, IN UINTN FileDataLength, IN BOO
lodepng_free(PixelData); lodepng_free(PixelData);
return NewImage; return NewImage;
} }
#endif
/* EOF */ /* EOF */

View File

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

View File

@ -37,6 +37,8 @@
#ifndef __LIBEG_LIBEG_H__ #ifndef __LIBEG_LIBEG_H__
#define __LIBEG_LIBEG_H__ #define __LIBEG_LIBEG_H__
#define USE_EG_IMAGE 0
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -380,28 +382,15 @@ typedef union {
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION; } EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
*/ */
#if USE_EG_IMAGE
typedef struct { typedef struct {
INTN Width; INTN Width;
INTN Height; INTN Height;
EG_PIXEL *PixelData; EG_PIXEL *PixelData;
BOOLEAN HasAlpha; //moved here to avoid alignment issue BOOLEAN HasAlpha; //moved here to avoid alignment issue
} EG_IMAGE; } EG_IMAGE;
/* #endif
typedef struct GUI_ANIME GUI_ANIME;
struct GUI_ANIME {
UINTN ID;
CHAR16 *Path;
UINTN Frames;
UINTN FrameTime;
INTN FilmX, FilmY; //relative
INTN ScreenEdgeHorizontal;
INTN ScreenEdgeVertical;
INTN NudgeX, NudgeY;
BOOLEAN Once;
GUI_ANIME *Next;
};
*/
#ifdef __cplusplus #ifdef __cplusplus
class EG_RECT { class EG_RECT {
public: public:
@ -440,15 +429,6 @@ typedef struct EG_RECT {
#define EG_EICOMPMODE_RLE (1) #define EG_EICOMPMODE_RLE (1)
#define EG_EICOMPMODE_EFICOMPRESS (2) #define EG_EICOMPMODE_EFICOMPRESS (2)
typedef struct {
EG_IMAGE *Image;
CONST CHAR16 *Path;
CONST CHAR16 *Format;
UINTN PixelSize;
} BUILTIN_ICON;
/* functions */ /* functions */
VOID egInitScreen(IN BOOLEAN SetMaxResolution); VOID egInitScreen(IN BOOLEAN SetMaxResolution);
@ -466,7 +446,7 @@ VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable);
// call egSetGraphicsModeEnabled(FALSE) to ensure the system // call egSetGraphicsModeEnabled(FALSE) to ensure the system
// is running in text mode. egHasGraphicsMode() only determines // is running in text mode. egHasGraphicsMode() only determines
// if libeg can draw to the screen in graphics mode. // 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 * 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 * egCreateFilledImage(IN INTN Width, IN INTN Height, IN BOOLEAN HasAlpha, IN EG_PIXEL *Color);
EG_IMAGE * egCopyImage(IN EG_IMAGE *Image); EG_IMAGE * egCopyImage(IN EG_IMAGE *Image);
@ -478,24 +458,25 @@ EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize); 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); 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, EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName,
OUT UINT8 **FileData, OUT UINTN *FileDataLength); OUT UINT8 **FileData, OUT UINTN *FileDataLength);
EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName, EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName,
IN CONST VOID *FileData, IN UINTN FileDataLength); IN CONST VOID *FileData, IN UINTN FileDataLength);
EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *DirName); EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *DirName);
EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir); EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir);
#if USE_EG_IMAGE
VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color); VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color);
VOID egFillImageArea(IN OUT EG_IMAGE *CompImage, VOID egFillImageArea(IN OUT EG_IMAGE *CompImage,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight, IN INTN AreaWidth, IN INTN AreaHeight,
IN EG_PIXEL *Color); IN EG_PIXEL *Color);
VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY); VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY);
#endif
VOID egClearScreen(IN const void *Color); VOID egClearScreen(IN const void *Color);
#if USE_EG_IMAGE
//VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY); //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 // will be replaced by XImage.Draw(ScreenPosX, ScreenPosY, 1.f); assuming Area* = 0
VOID egDrawImageArea(IN EG_IMAGE *Image, VOID egDrawImageArea(IN EG_IMAGE *Image,
@ -504,7 +485,7 @@ VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN ScreenPosX, IN INTN ScreenPosY); IN INTN ScreenPosX, IN INTN ScreenPosY);
VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY, VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
IN INTN AreaWidth, IN INTN AreaHeight); IN INTN AreaWidth, IN INTN AreaHeight);
#endif
EFI_STATUS egScreenShot(VOID); EFI_STATUS egScreenShot(VOID);

View File

@ -152,7 +152,7 @@ DECLARE_EMB_EXTERN_WITH_SIZE(emb_dark_checkbox_checked)
//typedef EG_IMAGE * (*EG_DECODE_FUNC)(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha); //typedef EG_IMAGE * (*EG_DECODE_FUNC)(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
/* functions */ /* functions */
#if USE_EG_IMAGE
VOID egRestrictImageArea(IN EG_IMAGE *Image, VOID egRestrictImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight); IN OUT INTN *AreaWidth, IN OUT INTN *AreaHeight);
@ -177,7 +177,7 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
EG_IMAGE * egDecodeICNS(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); 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); //VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);

View File

@ -531,7 +531,7 @@ VOID egClearScreen(IN const void *Color)
} }
} }
#if USE_EG_IMAGE
VOID egDrawImageArea(IN EG_IMAGE *Image, VOID egDrawImageArea(IN EG_IMAGE *Image,
IN INTN AreaPosX, IN INTN AreaPosY, IN INTN AreaPosX, IN INTN AreaPosY,
IN INTN AreaWidth, IN INTN AreaHeight, IN INTN AreaWidth, IN INTN AreaHeight,
@ -615,7 +615,7 @@ VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
// } // }
} }
#endif
// //
// Make a screenshot // Make a screenshot
// //

View File

@ -35,6 +35,7 @@
*/ */
//#if !defined(LODEPNG) //#if !defined(LODEPNG)
#include "libegint.h" #include "libegint.h"
#include "XImage.h"
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define DEBUG_IMG 0 #define DEBUG_IMG 0
@ -47,8 +48,11 @@
#else #else
#define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__) #define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__)
#endif #endif
#if USE_EG_IMAGE
#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname)) #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 //these functions used for icns, not with png
@ -148,22 +152,22 @@ VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT
// Load Apple .icns icons // Load Apple .icns icons
// //
EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha) EFI_STATUS XImage::FromICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize)
{ {
EG_IMAGE *NewImage; // EG_IMAGE *NewImage;
UINT8 *Ptr, *BufferEnd, *DataPtr, *MaskPtr; UINT8 *Ptr, *BufferEnd, *DataPtr, *MaskPtr;
UINT32 BlockLen, DataLen, MaskLen; UINT32 BlockLen, DataLen, MaskLen;
UINTN FetchPixelSize, PixelCount, i; UINTN FetchPixelSize, PixelCount, i;
UINT8 *CompData; UINT8 *CompData;
UINTN CompLen; UINTN CompLen;
UINT8 *SrcPtr; UINT8 *SrcPtr;
EG_PIXEL *DestPtr; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *DestPtr;
if (FileDataLength < 8 || FileData == NULL || if (FileDataLength < 8 || FileData == NULL ||
FileData[0] != 'i' || FileData[1] != 'c' || FileData[2] != 'n' || FileData[3] != 's') { FileData[0] != 'i' || FileData[1] != 'c' || FileData[2] != 'n' || FileData[3] != 's') {
// not an icns file... // not an icns file...
DBG("not icns\n"); DBG("not icns\n");
return NULL; return EFI_NOT_FOUND; //it is null at this moment
} }
FetchPixelSize = IconSize; FetchPixelSize = IconSize;
@ -236,13 +240,14 @@ EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN Ic
if (DataPtr == NULL) { if (DataPtr == NULL) {
DBG("not found such IconSize\n"); DBG("not found such IconSize\n");
return NULL; // no image found return EFI_NOT_FOUND; // no image found
} }
// allocate image structure and buffer // allocate image structure and buffer
NewImage = egCreateImage(FetchPixelSize, FetchPixelSize, WantAlpha); // NewImage = egCreateImage(FetchPixelSize, FetchPixelSize, WantAlpha);
if (NewImage == NULL) // if (NewImage == NULL)
return NULL; // return NULL;
setSizeInPixels(FetchPixelSize, FetchPixelSize);
PixelCount = FetchPixelSize * FetchPixelSize; PixelCount = FetchPixelSize * FetchPixelSize;
if (DataLen < PixelCount * 3) { if (DataLen < PixelCount * 3) {
@ -250,36 +255,36 @@ EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN Ic
// pixel data is compressed, RGB planar // pixel data is compressed, RGB planar
CompData = DataPtr; CompData = DataPtr;
CompLen = DataLen; CompLen = DataLen;
egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(NewImage, r), PixelCount); egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(*this, Red), PixelCount);
egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(NewImage, g), PixelCount); egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(*this, Green), PixelCount);
egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(NewImage, b), PixelCount); egDecompressIcnsRLE(&CompData, &CompLen, PLPTR(*this, Blue), PixelCount);
// possible assertion: CompLen == 0 // possible assertion: CompLen == 0
if (CompLen > 0) { if (CompLen > 0) {
DBG(" egLoadICNSIcon: %llu bytes of compressed data left\n", CompLen); DBG(" egLoadICNSIcon: %llu bytes of compressed data left\n", CompLen);
} }
} else { } else {
// pixel data is uncompressed, RGB interleaved // pixel data is uncompressed, RGB interleaved
SrcPtr = DataPtr; SrcPtr = DataPtr;
DestPtr = NewImage->PixelData; DestPtr = GetPixelPtr(0,0);
for (i = 0; i < PixelCount; i++, DestPtr++) { for (i = 0; i < PixelCount; i++, DestPtr++) {
DestPtr->r = *SrcPtr++; DestPtr->Red = *SrcPtr++;
DestPtr->g = *SrcPtr++; DestPtr->Green = *SrcPtr++;
DestPtr->b = *SrcPtr++; DestPtr->Blue = *SrcPtr++;
} }
} }
// add/set alpha plane // add/set alpha plane
if (MaskPtr != NULL && MaskLen >= PixelCount && WantAlpha) if (MaskPtr != NULL && MaskLen >= PixelCount)
egInsertPlane(MaskPtr, PLPTR(NewImage, a), PixelCount); egInsertPlane(MaskPtr, PLPTR(*this, Reserved), PixelCount);
else else
egSetPlane(PLPTR(NewImage, a), WantAlpha ? 255 : 0, PixelCount); egSetPlane(PLPTR(*this, Reserved), 255, PixelCount);
// FUTURE: scale to originally requested size if we had to load another size // FUTURE: scale to originally requested size if we had to load another size
return NewImage; return EFI_SUCCESS;
} }
//#endif //#endif
/* EOF */ /* EOF */

View File

@ -38,7 +38,7 @@
#include "nanosvg.h" #include "nanosvg.h"
#include "FloatLib.h" #include "FloatLib.h"
#include "../Platform/b64cdecode.h" #include "../Platform/b64cdecode.h"
#include "image.h" #include "XImage.h"
#ifndef DEBUG_ALL #ifndef DEBUG_ALL
#define DEBUG_SVG 0 #define DEBUG_SVG 0
@ -3172,7 +3172,8 @@ static void parseImage(NSVGparser* p, const char** dict)
float w,h; float w,h;
const char *href = NULL; const char *href = NULL;
UINT8 *tmpData = NULL; UINT8 *tmpData = NULL;
EG_IMAGE *NewImage = NULL; // EG_IMAGE *NewImage = NULL;
XImage *NewImage = new XImage;
for (i = 0; dict[i]; i += 2) { for (i = 0; dict[i]; i += 2) {
if (strcmp(dict[i], "width") == 0) { if (strcmp(dict[i], "width") == 0) {
@ -3196,7 +3197,8 @@ static void parseImage(NSVGparser* p, const char** dict)
if (len == 0) { if (len == 0) {
DBG("image not decoded from base64\n"); DBG("image not decoded from base64\n");
} }
NewImage = egDecodePNG(tmpData, len, TRUE); // NewImage = egDecodePNG(tmpData, len, TRUE);
NewImage->FromPNG(tmpData, len);
pt->image = (void *)NewImage; pt->image = (void *)NewImage;
if (tmpData) { if (tmpData) {
FreePool(tmpData); FreePool(tmpData);

View File

@ -1212,37 +1212,40 @@ static void nsvg__scanlineSolid(unsigned char* row, int count, unsigned char* co
// TODO // TODO
float fx, fy, dx, gx, gy; float fx, fy, dx, gx, gy;
float* t = cache->xform; float* t = cache->xform;
EG_IMAGE *Pattern = (EG_IMAGE *)cache->image; // EG_IMAGE *Pattern = (EG_IMAGE *)cache->image;
XImage *Pattern = (XImage*)cache->image;
if (!Pattern) { if (!Pattern) {
DBG("no pattern to fill\n"); DBG("no pattern to fill\n");
return; return;
} }
INTN Width = Pattern->Width; INTN Width = Pattern->GetWidth();
INTN Height = Pattern->Height; INTN Height = Pattern->GetHeight();
int i, cr, cg, cb, ca, ix, iy; int ix, iy;
INTN j; // INTN j;
fx = (float)x; fx = (float)x;
fy = (float)y; fy = (float)y;
dx = 1.0f; dx = 1.0f;
// unsigned int c; // unsigned int c;
for (i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int r,g,b,a,ia; int r,g,b,a,ia;
gx = fx*t[0] + fy*t[2] + t[4]; gx = fx*t[0] + fy*t[2] + t[4];
gy = fx*t[1] + fy*t[3] + t[5]; gy = fx*t[1] + fy*t[3] + t[5];
ix = dither(gx * Width, 2) % Width; ix = dither(gx * Width, 2) % Width;
iy = dither(gy * Height, 2) % Height; iy = dither(gy * Height, 2) % Height;
j = iy * Width + ix; // j = iy * Width + ix;
cr = Pattern->PixelData[j].r; EFI_GRAPHICS_OUTPUT_BLT_PIXEL cp = Pattern->GetPixel(ix, iy);
cb = Pattern->PixelData[j].b; // cr = Pattern->PixelData[j].r;
cg = Pattern->PixelData[j].g; // cb = Pattern->PixelData[j].b;
ca = Pattern->PixelData[j].a; // cg = Pattern->PixelData[j].g;
a = nsvg__div255((int)cover[0] * ca); // ca = Pattern->PixelData[j].a;
// cr = cp.Red;
a = nsvg__div255((int)cover[0] * cp.Reserved);
ia = 255 - a; ia = 255 - a;
// Premultiply // Premultiply
r = nsvg__div255(cr * a); r = nsvg__div255(cp.Red * a);
g = nsvg__div255(cg * a); g = nsvg__div255(cp.Green * a);
b = nsvg__div255(cb * a); b = nsvg__div255(cp.Blue * a);
// Blend over // Blend over
r += nsvg__div255(ia * (int)dst[0]); r += nsvg__div255(ia * (int)dst[0]);

View File

@ -198,6 +198,7 @@ typedef enum {
MouseMove MouseMove
} MOUSE_EVENT; } MOUSE_EVENT;
*/ */
/*
typedef struct _pointers { typedef struct _pointers {
EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol; EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
EG_IMAGE *Pointer; EG_IMAGE *Pointer;
@ -211,7 +212,7 @@ typedef struct _pointers {
EFI_SIMPLE_POINTER_STATE State; EFI_SIMPLE_POINTER_STATE State;
MOUSE_EVENT MouseEvent; MOUSE_EVENT MouseEvent;
} POINTERS; } POINTERS;
*/
//GUI types //GUI types

View File

@ -71,9 +71,9 @@ static BOOLEAN IsImageWithinScreenLimits(INTN Value, INTN ImageDimension, INTN S
static INTN RepositionFixedByCenter(INTN Value, INTN ScreenDimension, INTN DesignScreenDimension); static INTN RepositionFixedByCenter(INTN Value, INTN ScreenDimension, INTN DesignScreenDimension);
static INTN RepositionRelativeByGapsOnEdges(INTN Value, INTN ImageDimension, 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); INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
#if USE_EG_IMAGE
EG_IMAGE * LoadSvgFrame(INTN i); EG_IMAGE * LoadSvgFrame(INTN i);
#endif
// UGA defines and variables // UGA defines and variables
INTN UGAWidth; INTN UGAWidth;
@ -341,7 +341,7 @@ typedef struct {
// moreover it is class EG_RECT; // moreover it is class EG_RECT;
//same as EgRect but INTN <-> UINTN //same as EgRect but INTN <-> UINTN
*/ */
#if USE_EG_IMAGE
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos) VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos)
{ {
if (!Image) { if (!Image) {
@ -393,7 +393,7 @@ VOID BltImageAlpha(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos, IN EG_PIXEL *
egDrawImageArea(NewImage, 0, 0, 0, 0, XPos, YPos); egDrawImageArea(NewImage, 0, 0, 0, 0, XPos, YPos);
egFreeImage(NewImage); egFreeImage(NewImage);
} }
#endif
/* /*
-------------------------------------------------------------------- --------------------------------------------------------------------
Pos : Bottom -> Mid -> Top Pos : Bottom -> Mid -> Top

View File

@ -11,12 +11,13 @@ VOID SetNextScreenMode(INT32);
VOID SwitchToGraphicsAndClear(VOID); VOID SwitchToGraphicsAndClear(VOID);
VOID BltClearScreen(); VOID BltClearScreen();
#if USE_EG_IMAGE
VOID BltImage(IN EG_IMAGE *Image, IN INTN XPos, IN INTN YPos); 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 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 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 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); //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 HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN ScreenDimension, INTN DesignScreenDimension);
INTN CalculateNudgePosition(INTN Position, INTN NudgeValue, INTN ImageDimension, INTN ScreenDimension); INTN CalculateNudgePosition(INTN Position, INTN NudgeValue, INTN ImageDimension, INTN ScreenDimension);