Few cleaning in XImage. XPointer improvement.

Renamed some method in XArray XObjArray and XStringW.
This commit is contained in:
jief 2020-03-09 04:12:24 +03:00
parent b050d84bb7
commit 1cb7b4e69e
17 changed files with 406 additions and 513 deletions

View File

@ -26,7 +26,7 @@ class XArray
protected:
TYPE *m_data;
xsize m_len;
xsize m_size;
xsize m_allocatedSize;
xsize _GrowBy;
public:
@ -41,12 +41,12 @@ class XArray
TYPE *Data() { return m_data; }
public:
xsize Size() const { return m_size; }
xsize Length() const { return m_len; }
void SetLength(xsize l);
xsize AllocatedSize() const { return m_allocatedSize; }
xsize size() const { return m_len; }
void setSize(xsize l);
//low case functions like in std::vector
xsize size() const { return m_len; }
const TYPE& begin() const { return ElementAt(0); }
TYPE& begin() { return ElementAt(0); }
@ -114,7 +114,7 @@ xsize XArray<TYPE>::IdxOf(TYPE& e) const
{
xsize i;
for ( i=0 ; i<Length() ; i+=1 ) {
for ( i=0 ; i<size() ; i+=1 ) {
if ( ElementAt(i) == e ) return i;
}
return MAX_XSIZE;
@ -125,7 +125,7 @@ template<class TYPE>
void XArray<TYPE>::Init()
{
m_data = nullptr;
m_size = 0;
m_allocatedSize = 0;
m_len = 0;
_GrowBy = XArrayGrowByDefault;
}
@ -135,7 +135,7 @@ template<class TYPE>
XArray<TYPE>::XArray(const XArray<TYPE> &anArray)
{
Init();
AddArray(anArray.Data(), anArray.Length());
AddArray(anArray.Data(), anArray.size());
}
/* operator = */
@ -162,15 +162,15 @@ template<class TYPE>
void XArray<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
{
//XArray_DBG("CheckSize: m_len=%d, m_size=%d, nGrowBy=%d, nNewSize=%d\n", m_len, m_size, nGrowBy, nNewSize);
if ( nNewSize > m_size ) {
if ( nNewSize > m_allocatedSize ) {
nNewSize += nGrowBy;
m_data = (TYPE *)Xrealloc( m_size * sizeof(TYPE), nNewSize * sizeof(TYPE), (void *)m_data);
m_data = (TYPE *)Xrealloc( m_allocatedSize * sizeof(TYPE), nNewSize * sizeof(TYPE), (void *)m_data);
if ( !m_data ) {
DebugLog(2, "XArray<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_size, nNewSize*sizeof(TYPE), m_data);
CpuDeadLoop();
DebugLog(2, "XArray<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, nNewSize*sizeof(TYPE), m_data);
panic();
}
// memset(&_Data[_Size], 0, (nNewSize-_Size) * sizeof(TYPE)); // Could help for debugging, but zeroing in not needed.
m_size = nNewSize;
m_allocatedSize = nNewSize;
}
}
@ -183,14 +183,14 @@ void XArray<TYPE>::CheckSize(xsize nNewSize)
/* SetLength (xsize i) */
template<class TYPE>
void XArray<TYPE>::SetLength(xsize l)
void XArray<TYPE>::setSize(xsize l)
{
CheckSize(l, XArrayGrowByDefault); // be sure the size is allocated
m_len = l;
#ifdef DEBUG
if(m_len > m_size) {
if(m_len > m_allocatedSize) {
DebugLog(2, "XArray::SetLength(xsize) -> _Len > _Size");
CpuDeadLoop();
panic();
}
#endif
}
@ -203,7 +203,7 @@ TYPE &XArray<TYPE>::ElementAt(xsize index)
// #ifdef _DEBUG
if ( index >= m_len ) {
DebugLog(2, "XArray::ElementAt(xsize) -> Operator [] : index > m_len");
CpuDeadLoop();
panic();
}
// #endif
return m_data[index];
@ -216,7 +216,7 @@ const TYPE& XArray<TYPE>::ElementAt(xsize index) const
// #ifdef _DEBUG
if ( index >= m_len ) {
DebugLog(2, "XArray::ElementAt(xsize) const -> Operator [] : index > m_len");
CpuDeadLoop();
panic();
}
// #endif
return m_data[index];
@ -300,7 +300,7 @@ void XArray<TYPE>::RemoveAtIndex(int nIndex)
#if defined(__XTOOLS_INT_CHECK__)
if ( nIndex < 0 ) {
DebugLog(2, "XArray<TYPE>::RemoveAtIndex(int nIndex) : BUG nIndex (%d) is < 0. System halted\n", nIndex);
CpuDeadLoop();
panic();
}
#endif

View File

@ -36,7 +36,7 @@ class XObjArrayNC
public:
XObjArrayEntry<TYPE> *_Data;
xsize _Len;
xsize _Size;
xsize m_allocatedSize;
public:
void Init();
@ -44,12 +44,12 @@ class XObjArrayNC
virtual ~XObjArrayNC();
protected:
XObjArrayNC(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); CpuDeadLoop(); }
const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); CpuDeadLoop(); }
XObjArrayNC(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); panic(); }
const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); panic(); }
xsize _getLen() const { return _Len; }
public:
xsize AllocatedSize() const { return _Size; }
xsize AllocatedSize() const { return m_allocatedSize; }
xsize size() const { return _Len; }
xsize length() const { return _Len; }
@ -132,7 +132,7 @@ template<class TYPE>
void XObjArrayNC<TYPE>::Init()
{
_Data = nullptr;
_Size = 0;
m_allocatedSize = 0;
_Len = 0;
// THis was useful for realtime debugging with a debugger that do not recognise references.
#ifdef _DEBUG_iufasdfsfk
@ -179,14 +179,14 @@ XObjArrayNC<TYPE>::~XObjArrayNC()
template<class TYPE>
void XObjArrayNC<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
{
if ( _Size < nNewSize ) {
if ( m_allocatedSize < nNewSize ) {
nNewSize += nGrowBy + 1;
_Data = (XObjArrayEntry<TYPE> *)Xrealloc(sizeof(XObjArrayEntry<TYPE>) * _Size, sizeof(XObjArrayEntry<TYPE>) * nNewSize, (void *)_Data );
_Data = (XObjArrayEntry<TYPE> *)Xrealloc(sizeof(XObjArrayEntry<TYPE>) * m_allocatedSize, sizeof(XObjArrayEntry<TYPE>) * nNewSize, (void *)_Data );
if ( !_Data ) {
XObjArray_DBG("XObjArrayNC<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, _Size, sizeof(XObjArrayEntry<TYPE>) * nNewSize, _Data);
XObjArray_DBG("XObjArrayNC<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, sizeof(XObjArrayEntry<TYPE>) * nNewSize, _Data);
}
// memset(&_Data[_Size], 0, (nNewSize-_Size) * sizeof(XObjArrayEntry<TYPE>));
_Size = nNewSize;
// memset(&_Data[m_allocatedSize], 0, (nNewSize-m_allocatedSize) * sizeof(XObjArrayEntry<TYPE>));
m_allocatedSize = nNewSize;
}
}
@ -196,7 +196,7 @@ TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index)
{
if ( index >= _Len ) {
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
CpuDeadLoop();
panic();
}
return *((TYPE *)(_Data[index].Object));
}
@ -207,7 +207,7 @@ const TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index) const
{
if ( index >= _Len ) {
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) const -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
CpuDeadLoop();
panic();
}
return *((TYPE *)(_Data[index].Object));
}
@ -427,7 +427,7 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex)
{
if ( nIndex >= XObjArrayNC<TYPE>::_Len ) {
DebugLog(2, "void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex) : BUG nIndex (%d) is > Length(). System halted\n", nIndex);
CpuDeadLoop();
panic();
}
}
if ( _Data[nIndex].FreeIt )
@ -470,7 +470,7 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(int nIndex)
#if defined(__XTOOLS_INT_CHECK__)
if ( nIndex < 0 ) {
DebugLog(2, "XArray<TYPE>::RemoveAtIndex(int nIndex) : BUG nIndex (%d) is < 0. System halted\n", nIndex);
CpuDeadLoop();
panic();
}
#endif
RemoveAtIndex( (xsize)nIndex ); // Remove(xsize) will check that index is < _Len

