Fix a memory waste in efiStrError().

Create displayFreeMemory().
Few renaming and details that doesn't change behavior.
This commit is contained in:
jief 2023-11-06 23:51:16 +01:00
parent a107644cf2
commit c1ce6aa406
15 changed files with 147 additions and 44 deletions

View File

@ -142,6 +142,19 @@ UINT32 GetCrc32(UINT8 *Buffer, UINTN Size)
return x;
}
extern "C" {
#include <Library/OcMemoryLib.h>
}
void displayFreeMemory(const XString8& prefix)
{
UINTN LowMemory;
UINTN TotalMemory;
TotalMemory = OcCountFreePages (&LowMemory);
DebugLog(1, "--> %s: Firmware has %llu free pages (%llu in lower 4 GB)\n", prefix.c_str(), TotalMemory, LowMemory);
}
XBool haveError = false;

View File

@ -125,10 +125,14 @@ UINT32 GetCrc32(UINT8 *Buffer, UINTN Size);
extern XBool haveError;
#endif // __cplusplus
extern "C" {
void displayFreeMemory(const XString8& prefix);
}
#endif // _UTILS_H_

View File

@ -64,7 +64,7 @@ void construct_globals_objects(EFI_HANDLE ImageHandle)
ctor_ptr* currentCtor = (ctor_ptr*) (((UINTN) (LoadedImage->ImageBase)) + SectionHeader->PointerToRawData);
ctor_ptr* ctorEnd = (ctor_ptr*) (((UINTN) (LoadedImage->ImageBase)) + SectionHeader->PointerToRawData + SectionHeader->Misc.VirtualSize);
DBG("currentBegin %llX, ctorEnd %llX, %lld ctors to call\n", (UINTN)(currentCtor), (UINTN)(ctorEnd), (UINTN)(ctorEnd-currentCtor));
size_t i = 0;
size_t i = 0; (void)i; // avoid warning if DBG is an empty macro
while (currentCtor < ctorEnd)
{
DBG("[%03zu] &ctor %08llX, will call %08llX\n", i, (UINTN)(currentCtor), (UINTN)(*currentCtor));

View File

@ -17,6 +17,7 @@ void* operator new(unsigned long count)
DebugLog(2, "AllocatePool(%lu) returned NULL. Cpu halted\n", count);
CpuDeadLoop();
}
// MemLogf(false, 0, "operator new(%lu) %llx\n", count, uintptr_t(ptr));
return ptr;
}
@ -31,14 +32,22 @@ void* operator new[](unsigned long count)
DebugLog(2, "AllocatePool(%lu) returned NULL. Cpu halted\n", count);
CpuDeadLoop();
}
// MemLogf(false, 0, "operator new[](%lu) %llx\n", count, uintptr_t(ptr));
return ptr;
}
uint64_t operator_delete_count1 = 0;
uint64_t operator_delete_count2 = 0;
uint64_t operator_delete_count3 = 0;
#ifdef _MSC_VER
#pragma warning(disable : 4577)
#endif
void operator delete ( void* ptr ) noexcept
{
// ++operator_delete_count1;
// MemLogf(false, 0, "operator delete(%llx) %lld\n", uintptr_t(ptr), operator_delete_count1);
return FreePool(ptr);
}
@ -48,6 +57,8 @@ void _cdecl operator delete (void * ptr, unsigned __int64 count)
void operator delete (void * ptr, UINTN count)
#endif
{
// ++operator_delete_count2;
// MemLogf(false, 0, "operator delete(%llx, %lld) %lld\n", uintptr_t(ptr), count, operator_delete_count2);
return FreePool(ptr);
}
@ -58,6 +69,8 @@ void _cdecl operator delete[](void * ptr, unsigned __int64 count)
void operator delete[](void * ptr, UINTN count)
#endif
{
// ++operator_delete_count3;
// MemLogf(false, 0, "operator delete[](%llx, %lld) %lld\n", uintptr_t(ptr), count, operator_delete_count3);
return FreePool(ptr);
}

View File

