From 47523a05572f07e658b78746a68bbb250889e81d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Feb 2021 14:10:18 -0800 Subject: [PATCH 1/2] PPGe: Fallback to atlas text on alloc fail. --- Core/Util/PPGeDraw.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index e6eb5c9e119f..b0734e68cd5b 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -913,8 +913,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 +990,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; From 839be8e63642361cd688d4b6abf3925e6777c8a1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Feb 2021 14:23:35 -0800 Subject: [PATCH 2/2] PPGe: Clear text allocations on shutdown. --- Core/Util/PPGeDraw.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index b0734e68cd5b..bcb0412f8746 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -125,7 +125,7 @@ struct PPGeTextDrawerImage { TextStringEntry entry; u32 ptr; }; -std::map textDrawerImages; +static std::map 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()