Graphics.transition average FPS bugfix

Move average FPS update logic into new function updateAvgFPS()
Call this during Graphics.transition so that the FPS counter does not erroneously drop
This commit is contained in:
Eblo 2023-10-20 12:32:43 -04:00
parent 52c932b9a0
commit 7a12e6ddcf
No known key found for this signature in database
GPG key ID: 214AFBC4697F23AC

View file

@ -1083,14 +1083,7 @@ struct GraphicsPrivate {
swapGLBuffer();
SDL_LockMutex(avgFPSLock);
if (avgFPSData.size() > 40)
avgFPSData.erase(avgFPSData.begin());
double time = shState->runTime();
avgFPSData.push_back(time - last_avg_update);
last_avg_update = time;
SDL_UnlockMutex(avgFPSLock);
updateAvgFPS();
}
void checkSyncLock() {
@ -1130,6 +1123,17 @@ struct GraphicsPrivate {
SDL_UnlockMutex(glResourceLock);
}
void updateAvgFPS() {
SDL_LockMutex(avgFPSLock);
if (avgFPSData.size() > 40)
avgFPSData.erase(avgFPSData.begin());
double time = shState->runTime();
avgFPSData.push_back(time - last_avg_update);
last_avg_update = time;
SDL_UnlockMutex(avgFPSLock);
}
};
Graphics::Graphics(RGSSThreadData *data) {
@ -1309,6 +1313,8 @@ void Graphics::transition(int duration, const char *filename, int vague) {
GLMeta::blitEnd();
p->swapGLBuffer();
/* Call this manually, as redrawScreen() is not called during this loop. */
p->updateAvgFPS();
}
glState.blend.pop();