Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPGe: Fallback to atlas text on alloc fail #14067

Merged
merged 2 commits into from
Feb 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -364,6 +364,10 @@ void __PPGeShutdown()

delete textDrawer;
textDrawer = nullptr;

for (auto im : textDrawerImages)
kernelMemory.Free(im.second.ptr);
textDrawerImages.clear();
}

void PPGeBegin()
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down