@ -34,8 +34,8 @@ const char* efiStrError(EFI_STATUS Status)
{
size_t size = stdio_static_buf.allocatedSize();
UINTN n = 0;
n = AsciiSPrint(stdio_static_buf.dataSized(size), size, "%r", Status);
while ( n > size - 2 )
n = AsciiSPrint(stdio_static_buf.dataSized(size-1), size-1, "%r", Status); // dataSized(size)-1 is important to avoid stdio_static_buf grow by 1 at each call.
while ( n > size - 3 )
{
size += 10;
n = AsciiSPrint(stdio_static_buf.dataSized(size), size, "%r", Status);

View File

@ -6,6 +6,7 @@ extern "C" {
#endif
#include <Library/MemoryAllocationLib.h>
#include <Library/MemLogLib.h>
#ifdef __cplusplus
}
@ -21,16 +22,21 @@ void abort(void);
inline void* malloc(size_t size)
{
return AllocatePool(size);
void* ptr = AllocatePool(size);
// MemLogf(false, 0, "malloc(%zd) %llx\n", size, uintptr_t(ptr));
return ptr;
}
inline void* reallocWithOldSize(void *ptr, size_t newsize, size_t oldsize) // not the posix realloc. For EFI we need oldsize
{
return ReallocatePool(oldsize, newsize, ptr);
void* newptr = ReallocatePool(oldsize, newsize, ptr);
// MemLogf(false, 0, "reallocWithOldSize(%llx %zd %zd) %llx\n", uintptr_t(ptr), newsize, oldsize, uintptr_t(newptr));
return newptr;
}
inline void free(void *ptr)
{
// MemLogf(false, 0, "free(%llx)\n", uintptr_t(ptr));
FreePool(ptr);
}

View File

@ -555,9 +555,9 @@ EFI_STATUS LoadPlist(const XStringW& ConfName, C* plist)
} else {
}
#ifndef JIEF_DEBUG
if ( !parsingOk || xmlLiteParser.getXmlParserMessageArray().size() - xmlLiteParser.getXmlParserInfoMessageCount() > 0 ) gBS->Stall(3000000); // 3 seconds delay
#endif
return Status;
}

View File

