From ae6ba469c1e2f5490c3c47a1661c5af8591f1d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Feb 2026 14:56:31 +0100 Subject: [PATCH] Fix some more screenshot problems Followup to #21249 --- Core/Screenshot.cpp | 16 ++++++++++------ GPU/Common/GPUDebugInterface.h | 4 +++- UI/EmuScreen.cpp | 7 ++++--- UI/EmuScreen.h | 7 +++---- UI/IAPScreen.cpp | 14 +++++++++----- UI/IAPScreen.h | 2 ++ UI/MainScreen.cpp | 4 ++++ UI/PauseScreen.h | 2 +- 8 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp index 8ef7f077e2..d562d8508c 100644 --- a/Core/Screenshot.cpp +++ b/Core/Screenshot.cpp @@ -320,7 +320,7 @@ static GPUDebugBuffer ApplyRotation(const GPUDebugBuffer &buf, DisplayRotation r } } } - + rotated.SetIsBackbuffer(buf.IsBackBuffer()); return rotated; } @@ -340,29 +340,31 @@ bool ScreenshotNotifyEndOfFrame(Draw::DrawContext *draw) { return false; } + _dbg_assert_(draw); + GPUDebugBuffer buf; if (g_display.rotation != DisplayRotation::ROTATE_0) { - _dbg_assert_(draw); GPUDebugBuffer temp; if (!::GetOutputFramebuffer(draw, temp)) { g_pendingScreenshot.callback(ScreenshotResult::ScreenshotNotPossible); g_pendingScreenshot = {}; return false; } + _dbg_assert_msg_(temp.IsBackBuffer(), "temp isn't backbuffer??"); buf = ApplyRotation(temp, g_display.rotation); } else { - _dbg_assert_(draw); - if (!GetOutputFramebuffer(draw, buf)) { + if (!::GetOutputFramebuffer(draw, buf)) { g_pendingScreenshot.callback(ScreenshotResult::ScreenshotNotPossible); g_pendingScreenshot = {}; return false; } } - - _dbg_assert_(buf.IsBackBuffer()); + _dbg_assert_msg_(buf.IsBackBuffer(), "buf isn't backbuffer?? rotation: %d", g_display.rotation); const int w = buf.GetStride(); const int h = buf.GetHeight(); SaveScreenshotAsync(std::move(buf), w, h, g_pendingScreenshot.maxRes); + // Wipe the screenshot state. + g_pendingScreenshot = {}; return true; } @@ -398,6 +400,8 @@ bool ScreenshotNotifyPostGameRender(Draw::DrawContext *draw) { } SaveScreenshotAsync(std::move(buf), w, h, g_pendingScreenshot.maxRes); + // Wipe the screenshot state. + g_pendingScreenshot = {}; return true; } diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 5e8b2b7ade..00b4488425 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -122,6 +122,7 @@ struct GPUDebugBuffer { height_ = other.height_; stride_ = other.stride_; flipped_ = other.flipped_; + isBackBuffer_ = other.isBackBuffer_; fmt_ = other.fmt_; other.alloc_ = false; other.data_ = nullptr; @@ -131,7 +132,7 @@ struct GPUDebugBuffer { Free(); } - GPUDebugBuffer &operator = (GPUDebugBuffer &&other) noexcept { + GPUDebugBuffer &operator =(GPUDebugBuffer &&other) noexcept { if (this != &other) { Free(); alloc_ = other.alloc_; @@ -140,6 +141,7 @@ struct GPUDebugBuffer { stride_ = other.stride_; flipped_ = other.flipped_; fmt_ = other.fmt_; + isBackBuffer_ = other.isBackBuffer_; other.alloc_ = false; other.data_ = nullptr; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 594fdf95d9..0956ac2dab 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -863,9 +863,6 @@ void EmuScreen::OnVKey(VirtKey virtualKeyCode, bool down) { System_PostUIMessage(UIMessage::SAVESTATE_DISPLAY_SLOT); } break; - case VIRTKEY_SCREENSHOT: - TakeUserScreenshot(); - break; case VIRTKEY_RAPID_FIRE: __CtrlSetRapidFire(down, g_Config.iRapidFireInterval); break; @@ -896,6 +893,10 @@ void EmuScreen::ProcessVKey(VirtKey virtKey) { pauseTrigger_ = true; break; + case VIRTKEY_SCREENSHOT: + TakeUserScreenshot(); + break; + case VIRTKEY_TOGGLE_DEBUGGER: g_Config.bShowImDebugger = !g_Config.bShowImDebugger; break; diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 4f8f97bc96..81dd030ae2 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -73,11 +73,10 @@ protected: ScreenRenderFlags PreRender(ScreenRenderMode mode) override; // ControlListener implementations - void OnVKey(VirtKey virtualKeyCode, bool down); - void OnVKeyAnalog(VirtKey virtualKeyCode, float value); + void OnVKey(VirtKey virtualKeyCode, bool down) override; + void OnVKeyAnalog(VirtKey virtualKeyCode, float value) override; void UpdatePSPButtons(uint32_t buttonMask, uint32_t changedMask) override; - void SetPSPAnalog(int rotation, int stick, float x, float y); - void SetRawAnalog(int deviceId, float x, float y) {} + void SetPSPAnalog(int rotation, int stick, float x, float y) override; private: void CreateViews() override; diff --git a/UI/IAPScreen.cpp b/UI/IAPScreen.cpp index 5db05de21b..87ff640480 100644 --- a/UI/IAPScreen.cpp +++ b/UI/IAPScreen.cpp @@ -86,11 +86,7 @@ void IAPScreen::CreateViews() { WARN_LOG(Log::System, "Purchase failed or cancelled!"); }); } else { -#if PPSSPP_PLATFORM(ANDROID) - System_LaunchUrl(LaunchUrlType::BROWSER_URL, "market://details?id=org.ppsspp.ppssppgold"); -#else - System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold"); -#endif + LaunchPlayStoreOrWebsiteGold(); } }); } @@ -125,3 +121,11 @@ void IAPScreen::CreateViews() { rightColumnItems->Add(restorePurchases); } } + +void LaunchPlayStoreOrWebsiteGold() { +#if PPSSPP_PLATFORM(ANDROID) + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "market://details?id=org.ppsspp.ppssppgold"); +#else + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold"); +#endif +} diff --git a/UI/IAPScreen.h b/UI/IAPScreen.h index 8bc42830bf..836fb7c12c 100644 --- a/UI/IAPScreen.h +++ b/UI/IAPScreen.h @@ -16,3 +16,5 @@ private: // This screen can also be used to direct to Play Store purchases, for example. bool useIAP_ = false; }; + +void LaunchPlayStoreOrWebsiteGold(); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index bc5ea4d61e..1f0400e740 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1604,7 +1604,11 @@ void LaunchBuyGold(ScreenManager *screenManager) { if (System_GetPropertyBool(SYSPROP_USE_IAP)) { screenManager->push(new IAPScreen(true)); } else if (System_GetPropertyBool(SYSPROP_USE_APP_STORE)) { +#if PPSSPP_PLATFORM(ANDROID) + LaunchPlayStoreOrWebsiteGold(); +#else screenManager->push(new IAPScreen(false)); +#endif } else { #if PPSSPP_PLATFORM(IOS_APP_STORE) System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold_ios"); diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 60adc70b56..60fe05fcf4 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -46,7 +46,7 @@ protected: bool UnsyncKey(const KeyInput &key) override; void UnsyncAxis(const AxisInput *axes, size_t count) override; - void OnVKey(VirtKey virtualKeyCode, bool down); + void OnVKey(VirtKey virtualKeyCode, bool down) override; private: void CreateSavestateControls(UI::LinearLayout *viewGroup);