mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
iOS: Apply size changes between frames, fixing a glitch when rotating
UIKit lays out at the new size from the main thread, often while a frame is being drawn, and the swapchain was only resized after presenting. So the first frame of a rotation was laid out for one size and drawn at the other. The view controller now hands the new size to the render thread, and NativeFrame resizes before drawing instead of after presenting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f8939173c
commit
9741bcacd9
2 files changed
+72
-39
No files matched your search
+25
-29
@@ -1159,6 +1159,29 @@ void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
g_audioBackend->FrameUpdate(g_Config.bAutoSwitchAudioDevice);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
if (uiContext) {
|
||||
uiContext->SetBounds(Bounds(0, 0, g_display.dp_xres, g_display.dp_yres));
|
||||
}
|
||||
|
||||
graphicsContext->Resize();
|
||||
g_screenManager->resized();
|
||||
|
||||
// TODO: Move this to the GraphicsContext objects for each backend.
|
||||
// (Android used to be left out here, since every size change there was a full graphics restart,
|
||||
// and DeviceRestore covers it. Rotation and window resizing are in-place now.)
|
||||
#if !PPSSPP_PLATFORM(WINDOWS)
|
||||
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
|
||||
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
|
||||
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: We must begin the frame before update, so we can do texture size queries and stuff in Measure etc.
|
||||
Draw::DebugFlags debugFlags = Draw::DebugFlags::NONE;
|
||||
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE)
|
||||
@@ -1317,35 +1340,8 @@ void NativeFrame(GraphicsContext *graphicsContext) {
|
||||
|
||||
g_draw->Present(g_frameTiming.PresentMode());
|
||||
|
||||
if (resized) {
|
||||
INFO_LOG(Log::G3D, "Resized flag set - recalculating bounds");
|
||||
resized = false;
|
||||
|
||||
if (uiContext) {
|
||||
uiContext->SetBounds(Bounds(0, 0, g_display.dp_xres, g_display.dp_yres));
|
||||
|
||||
// OSX 10.6 and SDL 1.2 bug.
|
||||
#if defined(__APPLE__)
|
||||
static int dp_xres_old = g_display.dp_xres;
|
||||
if (g_display.dp_xres != dp_xres_old) {
|
||||
dp_xres_old = g_display.dp_xres;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
graphicsContext->Resize();
|
||||
g_screenManager->resized();
|
||||
|
||||
// TODO: Move this to the GraphicsContext objects for each backend.
|
||||
// (Android used to be left out here, since every size change there was a full graphics restart,
|
||||
// and DeviceRestore covers it. Rotation and window resizing are in-place now.)
|
||||
#if !PPSSPP_PLATFORM(WINDOWS)
|
||||
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
|
||||
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
|
||||
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
|
||||
#endif
|
||||
} else {
|
||||
// INFO_LOG(Log::G3D, "Polling graphics context");
|
||||
// Not done if we resized at the start of the frame, the swapchain is new.
|
||||
if (!resizedThisFrame) {
|
||||
graphicsContext->Poll();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user