Merge pull request #14067 from unknownbrackets/ppge-text-alloc

PPGe: Fallback to atlas text on alloc fail
This commit is contained in:
Henrik Rydgård 2021-02-07 09:09:17 +01:00 committed by GitHub
commit 93478e0b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,7 +125,7 @@ struct PPGeTextDrawerImage {
TextStringEntry entry;
u32 ptr;
};
std::map<PPGeTextDrawerCacheKey, PPGeTextDrawerImage> textDrawerImages;
static std::map<PPGeTextDrawerCacheKey, PPGeTextDrawerImage> textDrawerImages;
void PPGeSetDrawContext(Draw::DrawContext *draw) {
g_draw = draw;
@ -364,6 +364,10 @@ void __PPGeShutdown()
delete textDrawer;
textDrawer = nullptr;
for (auto im : textDrawerImages)
kernelMemory.Free(im.second.ptr);
textDrawerImages.clear();
}
void PPGeBegin()
@ -913,8 +917,10 @@ void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) {
if (HasTextDrawer()) {
PPGeTextDrawerImage im = PPGeGetTextImage(text, style, 480.0f - x, false);
PPGeDrawTextImage(im, x, y, style);
return;
if (im.ptr) {
PPGeDrawTextImage(im, x, y, style);
return;
}
}
if (style.hasShadow) {
@ -988,8 +994,10 @@ void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, fl
}
PPGeTextDrawerImage im = PPGeGetTextImage(s.c_str(), adjustedStyle, wrapWidth <= 0 ? 480.0f - x : wrapWidth, true);
PPGeDrawTextImage(im, x, y, adjustedStyle);
return;
if (im.ptr) {
PPGeDrawTextImage(im, x, y, adjustedStyle);
return;
}
}
int sx = style.hasShadow ? 1 : 0;