View File

@ -33,9 +33,9 @@ void XStringW::Init(UINTN aSize)
m_data = (wchar_t*)Xalloc( (aSize+1)*sizeof(wchar_t) ); /* le 0 terminal n'est pas compté dans mSize */
if ( !m_data ) {
DBG("XStringW::Init(%d) : Xalloc returned NULL. Cpu halted\n", (aSize+1)*sizeof(wchar_t));
CpuDeadLoop();
panic();
}
m_size = aSize;
m_allocatedSize = aSize;
m_len = 0;
m_data[0] = 0;
}
@ -83,7 +83,7 @@ XStringW::XStringW(const char* S)
DBG("Constructor(const char* S)\n");
xsize newLen = StrLenInWChar(S, AsciiStrLen(S));
Init(newLen);
utf8ToWChar(m_data, m_size+1, S, AsciiStrLen(S)); // m_size doesn't count the NULL terminator
utf8ToWChar(m_data, m_allocatedSize+1, S, AsciiStrLen(S)); // m_size doesn't count the NULL terminator
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@ -109,7 +109,7 @@ void XStringW::SetLength(UINTN len)
if ( StrLen(data()) != len ) {
DBG("XStringW::SetLength(UINTN len) : StrLen(data()) != len (%d != %d). System halted\n", StrLen(data()), len);
CpuDeadLoop();
panic();
}
}
@ -118,15 +118,15 @@ wchar_t *XStringW::CheckSize(UINTN nNewSize, UINTN nGrowBy)
{
//DBG("CheckSize: m_size=%d, nNewSize=%d\n", m_size, nNewSize);
if ( m_size < nNewSize )
if ( m_allocatedSize < nNewSize )
{
nNewSize += nGrowBy;
m_data = (wchar_t*)Xrealloc(m_size*sizeof(wchar_t), (nNewSize+1)*sizeof(wchar_t), m_data);
m_data = (wchar_t*)Xrealloc(m_allocatedSize*sizeof(wchar_t), (nNewSize+1)*sizeof(wchar_t), m_data);
if ( !m_data ) {
DBG("XStringW::CheckSize(%d, %d) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_size, (nNewSize+1)*sizeof(wchar_t), m_data);
CpuDeadLoop();
panic();
}
m_size = nNewSize;
m_allocatedSize = nNewSize;
}
return m_data;
}

View File

@ -22,7 +22,7 @@ class XStringW
protected:
wchar_t *m_data;
UINTN m_len;
UINTN m_size;
UINTN m_allocatedSize;
public:
void Init(UINTN aSize=0);
@ -45,7 +45,8 @@ public:
wchar_t *dataWithSizeMin(UINTN pos, UINTN sizeMin, UINTN nGrowBy=XStringWGrowByDefault) { CheckSize(sizeMin, nGrowBy); return data(pos); }
UINTN length() const { return m_len; }
UINTN size() const { return m_size; }
UINTN size() const { return m_len; }
UINTN allocatedSize() const { return m_allocatedSize; }
void SetLength(UINTN len);
/* IsNull ? */

View File

@ -15,8 +15,10 @@ extern xsize XBufferGrowByDefault;
#ifdef CLOVER_BUILD
#include "../cpp_util/panic.h"
extern "C" {
#include <Library/BaseLib.h> // for CpuDeadLoop
#include <Library/BaseLib.h> // for StrCmp
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h> // for CopyMen
}

View File

@ -0,0 +1,10 @@
#include "panic.h"
extern "C" {
#include <Library/BaseLib.h> // for CpuDeadLoop
}
void panic(void)
{
CpuDeadLoop();
}

View File

@ -0,0 +1,6 @@
#ifndef __PANIC_H__
#define __PANIC_H__
void panic(void);
#endif

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __menu_items_H__
#define __menu_items_H__
#ifndef __REFIT_MENU_SCREEN_H__
#define __REFIT_MENU_SCREEN_H__
#include "libeg.h"
@ -55,7 +55,6 @@
//#define FILM_PERCENT 100000
#define INITVALUE 40000
class REFIT_ABSTRACT_MENU_ENTRY;
class REFIT_MENU_ITEM_IEM_ABSTRACT;
class REFIT_MENU_ENTRY;
@ -69,11 +68,7 @@ public:
UINTN ID;
CONST CHAR16 *Title; //Title is not const, but *Title is. It will be better to make it XStringW
EG_IMAGE *TitleImage;
// INTN InfoLineCount;
// CONST CHAR16 **InfoLines;
XStringWArray InfoLines;
// INTN EntryCount;
// REFIT_MENU_ENTRY **Entries;
XObjArray<REFIT_ABSTRACT_MENU_ENTRY> Entries;
INTN TimeoutSeconds;
CONST CHAR16 *TimeoutText;
@ -97,7 +92,7 @@ public:
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText)
@ -105,14 +100,14 @@ public:
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0), mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);

