port: grp.SaveScreenShot via next-frame swapchain readback + JPEG

CPythonGraphic::SaveScreenShot queues a readback of the next presented
frame (ScreenShotHost -> VulkanWindow::request_frame); WriteScreenShot runs
the rest of 40250's function verbatim (X8R8G8B8 rows, SaveJPEG, EXIF tag).
jpeg_save is encoded with stb_image_write. SHGetSpecialFolderPath returns
$HOME/Documents (else cwd); CreateDirectory/_access/jpeg_save accept '\\'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 12:43:03 +09:00
co-authored by Claude Opus 5.5
parent c21e012965
commit bda85eea50
17 changed files with 2211 additions and 12 deletions
@@ -63,13 +63,32 @@
"note": "Verbatim 40250. The recording device reports no D3DCAPS2_FULLSCREENGAMMA (windowed output, where D3D8 ignores the ramp as well), so it returns at the caps check; IDirect3DDevice8::SetGammaRamp added to the D3D8 shim."
},
"GenScreenShotTag": {
"status": "TODO"
"status": "PORTED",
"impl": [
"src/platform/EterPythonLib/PythonGraphic.cpp:GenScreenShotTag"
],
"note": "Verbatim 40250; only reached when g_isScreenShotKey (false, never set)."
},
"CPythonGraphic::SaveJPEG": {
"status": "TODO"
"status": "PORTED",
"impl": [
"src/platform/EterPythonLib/PythonGraphic.cpp:CPythonGraphic::SaveJPEG"
],
"test": [
"tests/port/port_screenshot_test.cpp"
]
},
"CPythonGraphic::SaveScreenShot": {
"status": "TODO"
"status": "ADAPTED",
"impl": [
"src/platform/EterPythonLib/PythonGraphic.cpp:CPythonGraphic::SaveScreenShot",
"src/platform/EterPythonLib/PythonGraphic.cpp:ScreenShotHost::WriteScreenShot",
"src/host/live_client.cpp"
],
"test": [
"tests/port/port_screenshot_test.cpp"
],
"note": "40250 locks the D3D8 back buffer and writes the JPEG before returning. The script thread and the SDL host alternate, so the call queues a readback of the next presented frame (ScreenShotHost::SetRequest -> VulkanWindow::request_frame) and returns true; ScreenShotHost::WriteScreenShot runs the rest verbatim one frame later (X8R8G8B8 row loop, SaveJPEG, TraceError on failure, g_isScreenShotKey EXIF block). No host -> TraceError + false (40250's GetBackBuffer failure). Only the X8R8G8B8 branch exists: the swapchain is read back as BGRA. Checked on desktop: grp.SaveScreenShot() wrote ~/Documents/METIN2/<MMDD_hhmmss>.jpg with correct colours (SHGetSpecialFolderPath shim = $HOME/Documents, else cwd)."
},
"CPythonGraphic::PushState": {
"status": "PORTED",