mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-23 16:17:40 +01:00
modify XArray and lodepng to compile as cpp
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
8dbd938bf3
commit
d1043e2673
@ -52,13 +52,26 @@ class XArray
|
||||
xsize Length() const { return m_len; }
|
||||
void SetLength(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); }
|
||||
|
||||
const TYPE& end() const { return ElementAt(m_len - 1); }
|
||||
TYPE& end() { return ElementAt(m_len - 1); }
|
||||
|
||||
xsize insert(const TYPE newElement, xsize pos, xsize count = 1) { return Insert(newElement, pos, count); }
|
||||
const bool empty() const;
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
const TYPE& ElementAt(xsize nIndex) const;
|
||||
TYPE& ElementAt(xsize nIndex);
|
||||
|
||||
const TYPE& operator[](xsize nIndex) const { return ElementAt(nIndex); }
|
||||
TYPE& operator[](xsize nIndex) { return ElementAt(nIndex); }
|
||||
const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); }
|
||||
TYPE& operator[]( int nIndex) { return ElementAt(nIndex); }
|
||||
const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); }
|
||||
TYPE& operator[]( int nIndex) { return ElementAt(nIndex); }
|
||||
|
||||
operator const void *() const { return m_data; };
|
||||
operator void *() { return m_data; };
|
||||
@ -333,4 +346,10 @@ void XArray<TYPE>::Empty()
|
||||
m_len = 0;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
const bool XArray<TYPE>::empty() const
|
||||
{
|
||||
//printf("XArray Empty\n");
|
||||
return m_len == 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -260,7 +260,7 @@ void XImage::GetArea(UINTN x, UINTN y, UINTN W, UINTN H)
|
||||
UINT32 ScreenHeight = 0;
|
||||
UINT32 Depth = 0;
|
||||
UINT32 RefreshRate = 60;
|
||||
EFI_STATUS Status = UgaDraw->GetMode(UgaDraw, &LineWidth, &ScreenHeight, &Depth, &RefreshRate);
|
||||
Status = UgaDraw->GetMode(UgaDraw, &LineWidth, &ScreenHeight, &Depth, &RefreshRate);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return; // graphics not available
|
||||
}
|
||||
@ -277,10 +277,10 @@ void XImage::GetArea(UINTN x, UINTN y, UINTN W, UINTN H)
|
||||
void XImage::Draw(int x, int y, float scale)
|
||||
{
|
||||
//prepare images
|
||||
INTN UGAWidth = 0;
|
||||
INTN UGAHeight = 0;
|
||||
egGetScreenSize(&UGAWidth, &UGAHeight);
|
||||
XImage Background(UGAWidth, UGAHeight);
|
||||
INTN ScreenWidth = 0;
|
||||
INTN ScreenHeight = 0;
|
||||
egGetScreenSize(&ScreenWidth, &ScreenHeight);
|
||||
XImage Background(ScreenWidth, ScreenHeight);
|
||||
Background.GetArea(x, y, Width, Height);
|
||||
XImage Top(*this, scale);
|
||||
Background.Compose(x, y, Top, true);
|
||||
|
@ -6114,7 +6114,8 @@ unsigned decompress(XArray<unsigned char>& out, const unsigned char* in, size_t
|
||||
unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
@ -6136,7 +6137,8 @@ unsigned compress(XArray<unsigned char>& out, const unsigned char* in, size_t in
|
||||
unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
@ -6188,7 +6190,8 @@ unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h, const unsi
|
||||
state.info_raw.colortype = colortype;
|
||||
state.info_raw.bitdepth = bitdepth;
|
||||
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
@ -6209,7 +6212,8 @@ unsigned decode(XArray<unsigned char>& out, unsigned& w, unsigned& h,
|
||||
if(buffer && !error)
|
||||
{
|
||||
size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
}
|
||||
lodepng_free(buffer);
|
||||
return error;
|
||||
@ -6243,7 +6247,8 @@ unsigned encode(XArray<unsigned char>& out, const unsigned char* in, unsigned w,
|
||||
unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
@ -6266,7 +6271,8 @@ unsigned encode(XArray<unsigned char>& out,
|
||||
unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);
|
||||
if(buffer)
|
||||
{
|
||||
out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
// out.insert(out.end(), &buffer[0], &buffer[buffersize]);
|
||||
out.AddArray(buffer, buffersize);
|
||||
lodepng_free(buffer);
|
||||
}
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user