View File

@ -377,190 +377,6 @@ public:
};
//some unreal values
#define FILM_CENTRE 40000
//#define FILM_LEFT 50000
//#define FILM_TOP 50000
//#define FILM_RIGHT 60000
//#define FILM_BOTTOM 60000
//#define FILM_PERCENT 100000
#define INITVALUE 40000
typedef VOID (REFIT_MENU_SCREEN::*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);
class REFIT_MENU_SCREEN
{
public:
XPointer mPointer;
UINTN ID;
CONST CHAR16 *Title; //Title is not const, but *Title is. It will be better to make it XStringW
EG_IMAGE *TitleImage;
// INTN InfoLineCount;
// CONST CHAR16 **InfoLines;
XStringWArray InfoLines;
// INTN EntryCount;
// REFIT_MENU_ENTRY **Entries;
XObjArray<REFIT_ABSTRACT_MENU_ENTRY> Entries;
INTN TimeoutSeconds;
CONST CHAR16 *TimeoutText;
CONST CHAR16 *Theme;
BOOLEAN AnimeRun;
BOOLEAN Once;
UINT64 LastDraw;
INTN CurrentFrame;
INTN Frames;
UINTN FrameTime; //ms
EG_RECT FilmPlace;
EG_IMAGE **Film;
ACTION mAction;
UINTN mItemID;
SCROLL_STATE ScrollState;
// MENU_STYLE_FUNC StyleFunc;
REFIT_MENU_SCREEN()
: mPointer(), ID(0), Title(0), TitleImage(0),
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText)
: mPointer(), ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{};
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
: mPointer(), ID(ID), Title(Title), TitleImage(0),
TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0), mAction(ActionNone), mItemID(0) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
{
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
};
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {};
//
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// REFIT_ABSTRACT_MENU_ENTRY* entry,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {
// Entries.AddReference(entry, false);
// };
// REFIT_MENU_SCREEN( UINTN ID_,
// CONST CHAR16 *Title_,
// EG_IMAGE *TitleImage_,
//// INTN InfoLineCount_,
//// CONST CHAR16 **InfoLines_,
// REFIT_ABSTRACT_MENU_ENTRY* entry1,
// REFIT_ABSTRACT_MENU_ENTRY* entry2,
// INTN TimeoutSeconds_,
// CONST CHAR16 *TimeoutText_,
// CONST CHAR16 *Theme_,
// BOOLEAN AnimeRun_,
// BOOLEAN Once_,
// UINT64 LastDraw_,
// INTN CurrentFrame_,
// INTN Frames_,
// UINTN FrameTime_,
// EG_RECT FilmPlace_,
// EG_IMAGE **Film_)
// : ID(ID_), Title(Title_), TitleImage(TitleImage_),
// /*InfoLineCount(InfoLineCount_), InfoLines(InfoLines_),*/ TimeoutSeconds(TimeoutSeconds_),
// TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
// Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
// Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
// Film(Film_), mAction(ActionNone), mItemID(0), mPointer(NULL)
// {
// Entries.AddReference(entry1, false);
// Entries.AddReference(entry2, false);
// };
//Scroll functions
VOID InitScroll(IN INTN ItemCount, IN UINTN MaxCount,
IN UINTN VisibleSpace, IN INTN Selected);
VOID UpdateScroll(IN UINTN Movement);
VOID HidePointer();
EFI_STATUS MouseBirth();
VOID KillMouse();
VOID AddMenuItem_(REFIT_MENU_ITEM_IEM_ABSTRACT* InputBootArgs, INTN Inx, CONST CHAR8 *Title, BOOLEAN Cursor);
VOID AddMenuInfo(CONST CHAR16 *Line);
VOID AddMenuInfoLine(IN CONST CHAR16 *InfoLine);
VOID AddMenuEntry(IN REFIT_MENU_ENTRY *Entry, bool freeIt);
VOID AddMenuItemSwitch(INTN Inx, CONST CHAR8 *Title, BOOLEAN Cursor);
VOID AddMenuCheck(CONST CHAR8 *Text, UINTN Bit, INTN ItemNum);
VOID AddMenuItemInput(INTN Inx, CONST CHAR8 *Title, BOOLEAN Cursor);
VOID FreeMenu();
INTN FindMenuShortcutEntry(IN CHAR16 Shortcut);
UINTN RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc);
VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos);
VOID CountItems();
VOID InitAnime();
BOOLEAN GetAnime();
VOID UpdateAnime();
//Style functions
virtual VOID MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
~REFIT_MENU_SCREEN() {};
};
#endif
/*

View File

@ -25,7 +25,7 @@ XImage::XImage(UINTN W, UINTN H)
{
Width = W;
Height = H;
PixelData.CheckSize(GetWidth()*GetHeight());
setSizeInPixels(W, H);
}
XImage::XImage(EG_IMAGE* egImage)
@ -33,15 +33,22 @@ XImage::XImage(EG_IMAGE* egImage)
if ( egImage) {
Width = egImage->Width;
Height = egImage->Height;
setSizeInPixels(GetWidth(), GetHeight()); // 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(GetWidth(), GetHeight()); // change the size, ie the number of element in the array. Reaalocate buffer if needed
}
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));
}
}
XImage& XImage::operator= (const XImage& other)
{
Width = other.GetWidth();
Height = other.GetHeight();
setSizeInPixels(GetWidth(), GetHeight()); // change the size, ie the number of element in the array. Reaalocate buffer if needed
CopyMem(&PixelData[0], &other.PixelData[0], GetSizeInBytes());
return *this;
}
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale)
@ -58,8 +65,7 @@ XImage::XImage(const XImage& Image, float scale)
if (scale < 1.e-4) {
Width = SrcWidth;
Height = SrcHeight;
PixelData.CheckSize(GetWidth()*GetHeight());
PixelData.SetLength(GetWidth()*GetHeight());
setSizeInPixels(GetWidth(), GetHeight());
for (UINTN y = 0; y < Height; ++y)
for (UINTN x = 0; x < Width; ++x)
PixelData[y * Width + x] = Image.GetPixel(x, y);
@ -67,8 +73,7 @@ XImage::XImage(const XImage& Image, float scale)
} else {
Width = (UINTN)(SrcWidth * scale);
Height = (UINTN)(SrcHeight * scale);
PixelData.CheckSize(Width * Height);
PixelData.SetLength(Width * Height);
setSizeInPixels(GetWidth(), GetHeight());
CopyScaled(Image, scale);
}
}
@ -165,9 +170,14 @@ UINTN XImage::GetHeight() const
return Height;
}
UINTN XImage::GetSize() const
UINTN XImage::GetSizeInBytes() const
{
return Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
return PixelData.size() * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
}
void XImage::setSizeInPixels(UINTN W, UINTN H)
{
PixelData.setSize(Width * Height);
}
void XImage::Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color)
@ -367,19 +377,61 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
Width = (x + W > (UINTN)UGAWidth) ? (UGAWidth - x) : W;
Height = (y + H > (UINTN)UGAHeight) ? ((UINTN)UGAHeight - y) : H;
PixelData.SetLength(Width * Height); // setLength BEFORE, so &PixelData[0]
setSizeInPixels(Width, Height); // setSizeInPixels BEFORE, so &PixelData[0]
if ( Width == 0 || Height == 0 ) return; // nothing to get, area is zero. &PixelData[0] would crash
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&PixelData[0],
&PixelData[0],
EfiBltVideoToBltBuffer,
x, y, 0, 0, Width, Height, 0);
x, y, 0, 0, Width, Height, Width*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw,
(EFI_UGA_PIXEL *)GetPixelPtr(0,0),
EfiUgaVideoToBltBuffer,
x, y, 0, 0, Width, Height, 0);
x, y, 0, 0, Width, Height, Width*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
}
void XImage::Draw2(INTN x, INTN y, UINTN width, UINTN height, float scale)
{
// //prepare images
//// DBG("1\n");
// XImage Top(*this, scale);
//// DBG("2\n");
// XImage Background(Width, Height);
//// DBG("3\n");
// Background.GetArea(x, y, Width, Height);
//// DBG("4\n");
// Background.Compose(0, 0, Top, true);
//// DBG("5\n");
UINTN AreaWidth = (x + Width > (UINTN)UGAWidth) ? (UGAWidth - x) : Width;
UINTN AreaHeight = (y + Height > (UINTN)UGAHeight) ? (UGAHeight - y) : Height;
// DBG("area=%d,%d\n", AreaWidth, AreaHeight);
// prepare protocols
EFI_STATUS Status;
EFI_GUID UgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
EFI_UGA_DRAW_PROTOCOL *UgaDraw = NULL;
EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL;
Status = EfiLibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
if (EFI_ERROR(Status)) {
GraphicsOutput = NULL;
Status = EfiLibLocateProtocol(&UgaDrawProtocolGuid, (VOID **)&UgaDraw);
if (EFI_ERROR(Status))
UgaDraw = NULL;
}
//output combined image
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput, (*this).GetPixelPtr(0, 0),
EfiBltBufferToVideo,
0, 0, x, y, width, height, GetWidth()*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)(*this).GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,
0, 0, x, y, AreaWidth, AreaHeight, 0);
}
}
@ -414,9 +466,9 @@ void XImage::Draw(INTN x, INTN y, float scale)
}
//output combined image
if (GraphicsOutput != NULL) {
GraphicsOutput->Blt(GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Background.GetPixelPtr(0, 0),
GraphicsOutput->Blt(GraphicsOutput, Background.GetPixelPtr(0, 0),
EfiBltBufferToVideo,
0, 0, x, y, AreaWidth, AreaHeight, 0);
0, 0, x, y, AreaWidth, AreaHeight, GetWidth()*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
}
else if (UgaDraw != NULL) {
UgaDraw->Blt(UgaDraw, (EFI_UGA_PIXEL *)Background.GetPixelPtr(0, 0), EfiUgaBltBufferToVideo,

View File

@ -56,11 +56,15 @@ public:
XImage(const XImage& Image, float scale);
~XImage();
XImage& operator= (const XImage& other);
protected:
UINTN GetSize() const; //in bytes
UINTN GetSizeInBytes() const; //in bytes
public:
void setSizeInPixels(UINTN W, UINTN H);
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const;
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& GetPixel(UINTN x, UINTN y) const;
@ -68,6 +72,8 @@ public:
UINTN GetWidth() const;
UINTN GetHeight() const;
void setZero() { SetMem( (void*)GetPixelPtr(0, 0), GetSizeInBytes(), 0); }
void setEmpty() { Width=0; Height=0; PixelData.setEmpty(); }
bool isEmpty() const { return PixelData.size() == 0; }
@ -83,6 +89,7 @@ public:
void GetArea(const EG_RECT& Rect);
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
void Draw(INTN x, INTN y, float scale);
void Draw2(INTN x, INTN y, UINTN width, UINTN height, float scale);
};
#endif //__XSTRINGW_H__

View File

@ -40,7 +40,7 @@ XPointer::~XPointer()
void XPointer::Hide()
{
if (Alive) {
oldImage.Draw(oldPlace.XPos, oldPlace.YPos, 1.f);
oldImage.Draw2(oldPlace.XPos, oldPlace.YPos, oldImage.GetWidth(), oldImage.GetHeight(), 1.f);
}
}
@ -164,7 +164,7 @@ VOID XPointer::UpdatePointer()
else
MouseEvent = NoEvents;
CopyMem(&State, &tmpState, sizeof(EFI_SIMPLE_POINTER_STATE));
CopyMem(&State, &tmpState, sizeof(State));
CurrentMode = SimplePointerProtocol->Mode;
ScreenRelX = ((UGAWidth * State.RelativeMovementX / (INTN)CurrentMode->ResolutionX) * gSettings.PointerSpeed) >> 10;
@ -183,8 +183,10 @@ VOID XPointer::UpdatePointer()
if (newPlace.YPos < 0) newPlace.YPos = 0;
if (newPlace.YPos > UGAHeight - 1) newPlace.YPos = UGAHeight - 1;
Hide();
Draw();
if ( CompareMem(&oldPlace, &newPlace, sizeof(__typeof(oldPlace))) != 0 ) {
Hide();
Draw();
}
}
}

View File

@ -584,9 +584,9 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
// decode it
NewImage = egDecodePNG(FileData, FileDataLength, TRUE);
if (!NewImage) {
NewImage = egDecodeICNS(FileData, FileDataLength, IconSize, TRUE);
}
// if (!NewImage) {
// NewImage = egDecodeICNS(FileData, FileDataLength, IconSize, TRUE);
// }
FreePool(FileData);
return NewImage;

View File

@ -174,7 +174,7 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
//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 * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha);

View File

@ -1,246 +1,246 @@
/*
* libeg/load_icns.c
* Loading function for .icns Apple icon images
*
* Copyright (c) 2006 Christoph Pfisterer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Christoph Pfisterer nor the names of the
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//#if !defined(LODEPNG)
#include "libegint.h"
#ifndef DEBUG_ALL
#define DEBUG_IMG 0
#else
#define DEBUG_IMG DEBUG_ALL
#endif
#if DEBUG_IMG == 0
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__)
#endif
///*
// * libeg/load_icns.c
// * Loading function for .icns Apple icon images
// *
// * Copyright (c) 2006 Christoph Pfisterer
// * All rights reserved.
// *
// * Redistribution and use in source and binary forms, with or without
// * modification, are permitted provided that the following conditions are
// * met:
// *
// * * Redistributions of source code must retain the above copyright
// * notice, this list of conditions and the following disclaimer.
// *
// * * Redistributions in binary form must reproduce the above copyright
// * notice, this list of conditions and the following disclaimer in the
// * documentation and/or other materials provided with the
// * distribution.
// *
// * * Neither the name of Christoph Pfisterer nor the names of the
// * contributors may be used to endorse or promote products derived
// * from this software without specific prior written permission.
// *
// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// */
////#if !defined(LODEPNG)
//#include "libegint.h"
//
// Decompress .icns RLE data
//
VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *PixelData, IN UINTN PixelCount)
{
UINT8 *cp;
UINT8 *cp_end;
UINT8 *pp;
UINTN pp_left;
UINTN len, i;
UINT8 value;
// setup variables
cp = *CompData;
cp_end = cp + *CompLen;
pp = PixelData;
pp_left = PixelCount;
// decode
while (cp + 1 < cp_end && pp_left > 0) {
len = *cp++;
if (len & 0x80) { // compressed data: repeat next byte
len -= 125;
if (len > pp_left)
break;
value = *cp++;
for (i = 0; i < len; i++) {
*pp = value;
pp += 4;
}
} else { // uncompressed data: copy bytes
len++;
if (len > pp_left || cp + len > cp_end)
break;
for (i = 0; i < len; i++) {
*pp = *cp++;
pp += 4;
}
}
pp_left -= len;
}
if (pp_left > 0) {
DBG(" egDecompressIcnsRLE: still need %d bytes of pixel data\n", pp_left);
}
// record what's left of the compressed data stream
*CompData = cp;
*CompLen = (UINTN)(cp_end - cp);
}
//
// Load Apple .icns icons
//
EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha)
{
EG_IMAGE *NewImage;
UINT8 *Ptr, *BufferEnd, *DataPtr, *MaskPtr;
UINT32 BlockLen, DataLen, MaskLen;
UINTN FetchPixelSize, PixelCount, i;
UINT8 *CompData;
UINTN CompLen;
UINT8 *SrcPtr;
EG_PIXEL *DestPtr;
if (FileDataLength < 8 || FileData == NULL ||
FileData[0] != 'i' || FileData[1] != 'c' || FileData[2] != 'n' || FileData[3] != 's') {
// not an icns file...
DBG("not icns\n");
return NULL;
}
FetchPixelSize = IconSize;
for (;;) {
DataPtr = NULL;
DataLen = 0;
MaskPtr = NULL;
MaskLen = 0;
Ptr = FileData + 8;
BufferEnd = FileData + FileDataLength;
// iterate over tagged blocks in the file
while (Ptr + 8 <= BufferEnd) {
BlockLen = ((UINT32)Ptr[4] << 24) + ((UINT32)Ptr[5] << 16) + ((UINT32)Ptr[6] << 8) + (UINT32)Ptr[7];
if (Ptr + BlockLen > BufferEnd) // block continues beyond end of file
break;
// extract the appropriate blocks for each pixel size
if (FetchPixelSize == 128) {
if (Ptr[0] == 'i' && Ptr[1] == 't' && Ptr[2] == '3' && Ptr[3] == '2') {
if (Ptr[8] == 0 && Ptr[9] == 0 && Ptr[10] == 0 && Ptr[11] == 0) {
DataPtr = Ptr + 12;
DataLen = BlockLen - 12;
}
} else if (Ptr[0] == 't' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
MaskPtr = Ptr + 8;
MaskLen = BlockLen - 8;
}
} else if (FetchPixelSize == 48) {
if (Ptr[0] == 'i' && Ptr[1] == 'h' && Ptr[2] == '3' && Ptr[3] == '2') {
DataPtr = Ptr + 8;
DataLen = BlockLen - 8;
} else if (Ptr[0] == 'h' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
MaskPtr = Ptr + 8;
MaskLen = BlockLen - 8;
}
} else if (FetchPixelSize == 32) {
if (Ptr[0] == 'i' && Ptr[1] == 'l' && Ptr[2] == '3' && Ptr[3] == '2') {
DataPtr = Ptr + 8;
DataLen = BlockLen - 8;
} else if (Ptr[0] == 'l' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
MaskPtr = Ptr + 8;
MaskLen = BlockLen - 8;
}
} else if (FetchPixelSize == 16) {
if (Ptr[0] == 'i' && Ptr[1] == 's' && Ptr[2] == '3' && Ptr[3] == '2') {
DataPtr = Ptr + 8;
DataLen = BlockLen - 8;
} else if (Ptr[0] == 's' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
MaskPtr = Ptr + 8;
MaskLen = BlockLen - 8;
}
}
Ptr += BlockLen;
}
//TODO - take different larger size if not found
// FUTURE: try to load a different size and scale it later
if (DataPtr == NULL && FetchPixelSize == 128) {
FetchPixelSize = 32;
continue;
}
break;
}
if (DataPtr == NULL) {
DBG("not found such IconSize\n");
return NULL; // no image found
}
// allocate image structure and buffer
NewImage = egCreateImage(FetchPixelSize, FetchPixelSize, WantAlpha);
if (NewImage == NULL)
return NULL;
PixelCount = FetchPixelSize * FetchPixelSize;
if (DataLen < PixelCount * 3) {
// pixel data is compressed, RGB planar
CompData = DataPtr;
CompLen = DataLen;
egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->r, PixelCount);
egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->g, PixelCount);
egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->b, PixelCount);
// possible assertion: CompLen == 0
if (CompLen > 0) {
DBG(" egLoadICNSIcon: %d bytes of compressed data left\n", CompLen);
}
} else {
// pixel data is uncompressed, RGB interleaved
SrcPtr = DataPtr;
DestPtr = NewImage->PixelData;
for (i = 0; i < PixelCount; i++, DestPtr++) {
DestPtr->r = *SrcPtr++;
DestPtr->g = *SrcPtr++;
DestPtr->b = *SrcPtr++;
}
}
// Jief : not sure where they should define TODO !
extern VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
extern VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINT64 PixelCount);
// add/set alpha plane
if (MaskPtr != NULL && MaskLen >= PixelCount && WantAlpha)
egInsertPlane(MaskPtr, &NewImage->PixelData->a, PixelCount);
else
egSetPlane(&NewImage->PixelData->a, WantAlpha ? 255 : 0, PixelCount);
// FUTURE: scale to originally requested size if we had to load another size
return NewImage;
}
//#ifndef DEBUG_ALL
//#define DEBUG_IMG 0
//#else
//#define DEBUG_IMG DEBUG_ALL
//#endif
/* EOF */
//
//#if DEBUG_IMG == 0
//#define DBG(...)
//#else
//#define DBG(...) DebugLog(DEBUG_IMG, __VA_ARGS__)
//#endif
//
//
////
//// Decompress .icns RLE data
////
//
//VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *PixelData, IN UINTN PixelCount)
//{
// UINT8 *cp;
// UINT8 *cp_end;
// UINT8 *pp;
// UINTN pp_left;
// UINTN len, i;
// UINT8 value;
//
// // setup variables
// cp = *CompData;
// cp_end = cp + *CompLen;
// pp = PixelData;
// pp_left = PixelCount;
//
// // decode
// while (cp + 1 < cp_end && pp_left > 0) {
// len = *cp++;
// if (len & 0x80) { // compressed data: repeat next byte
// len -= 125;
// if (len > pp_left)
// break;
// value = *cp++;
// for (i = 0; i < len; i++) {
// *pp = value;
// pp += 4;
// }
// } else { // uncompressed data: copy bytes
// len++;
// if (len > pp_left || cp + len > cp_end)
// break;
// for (i = 0; i < len; i++) {
// *pp = *cp++;
// pp += 4;
// }
// }
// pp_left -= len;
// }
//
// if (pp_left > 0) {
// DBG(" egDecompressIcnsRLE: still need %d bytes of pixel data\n", pp_left);
// }
//
// // record what's left of the compressed data stream
// *CompData = cp;
// *CompLen = (UINTN)(cp_end - cp);
//}
//
////
//// Load Apple .icns icons
////
//
//EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha)
//{
// EG_IMAGE *NewImage;
// UINT8 *Ptr, *BufferEnd, *DataPtr, *MaskPtr;
// UINT32 BlockLen, DataLen, MaskLen;
// UINTN FetchPixelSize, PixelCount, i;
// UINT8 *CompData;
// UINTN CompLen;
// UINT8 *SrcPtr;
// EG_PIXEL *DestPtr;
//
// if (FileDataLength < 8 || FileData == NULL ||
// FileData[0] != 'i' || FileData[1] != 'c' || FileData[2] != 'n' || FileData[3] != 's') {
// // not an icns file...
// DBG("not icns\n");
// return NULL;
// }
//
// FetchPixelSize = IconSize;
// for (;;) {
// DataPtr = NULL;
// DataLen = 0;
// MaskPtr = NULL;
// MaskLen = 0;
//
// Ptr = FileData + 8;
// BufferEnd = FileData + FileDataLength;
// // iterate over tagged blocks in the file
// while (Ptr + 8 <= BufferEnd) {
// BlockLen = ((UINT32)Ptr[4] << 24) + ((UINT32)Ptr[5] << 16) + ((UINT32)Ptr[6] << 8) + (UINT32)Ptr[7];
// if (Ptr + BlockLen > BufferEnd) // block continues beyond end of file
// break;
//
// // extract the appropriate blocks for each pixel size
// if (FetchPixelSize == 128) {
// if (Ptr[0] == 'i' && Ptr[1] == 't' && Ptr[2] == '3' && Ptr[3] == '2') {
// if (Ptr[8] == 0 && Ptr[9] == 0 && Ptr[10] == 0 && Ptr[11] == 0) {
// DataPtr = Ptr + 12;
// DataLen = BlockLen - 12;
// }
// } else if (Ptr[0] == 't' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
// MaskPtr = Ptr + 8;
// MaskLen = BlockLen - 8;
// }
//
// } else if (FetchPixelSize == 48) {
// if (Ptr[0] == 'i' && Ptr[1] == 'h' && Ptr[2] == '3' && Ptr[3] == '2') {
// DataPtr = Ptr + 8;
// DataLen = BlockLen - 8;
// } else if (Ptr[0] == 'h' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
// MaskPtr = Ptr + 8;
// MaskLen = BlockLen - 8;
// }
//
// } else if (FetchPixelSize == 32) {
// if (Ptr[0] == 'i' && Ptr[1] == 'l' && Ptr[2] == '3' && Ptr[3] == '2') {
// DataPtr = Ptr + 8;
// DataLen = BlockLen - 8;
// } else if (Ptr[0] == 'l' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
// MaskPtr = Ptr + 8;
// MaskLen = BlockLen - 8;
// }
//
// } else if (FetchPixelSize == 16) {
// if (Ptr[0] == 'i' && Ptr[1] == 's' && Ptr[2] == '3' && Ptr[3] == '2') {
// DataPtr = Ptr + 8;
// DataLen = BlockLen - 8;
// } else if (Ptr[0] == 's' && Ptr[1] == '8' && Ptr[2] == 'm' && Ptr[3] == 'k') {
// MaskPtr = Ptr + 8;
// MaskLen = BlockLen - 8;
// }
//
// }
//
// Ptr += BlockLen;
// }
// //TODO - take different larger size if not found
// // FUTURE: try to load a different size and scale it later
// if (DataPtr == NULL && FetchPixelSize == 128) {
// FetchPixelSize = 32;
// continue;
// }
//
// break;
// }
//
// if (DataPtr == NULL) {
// DBG("not found such IconSize\n");
// return NULL; // no image found
// }
//
// // allocate image structure and buffer
// NewImage = egCreateImage(FetchPixelSize, FetchPixelSize, WantAlpha);
// if (NewImage == NULL)
// return NULL;
// PixelCount = FetchPixelSize * FetchPixelSize;
//
// if (DataLen < PixelCount * 3) {
//
// // pixel data is compressed, RGB planar
// CompData = DataPtr;
// CompLen = DataLen;
// egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->r, PixelCount);
// egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->g, PixelCount);
// egDecompressIcnsRLE(&CompData, &CompLen, &NewImage->PixelData->b, PixelCount);
// // possible assertion: CompLen == 0
// if (CompLen > 0) {
// DBG(" egLoadICNSIcon: %d bytes of compressed data left\n", CompLen);
// }
//
// } else {
//
// // pixel data is uncompressed, RGB interleaved
// SrcPtr = DataPtr;
// DestPtr = NewImage->PixelData;
// for (i = 0; i < PixelCount; i++, DestPtr++) {
// DestPtr->r = *SrcPtr++;
// DestPtr->g = *SrcPtr++;
// DestPtr->b = *SrcPtr++;
// }
//
// }
//
// // Jief : not sure where they should define TODO !
// extern VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
// extern VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINT64 PixelCount);
//
// // add/set alpha plane
// if (MaskPtr != NULL && MaskLen >= PixelCount && WantAlpha)
// egInsertPlane(MaskPtr, &NewImage->PixelData->a, PixelCount);
// else
// egSetPlane(&NewImage->PixelData->a, WantAlpha ? 255 : 0, PixelCount);
//
// // FUTURE: scale to originally requested size if we had to load another size
//
// return NewImage;
//}
////#endif
///* EOF */

