From ab58827ed66599daf93d22994d30f83ff25d27fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 30 Aug 2023 23:30:23 +0200 Subject: [PATCH 1/3] Callback -> lambda (cleanup) --- UI/GameSettingsScreen.cpp | 10 ++++------ UI/GameSettingsScreen.h | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 7a6b3a3a93..b916b17df9 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -319,7 +319,10 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) max_res_temp = 4; // At least allow 2x int max_res = std::min(max_res_temp, (int)ARRAY_SIZE(deviceResolutions)); UI::PopupMultiChoice *hwscale = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAndroidHwScale, gr->T("Display Resolution (HW scaler)"), deviceResolutions, 0, max_res, I18NCat::GRAPHICS, screenManager())); - hwscale->OnChoice.Handle(this, &GameSettingsScreen::OnHwScaleChange); // To refresh the display mode + hwscale->OnChoice.Add([](UI::EventParams &) { + System_RecreateActivity(); + return UI::EVENT_DONE; + }); } #endif @@ -1333,11 +1336,6 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnHwScaleChange(UI::EventParams &e) { - System_RecreateActivity(); - return UI::EVENT_DONE; -} - void GameSettingsScreen::onFinish(DialogResult result) { Reporting::Enable(enableReports_, "report.ppsspp.org"); Reporting::UpdateConfig(); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 3658874397..14dd4af8e5 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -96,7 +96,6 @@ private: UI::EventReturn OnFullscreenChange(UI::EventParams &e); UI::EventReturn OnFullscreenMultiChange(UI::EventParams &e); UI::EventReturn OnResolutionChange(UI::EventParams &e); - UI::EventReturn OnHwScaleChange(UI::EventParams &e); UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e); UI::EventReturn OnRenderingBackend(UI::EventParams &e); UI::EventReturn OnRenderingDevice(UI::EventParams &e); From e40fbba02b41cefcd28022bda9271e8c2dd3e7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 30 Aug 2023 23:30:49 +0200 Subject: [PATCH 2/3] Log global messages processed --- UI/NativeApp.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 226b942a33..9687f74517 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -153,7 +153,7 @@ #include -void HandleGlobalMessage(const std::string &msg, const std::string &value); +bool HandleGlobalMessage(const std::string &msg, const std::string &value); ScreenManager *g_screenManager; std::string config_filename; @@ -1076,7 +1076,9 @@ void NativeFrame(GraphicsContext *graphicsContext) { } for (const auto &item : toProcess) { - HandleGlobalMessage(item.msg, item.value); + if (HandleGlobalMessage(item.msg, item.value)) { + INFO_LOG(SYSTEM, "Handled global message: %s / %s", item.msg.c_str(), item.value.c_str()); + } g_screenManager->sendMessage(item.msg.c_str(), item.value.c_str()); } @@ -1181,28 +1183,32 @@ void NativeFrame(GraphicsContext *graphicsContext) { } } -void HandleGlobalMessage(const std::string &msg, const std::string &value) { +bool HandleGlobalMessage(const std::string &msg, const std::string &value) { if (msg == "savestate_displayslot") { auto sy = GetI18NCategory(I18NCat::SYSTEM); std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1); // Show for the same duration as the preview. g_OSD.Show(OSDType::MESSAGE_INFO, msg, 2.0f, "savestate_slot"); + return true; } else if (msg == "gpu_displayResized") { if (gpu) { gpu->NotifyDisplayResized(); } + return true; } else if (msg == "gpu_renderResized") { if (gpu) { gpu->NotifyRenderResized(); } + return true; } else if (msg == "gpu_configChanged") { if (gpu) { gpu->NotifyConfigChanged(); } Reporting::UpdateConfig(); + return true; } else if (msg == "core_powerSaving") { if (value != "false") { @@ -1214,6 +1220,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { #endif } Core_SetPowerSaving(value != "false"); + return true; } else if (msg == "permission_granted" && value == "storage") { CreateSysDirectories(); @@ -1227,9 +1234,13 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { g_Config.Reload(); PostLoadConfig(); g_Config.iGPUBackend = gpuBackend; + return true; } else if (msg == "app_resumed" || msg == "got_focus") { // Assume that the user may have modified things. MemoryStick_NotifyWrite(); + return true; + } else { + return false; } } From 4b89fab91c0bafd121dc2682d9f444ae55205339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 30 Aug 2023 23:42:00 +0200 Subject: [PATCH 3/3] NativeInitGraphics: Update core parameter pixel width/height (since we lose resized flag) --- GPU/Common/FramebufferManagerCommon.cpp | 2 ++ GPU/GPUCommonHW.cpp | 2 ++ UI/NativeApp.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5cd77dd8d3..8042a25452 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2622,6 +2622,8 @@ void FramebufferManagerCommon::NotifyDisplayResized() { pixelHeight_ = PSP_CoreParameter().pixelHeight; presentation_->UpdateDisplaySize(pixelWidth_, pixelHeight_); + INFO_LOG(G3D, "FramebufferManagerCommon::NotifyDisplayResized: %dx%d", pixelWidth_, pixelHeight_); + // No drawing is allowed here. This includes anything that might potentially touch a command buffer, like creating images! // So we need to defer the post processing initialization. updatePostShaders_ = true; diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index 3929929ed6..18efa1b9a8 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -447,6 +447,8 @@ void GPUCommonHW::DeviceLost() { // Call at the start of the GPU implementation's DeviceRestore void GPUCommonHW::DeviceRestore(Draw::DrawContext *draw) { draw_ = draw; + displayResized_ = true; // re-check display bounds. + renderResized_ = true; framebufferManager_->DeviceRestore(draw_); textureCache_->DeviceRestore(draw_); shaderManager_->DeviceRestore(draw_); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9687f74517..76b7cf5faa 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -885,6 +885,8 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { g_gameInfoCache = new GameInfoCache(); if (gpu) { + PSP_CoreParameter().pixelWidth = g_display.pixel_xres; + PSP_CoreParameter().pixelHeight = g_display.pixel_yres; gpu->DeviceRestore(g_draw); }