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: Decimate text images properly #14078

Merged
merged 1 commit into from
Feb 8, 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
25 changes: 15 additions & 10 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float
// Clears the buffer and state when done.
void PPGeDrawCurrentText(u32 color = 0xFFFFFFFF);

static void PPGeDecimateTextImages(int age = 97);

void PPGeSetTexture(u32 dataAddr, int width, int height);

//only 0xFFFFFF of data is used
Expand Down Expand Up @@ -906,6 +908,18 @@ static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, const PP
PPGeSetDefaultTexture();
}

static void PPGeDecimateTextImages(int age) {
// Do this always, in case the platform has no TextDrawer but save state did.
for (auto it = textDrawerImages.begin(); it != textDrawerImages.end(); ) {
if (gpuStats.numFlips - it->second.entry.lastUsedFrame >= age) {
kernelMemory.Free(it->second.ptr);
it = textDrawerImages.erase(it);
} else {
++it;
}
}
}

void PPGeDrawText(const char *text, float x, float y, const PPGeStyle &style) {
if (!text || !strlen(text)) {
return;
Expand Down Expand Up @@ -1300,15 +1314,6 @@ void PPGeNotifyFrame() {
textDrawer->OncePerFrame();
}

// Do this always, in case the platform has no TextDrawer but save state did.
for (auto it = textDrawerImages.begin(); it != textDrawerImages.end(); ) {
if (it->second.entry.lastUsedFrame - gpuStats.numFlips >= 97) {
kernelMemory.Free(it->second.ptr);
it = textDrawerImages.erase(it);
} else {
++it;
}
}

PPGeDecimateTextImages();
PPGeImage::Decimate();
}