diff --git a/Common/System/Display.cpp b/Common/System/Display.cpp index 5cb0a4bee4..731ab1e3c0 100644 --- a/Common/System/Display.cpp +++ b/Common/System/Display.cpp @@ -56,22 +56,23 @@ DisplayProperties::DisplayProperties() { bool DisplayProperties::Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale) { bool px_changed = false; - if (pixel_xres != new_pixel_xres) { + if (new_pixel_xres > 0 && pixel_xres != new_pixel_xres) { pixel_xres = new_pixel_xres; px_changed = true; } - if (pixel_yres != new_pixel_yres) { + if (new_pixel_yres > 0 && pixel_yres != new_pixel_yres) { pixel_yres = new_pixel_yres; px_changed = true; } - dpi_scale_real = new_scale; - dpi_scale = new_scale / customScale; + if (new_scale > 0) { + dpi_scale_real = new_scale; + } + dpi_scale = dpi_scale_real / customScale; pixel_in_dps = 1.0f / dpi_scale; - int new_dp_xres = (int)(new_pixel_xres * dpi_scale); - int new_dp_yres = (int)(new_pixel_yres * dpi_scale); - + int new_dp_xres = (int)(pixel_xres * dpi_scale); + int new_dp_yres = (int)(pixel_yres * dpi_scale); if (new_dp_xres != dp_xres || new_dp_yres != dp_yres || px_changed) { dp_xres = new_dp_xres; dp_yres = new_dp_yres; diff --git a/Common/System/Display.h b/Common/System/Display.h index 3c1bb436a6..658a44e2a1 100644 --- a/Common/System/Display.h +++ b/Common/System/Display.h @@ -41,6 +41,7 @@ struct DisplayProperties { void Print(); // Returns true if the dimensions changed. + // The first three parameters can take -1 to signify "unchanged". bool Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale); }; diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 81d33c927a..5a391c7679 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -549,7 +549,7 @@ QString MainUI::InputBoxGetQString(QString title, QString defaultValue) { } void MainUI::resizeGL(int w, int h) { - if (Native_UpdateScreenScale(w, h, 1.0f)) { + if (Native_UpdateScreenScale(w, h, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor))) { System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); } xscale = w / this->width(); @@ -842,7 +842,7 @@ int main(int argc, char *argv[]) // We assume physicalDotsPerInchY is the same as PerInchX. float dpi_scale = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX(); - g_display.Recalculate(res.width(), res.height(), dpi_scale, 1.0f); + g_display.Recalculate(res.width(), res.height(), dpi_scale, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); refreshRate = screen->refreshRate(); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 2f585b7d0e..1dd710ac35 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -780,7 +780,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN); // This one calls NativeResized if the size changed. - Native_UpdateScreenScale(new_width_px, new_height_px, 1.0f); + Native_UpdateScreenScale(new_width_px, new_height_px, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); // Set variable here in case fullscreen was toggled by hotkey if (g_Config.UseFullScreen() != fullscreen) { @@ -1437,7 +1437,7 @@ int main(int argc, char *argv[]) { float dpi_scale = 1.0f / (g_ForcedDPI == 0.0f ? g_DesktopDPI : g_ForcedDPI); - Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI, 1.0f); + Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); bool mainThreadIsRender = g_Config.iGPUBackend == (int)GPUBackend::OPENGL; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index bbc1b0cc14..99512bbe0c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1129,6 +1129,12 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { #endif PopupSliderChoice *uiScale = systemSettings->Add(new PopupSliderChoice(&g_Config.iUIScaleFactor, -8, 8, 0, "UI scale factor (DPI adjustment)", screenManager())); + uiScale->SetZeroLabel(sy->T("Off")); + uiScale->OnChange.Add([](UI::EventParams &e) { + g_display.Recalculate(-1, -1, -1, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); + NativeResized(); + return UI::EVENT_DONE; + }); const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; diff --git a/UWP/App.cpp b/UWP/App.cpp index 67bafebe0a..74d36aaab4 100644 --- a/UWP/App.cpp +++ b/UWP/App.cpp @@ -330,7 +330,7 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar PSP_CoreParameter().pixelWidth = (int)(width * scale); PSP_CoreParameter().pixelHeight = (int)(height * scale); - if (Native_UpdateScreenScale((int)width, (int)height, 1.0f)) { + if (Native_UpdateScreenScale((int)width, (int)height, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor))) { System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED); } } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 5a00a86c9a..dc132997e6 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1001,7 +1001,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e } static bool recalculateDpi(int pixel_xres, int pixel_yres) { - bool retval = g_display.Recalculate(pixel_xres, pixel_yres, 240.0f / (float)display_dpi, 1.0f); + bool retval = g_display.Recalculate(pixel_xres, pixel_yres, 240.0f / (float)display_dpi, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); INFO_LOG(Log::G3D, "RecalcDPI: display_xres=%d display_yres=%d pixel_xres=%d pixel_yres=%d", display_xres, display_yres, g_display.pixel_xres, g_display.pixel_yres); INFO_LOG(Log::G3D, "RecalcDPI: g_dpi=%d g_dpi_scale=%f dp_xres=%d dp_yres=%d", display_dpi, g_display.dpi_scale, g_display.dp_xres, g_display.dp_yres); diff --git a/ios/DisplayManager.mm b/ios/DisplayManager.mm index 2319d5c944..94ffd8837e 100644 --- a/ios/DisplayManager.mm +++ b/ios/DisplayManager.mm @@ -13,6 +13,9 @@ #include "Common/System/System.h" #include "Common/System/NativeApp.h" #include "Core/System.h" +#include "Core/Config.h" +#include "Core/ConfigValues.h" + #import #define IS_IPAD() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) @@ -151,7 +154,7 @@ } float dpi_scale = 240.0f / dpi; - g_display.Recalculate(size.width * scale, size.height * scale, dpi_scale, 1.0f); + g_display.Recalculate(size.width * scale, size.height * scale, dpi_scale, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); [[sharedViewController getView] setContentScaleFactor:scale];