Merge pull request #18022 from hrydgard/screen-scaler-ingame-fix

Android: Fix changing display resolution scale in-game
This commit is contained in:
Henrik Rydgård 2023-08-31 08:45:39 +02:00 committed by GitHub
commit 3e6788defe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 10 deletions

View File

@ -2614,6 +2614,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;

View File

@ -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_);

View File

@ -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();

View File

@ -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);

View File

@ -153,7 +153,7 @@
#include <Core/HLE/Plugins.h>
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;
@ -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);
}
@ -1076,7 +1078,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 +1185,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 +1222,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 +1236,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;
}
}