mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 07:20:31 +02:00
Make the resized flag atomic
On Android it's set on the Java UI thread right after writing g_display, and read on the render thread, which then copies the dp size into the UI bounds just once. With a plain bool the render thread could see the flag before the new size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7ec86c5d5
commit
866cf89b65
1 file changed
+7
-5
+7
-5
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <clocale>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -184,7 +185,9 @@ void SaveFrameDump();
|
||||
ScreenManager *g_screenManager;
|
||||
std::string config_filename;
|
||||
|
||||
static bool resized = false;
|
||||
// Set from any thread (on Android, the Java UI thread right after it writes g_display). Atomic, so the frame
|
||||
// that consumes it also sees those writes - with a plain bool it could see the flag first and keep stale bounds.
|
||||
static std::atomic<bool> resized{false};
|
||||
|
||||
static int renderCounter = 0;
|
||||
|
||||
@@ -1157,10 +1160,9 @@ void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
}
|
||||
|
||||
// Resize before drawing anything, so the first frame at a new size isn't drawn into the old backbuffer.
|
||||
const bool resizedThisFrame = resized;
|
||||
if (resized) {
|
||||
INFO_LOG(Log::G3D, "Resized flag set - recalculating bounds");
|
||||
resized = false;
|
||||
const bool resizedThisFrame = resized.exchange(false);
|
||||
if (resizedThisFrame) {
|
||||
INFO_LOG(Log::G3D, "Resized flag set - recalculating bounds (%dx%d dp)", g_display.dp_xres, g_display.dp_yres);
|
||||
|
||||
if (uiContext) {
|
||||
uiContext->SetBounds(Bounds(0, 0, g_display.dp_xres, g_display.dp_yres));
|
||||
|
||||
Reference in new issue
Block a user