@ -81,7 +81,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
strncpy(IconImage->id, group->id, 63);
break;
}
group = group->next;
group = group->parent;
}
if (group) { //the shape is in the group
// keep this sample for debug purpose
@ -105,7 +105,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString8& IconNameX, OUT XImage*
//there is bounds after nsvgParse()
IconImage->width = shape->bounds[2] - shape->bounds[0];
IconImage->height = shape->bounds[3] - shape->bounds[1];
// DBG("parsed bounds: %f, %f\n", IconImage->width, IconImage->height);
DBG("parsed bounds: %f, %f\n", IconImage->width, IconImage->height);
if ( IconImage->height < 1.f ) {
IconImage->height = 200.f;
}
@ -227,8 +227,8 @@ if ( nsvg__nbDanglingPtr() > 0 ) {
SVGParser = nsvgParse(buffer2, 72, 1.f); //the buffer will be modified, it is how nanosvg works // Jief : NEVER cast const to not const. Just change the parameter to not const !!! Nothing better to deceive.
// nsvg__deleteParser(SVGParser);
if ( nsvg__nbDanglingPtr() > 0 ) {
nsvg__outputDanglingPtr();
nvsg__memoryallocation_verbose = true; // there leaks. Activate verbose
// nsvg__outputDanglingPtr();
// nvsg__memoryallocation_verbose = true; // there leaks. Activate verbose
}else{
nvsg__memoryallocation_verbose = false; // be sure that nvsg__memoryallocation_verbose is false, as it seems there is no memory leaks
}

View File

@ -513,7 +513,7 @@ XTheme::GetThemeTagSettings(const TagDict* DictPointer)
BadgeOffsetY = GetPropertyAsInteger(Prop, BadgeOffsetY);
Prop = Dict->propertyForKey("Scale");
ThemeX->BadgeScale = GetPropertyAsInteger(Prop, BadgeScale);
BadgeScale = GetPropertyAsInteger(Prop, BadgeScale);
}
Dict = DictPointer->dictPropertyForKey("Origination");

View File

@ -735,7 +735,7 @@ void nsvg__deleteParser(NSVGparser* p)
if (p != NULL) {
nsvg__deleteStyles(p->styles);
nsvg__deleteSymbols(p->symbols);
nsvg__deletePaths(p->plist);
nsvg__deletePaths(p->pathList);
nsvg__deleteGradientData(p->gradients);
// do not delete font here, as we free all fonts later by following fontsdb
@ -750,12 +750,12 @@ void nsvg__deleteParser(NSVGparser* p)
attr->fontFace = NULL;
}
while (attr->group) {
NSVGgroup* group = attr->group->next;
NSVGgroup* group = attr->group->parent;
nsvg__delete(attr->group, "nsvg__deleteParser3"_XS8);
attr->group = group;
}
}
FreePool(p);
nsvg__delete(p, "nsvg__deleteParser4"_XS8);
}
}
@ -1098,7 +1098,7 @@ static void nsvg__addShape(NSVGparser* p)
NSVGshape* shape;
// int i;
if (p->plist == NULL /*&& !p->isText*/ )
if (p->pathList == NULL /*&& !p->isText*/ )
return;
shape = (NSVGshape*)nsvg__alloczero(sizeof(NSVGshape), S8Printf("nsvg__addShape %s", attr->id));
@ -1121,8 +1121,8 @@ static void nsvg__addShape(NSVGparser* p)
shape->opacity = attr->opacity;
memcpy(shape->xform, attr->xform, sizeof(float)*6);
shape->paths = p->plist;
p->plist = NULL;
shape->paths = p->pathList;
p->pathList = NULL;
shape->clip.count = attr->clipPathCount;
// if (shape->clip.count > 0) {
@ -1273,8 +1273,8 @@ static void nsvg__addPath(NSVGparser* p, char closed, const char* fromWhere)
path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
}
}
path->next = p->plist;
p->plist = path;
path->next = p->pathList;
p->pathList = path;
return;
}
@ -3191,7 +3191,7 @@ static void nsvg__parseText(NSVGparser* p, char** dict)
// DBG("set help_night->font=%s color=%X size=%f as in HelpRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
break;
}
group = group->next;
group = group->parent;
}
}
@ -3663,7 +3663,6 @@ static void nsvg__parseSymbol(NSVGparser* p, char** dict)
static void nsvg__parseGroup(NSVGparser* p, char** dict)
{
NSVGgroup* group;
NSVGattrib* oldAttr = nsvg__getAttr(p);
nsvg__pushAttr(p);
NSVGattrib* curAttr = nsvg__getAttr(p);
@ -3673,7 +3672,7 @@ static void nsvg__parseGroup(NSVGparser* p, char** dict)
return;
}
// DBG("parse group\n");
group = (NSVGgroup*)nsvg__alloczero(sizeof(NSVGgroup), "nsvg__parseGroup"_XS8);
NSVGgroup* group = (NSVGgroup*)nsvg__alloczero(sizeof(NSVGgroup), "nsvg__parseGroup"_XS8);
// if (curAttr->id[0] == '\0') //skip anonymous groups
// return;
@ -3691,13 +3690,13 @@ static void nsvg__parseGroup(NSVGparser* p, char** dict)
// DBG("parsed groupID=%s\n", group->id);
if (oldAttr != NULL) {
group->next = oldAttr->group;
group->parent = oldAttr->group;
}
curAttr->group = group;
if (!visSet) {
if (group->next != NULL) {
group->visibility = group->next->visibility;
if (group->parent != NULL) {
group->visibility = group->parent->visibility;
} else {
group->visibility = NSVG_VIS_VISIBLE;
}
@ -3968,7 +3967,7 @@ static void nsvg__parseGlyph(NSVGparser* p, char** dict, XBool missing)
return;
}
p->plist = NULL;
p->pathList = NULL;
glyph = (NSVGglyph*)nsvg__alloczero(sizeof(NSVGglyph), "nsvg__parseGlyph"_XS8);
if (!glyph) {
@ -3993,8 +3992,8 @@ static void nsvg__parseGlyph(NSVGparser* p, char** dict, XBool missing)
}
nsvg__parsePath(p, dict);
glyph->path = p->plist; // plist means PathList ;)
p->plist = 0; //lastPath;
glyph->path = p->pathList;
p->pathList = 0; //lastPath;
if (p->font) {
if (missing) {
@ -4617,7 +4616,7 @@ void nsvg__deleteClipPaths(NSVGclipPath* path)
while (path != NULL) {
pnext = path->next;
nsvg__deleteShapes(path->shapes);
FreePool(path);
nsvg__delete(path, "nsvg__deleteClipPaths"_XS8);
path = pnext;
}
}
@ -4630,7 +4629,7 @@ void nsvgDelete(NSVGimage* image)
nsvg__deleteClipPaths(image->clipPaths);
group = image->groups;
while (group != NULL) {
gnext = group->next;
gnext = group->parent;
nsvg__delete(group, "nsvgDelete group"_XS8);
group = gnext;
}

View File

@ -164,9 +164,7 @@ typedef struct NSVGpattern {
typedef struct NSVGgroup
{
char id[kMaxIDLength];
struct NSVGgroup* parent; // Pointer to parent group or NULL
struct NSVGgroup* next; // Pointer to next group or NULL
// struct NSVGshape* xshapeList; // list of shapes inside the group
struct NSVGgroup* parent; // Pointer to next group or NULL
int visibility;
} NSVGgroup;
@ -413,7 +411,7 @@ typedef struct NSVGparser
float* pts;
int npts;
int cpts;
NSVGpath* plist;
NSVGpath* pathList;
NSVGimage* image;
NSVGstyles* styles;
NSVGgradientData* gradients;
@ -458,7 +456,6 @@ void* nsvg__realloc(UINTN oldsize, UINTN newsize, void* ref, const XString8& msg
void nsvg__delete(void* buffer, const XString8& msg);
size_t nsvg__nbDanglingPtr();
void nsvg__outputDanglingPtr();
#endif
bool isShapeInGroup(NSVGshape* shape, const char* groupName);

View File

@ -50,6 +50,7 @@
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_SVG, __VA_ARGS__)
//#define DEBUG_TRACE
#endif
@ -253,6 +254,9 @@ static void nsvg__addPathPoint(NSVGrasterizer* r, NSVGpoint* pt, float* t, int f
static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint* pt)
{
#ifdef DEBUG_TRACE
DBG("nsvg__appendPathPoint\n");
#endif
if (r->npoints+1 > r->cpoints) {
int OldSize = r->cpoints * sizeof(NSVGpoint);
r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
@ -268,6 +272,9 @@ static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint* pt)
static void nsvg__duplicatePoints(NSVGrasterizer* r)
{
#ifdef DEBUG_TRACE
DBG("nsvg__duplicatePoints\n");
#endif
if (r->npoints > r->cpoints2) {
int OldSize = r->cpoints2 * sizeof(NSVGpoint);
r->cpoints2 = r->npoints;
@ -287,6 +294,9 @@ static void nsvg__duplicatePoints(NSVGrasterizer* r)
static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
{
#ifdef DEBUG_TRACE
DBG("nsvg__addEdge\n");
#endif
NSVGedge* e;
// Skip horizontal edges
@ -352,6 +362,9 @@ static float nsvg__controlPathLength(float x1, float y1, float x2, float y2, flo
static void nsvg__flattenCubicBez2(NSVGrasterizer* r, float* x, float* t, int type)
{
#ifdef DEBUG_TRACE
DBG("nsvg__flattenCubicBez2\n");
#endif
float ax, ay, bx, by, cx, cy, dx, dy;
float x1, y1, x2, y2, x3, y3, x4, y4;
// float pointX, pointY;
@ -435,6 +448,9 @@ static void nsvg__flattenCubicBez2(NSVGrasterizer* r, float* x, float* t, int ty
static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float* xform)
{
#ifdef DEBUG_TRACE
DBG("nsvg__flattenShape\n");
#endif
int i, j;
NSVGpath* path;
NSVGpoint pt;
@ -500,6 +516,9 @@ static void nsvg__buttCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right,
static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
{
#ifdef DEBUG_TRACE
DBG("nsvg__squareCap\n");
#endif
float w = lineWidth * 0.5f;
float px = p->x - dx*w, py = p->y - dy*w;
float dlx = dy, dly = -dx;
@ -522,6 +541,9 @@ static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int ncap, int connect)
{
#ifdef DEBUG_TRACE
DBG("nsvg__roundCap\n");
#endif
float w = lineWidth * 0.5f;
float px = p->x, py = p->y;
@ -558,6 +580,9 @@ static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right,
static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
{
#ifdef DEBUG_TRACE
DBG("nsvg__bevelJoin\n");
#endif
float w = lineWidth * 0.5f;
float dlx0 = p0->dy, dly0 = -p0->dx;
float dlx1 = p1->dy, dly1 = -p1->dx;
@ -578,6 +603,9 @@ static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
{
#ifdef DEBUG_TRACE
DBG("nsvg__miterJoin\n");
#endif
float w = lineWidth * 0.5f;
float dlx0 = p0->dy, dly0 = -p0->dx;
float dlx1 = p1->dy, dly1 = -p1->dx;
@ -614,6 +642,9 @@ static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth, int ncap)
{
#ifdef DEBUG_TRACE
DBG("nsvg__roundJoin\n");
#endif
int n;
float w = lineWidth * 0.5f;
float dlx0 = p0->dy, dly0 = -p0->dx;
@ -676,6 +707,9 @@ static int nsvg__curveDivs(float r, float arc, float tol)
static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
{
#ifdef DEBUG_TRACE
DBG("nsvg__expandStroke\n");
#endif
int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); // Calculate divisions per half circle.
NSVGpoint left = {0,0,0,0,0,0,0,0,{0,0,0}}, right = {0,0,0,0,0,0,0,0,{0,0,0}}, firstLeft = {0,0,0,0,0,0,0,0,{0,0,0}}, firstRight = {0,0,0,0,0,0,0,0,{0,0,0}};
NSVGpoint* p0, *p1;
@ -747,6 +781,9 @@ static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints
static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin)
{
#ifdef DEBUG_TRACE
DBG("nsvg__prepareStroke\n");
#endif
NSVGpoint *p0, *p1;
@ -804,6 +841,9 @@ static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoi
static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float* xform)
{
#ifdef DEBUG_TRACE
DBG("nsvg__flattenShapeStroke\n");
#endif
int closed;
NSVGpath* path;
NSVGpoint* p0, *p1;
@ -1007,6 +1047,9 @@ static void nsvg__fillScanline(UINT8* scanline, int len, int x0, int x1, int max
// are wrong, or if the user supplies a too-small bitmap
static void nsvg__fillActiveEdges(UINT8* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule)
{
#ifdef DEBUG_TRACE
DBG("nsvg__fillActiveEdges\n");
#endif
// non-zero winding fill
int x0 = 0, w = 0;
@ -1080,6 +1123,9 @@ static void nsvg__scanlineBit(
UINT8* row, int count, UINT8* cover, int x, int y,
/* float tx, float ty, float scalex, float scaley, */ NSVGcachedPaint* cache)
{
#ifdef DEBUG_TRACE
DBG("nsvg__scanlineBit\n");
#endif
//xxx where is security check that x/8 and (x+count)/8 is inside row[] index?
// called by r->fscanline(&r->bitmap[y * r->stride], xmax-xmin+1, &r->scanline[xmin], xmin, y,/* tx,ty, scalex, scaley, */ cache);
int x1 = x + count;
@ -1091,6 +1137,9 @@ static void nsvg__scanlineBit(
static void nsvg__scanlineSolid(UINT8* row, int count, UINT8* cover, int x, int y,
/* float tx, float ty, float scalex, float scaley, */ NSVGcachedPaint* cache)
{
#ifdef DEBUG_TRACE
DBG("nsvg__scanlineSolid\n");
#endif
// static int once = 0;
UINT8* dst = row + x*4;
if (cache->type == NSVG_PAINT_COLOR) {
@ -1345,6 +1394,9 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r,
/* float tx, float ty, float scalex, float scaley, */
NSVGcachedPaint* cache, char fillRule, NSVGclip* clip)
{
#ifdef DEBUG_TRACE
DBG("nsvg__rasterizeSortedEdges\n");
#endif
NSVGactiveEdge *active = NULL;
int e = 0;
@ -1444,6 +1496,9 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r,
static void nsvg__unpremultiplyAlpha(UINT8* image, int w, int h, int stride)
{
#ifdef DEBUG_TRACE
DBG("nsvg__unpremultiplyAlpha\n");
#endif
// Unpremultiply
for (int y = 0; y < h; y++) {
@ -1503,6 +1558,9 @@ static void nsvg__unpremultiplyAlpha(UINT8* image, int w, int h, int stride)
static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, NSVGshape* shape, float *xformShape)
{
#ifdef DEBUG_TRACE
DBG("nsvg__initPaint\n");
#endif
NSVGgradient* grad = paint->paint.gradient;
@ -1591,6 +1649,9 @@ static void nsvg__rasterizeShapes(NSVGrasterizer* r,
UINT8* dst, int w, int h, int stride,
NSVGscanlineFunction fscanline)
{
#ifdef DEBUG_TRACE
DBG("nsvg__rasterizeShapes %s %f %f %f %f\n", groupName ? groupName : "", tx, ty, scalex, scaley);
#endif
NSVGshape *shape = NULL, *shapeLink = NULL;
float xform[6], xform2[6];
float min_scale = fabsf(scalex) < fabsf(scaley) ? fabsf(scalex) : fabsf(scaley);
@ -1653,6 +1714,9 @@ static void nsvg__rasterizeShapes(NSVGrasterizer* r,
static void renderShape(NSVGrasterizer* r,
NSVGshape* shape, float *xform, float min_scale)
{
#ifdef DEBUG_TRACE
DBG("render shape %s %f %f %f %f %f %f\n", shape->id, xform[0], xform[1], xform[2], xform[3], xform[4], xform[5]);
#endif
NSVGedge *e = NULL;
NSVGcachedPaint cache;

View File

@ -121,7 +121,7 @@ void XTheme::LoadFontImage(IN XBool UseEmbedded, IN INTN Rows, IN INTN Cols)
if (EFI_ERROR(Status)) {
//then take from common font folder
// fontFilePath = SWPrintf(L"%s\\%s", commonFontDir, isKorean ? L"FontKorean.png" : ThemeX->FontFileName.data());
// fontFilePath = SWPrintf(L"%s\\%s", commonFontDir, isKorean ? L"FontKorean.png" : FontFileName.data());
fontFilePath = commonFontDir + FontFileName;
Status = NewImage.LoadXImage(&self.getCloverDir(), fontFilePath);
//else use embedded even if it is not embedded
@ -162,8 +162,8 @@ void XTheme::LoadFontImage(IN XBool UseEmbedded, IN INTN Rows, IN INTN Cols)
(PixelPtr->Red == FirstPixel.Red)
) {
PixelPtr->Reserved = 0; //if a pixel has same color as first pixel then it will be transparent
//} else if (ThemeX->DarkEmbedded) {
} else if (ThemeX->embedded && !ThemeX->Daylight) {
//} else if (DarkEmbedded) {
} else if (embedded && !Daylight) {
*PixelPtr = SemiWhitePixel; //special case to change a text to semi white, not blue pixels
}
FontPtr[Ypos + x] = *PixelPtr++; //not (x, YPos) !!!

View File

@ -173,7 +173,7 @@ void UninitRefitLib(void)
{
// called before running external programs to close open file handles
ThemeX->closeThemeDir();
//ThemeX->closeThemeDir();
selfOem.closeHandle();
self.closeHandle();
@ -190,7 +190,7 @@ EFI_STATUS ReinitRefitLib(void)
selfOem.reInitialize();
ReinitVolumes();
ThemeX->openThemeDir();
//ThemeX->openThemeDir();
return EFI_SUCCESS;
}

View File

@ -674,6 +674,9 @@ void LOADER_ENTRY::StartLoader()
DbgHeader("StartLoader");
DBG("Starting %ls\n", FileDevicePathToXStringW(DevicePath).wc_str());
displayFreeMemory("LOADER_ENTRY::StartLoader()"_XS8);
// while ( OcCountFreePages(NULL) > 300000 && AllocatePages(100) ) /*DBG("Free memory : %lld\n", OcCountFreePages(NULL))*/;
// displayFreeMemory();
if (Settings.notEmpty()) {
DBG(" Settings: %ls\n", Settings.wc_str());
@ -2693,6 +2696,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MsgLog("Build id: %s\n", gBuildId.c_str());
if ( gBuildInfo ) DBG("Build with: [%s]\n", gBuildInfo);
displayFreeMemory(""_XS8);
//dumping SETTING structure
@ -3087,7 +3091,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
gSettings.Boot.FastBoot = false; //Hmm... will never be here
}
#ifdef JIEF_DEBUG
MainMenu.TimeoutSeconds=60;
#endif
AfterTool = false;
gEvent = 0; //clear to cancel loop
while (MainLoopRunning) {
@ -3100,6 +3106,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GlobalConfig.gThemeChanged = false;
ThemeX->ClearScreen();
}
displayFreeMemory("Before RunMainMenu"_XS8);
MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry);
}
// DBG("exit from MainMenu %llu\n", MenuExit); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3