View File

@ -66,8 +66,8 @@
entry_scan/securebootkeys.h
gui/menu_items/menu_items.h
gui/menu_items/menu_globals.h
# gui/REFIT_MENU_SCREEN.cpp
# gui/REFIT_MENU_SCREEN.h
gui/REFIT_MENU_SCREEN.cpp
gui/REFIT_MENU_SCREEN.h
libeg/egemb_icons.cpp
libeg/egemb_icons_dark.cpp
libeg/egemb_font.cpp
@ -75,7 +75,7 @@
libeg/BmLib.cpp
libeg/image.cpp
# libeg/load_bmp.cpp
libeg/load_icns.cpp
# libeg/load_icns.cpp
libeg/libscreen.cpp
libeg/lodepng.cpp
libeg/lodepng.h
@ -171,6 +171,8 @@
Platform/sse3_patcher.h
Platform/sse3_5_patcher.h
Version.h
cpp_util/panic.h
cpp_util/panic.cpp
cpp_util/memory.cpp
cpp_util/globals_ctor.cpp
cpp_util/globals_ctor.h

View File

@ -25,7 +25,7 @@ Revision History
#define _SHELL_I_O_H
#include <Library/GenericBdsLib.h>
#include "../gui/menu_items/menu_items.h" // for REFIT_MENU_SCREEN
//#include "../gui/menu_items/menu_items.h"
#include "../gui/REFIT_MENU_SCREEN.h"
#define EFI_TPL_APPLICATION 4