mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix live resizing, implement setting on all platforms.
This commit is contained in:
parent
852018e899
commit
1a1483478a
8 changed files with 25 additions and 14 deletions
|
@ -56,22 +56,23 @@ DisplayProperties::DisplayProperties() {
|
||||||
|
|
||||||
bool DisplayProperties::Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale) {
|
bool DisplayProperties::Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale) {
|
||||||
bool px_changed = false;
|
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;
|
pixel_xres = new_pixel_xres;
|
||||||
px_changed = true;
|
px_changed = true;
|
||||||
}
|
}
|
||||||
if (pixel_yres != new_pixel_yres) {
|
if (new_pixel_yres > 0 && pixel_yres != new_pixel_yres) {
|
||||||
pixel_yres = new_pixel_yres;
|
pixel_yres = new_pixel_yres;
|
||||||
px_changed = true;
|
px_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dpi_scale_real = new_scale;
|
if (new_scale > 0) {
|
||||||
dpi_scale = new_scale / customScale;
|
dpi_scale_real = new_scale;
|
||||||
|
}
|
||||||
|
dpi_scale = dpi_scale_real / customScale;
|
||||||
pixel_in_dps = 1.0f / dpi_scale;
|
pixel_in_dps = 1.0f / dpi_scale;
|
||||||
|
|
||||||
int new_dp_xres = (int)(new_pixel_xres * dpi_scale);
|
int new_dp_xres = (int)(pixel_xres * dpi_scale);
|
||||||
int new_dp_yres = (int)(new_pixel_yres * dpi_scale);
|
int new_dp_yres = (int)(pixel_yres * dpi_scale);
|
||||||
|
|
||||||
if (new_dp_xres != dp_xres || new_dp_yres != dp_yres || px_changed) {
|
if (new_dp_xres != dp_xres || new_dp_yres != dp_yres || px_changed) {
|
||||||
dp_xres = new_dp_xres;
|
dp_xres = new_dp_xres;
|
||||||
dp_yres = new_dp_yres;
|
dp_yres = new_dp_yres;
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct DisplayProperties {
|
||||||
void Print();
|
void Print();
|
||||||
|
|
||||||
// Returns true if the dimensions changed.
|
// 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);
|
bool Recalculate(int new_pixel_xres, int new_pixel_yres, float new_scale, float customScale);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ QString MainUI::InputBoxGetQString(QString title, QString defaultValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainUI::resizeGL(int w, int h) {
|
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);
|
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
|
||||||
}
|
}
|
||||||
xscale = w / this->width();
|
xscale = w / this->width();
|
||||||
|
@ -842,7 +842,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// We assume physicalDotsPerInchY is the same as PerInchX.
|
// We assume physicalDotsPerInchY is the same as PerInchX.
|
||||||
float dpi_scale = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX();
|
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();
|
refreshRate = screen->refreshRate();
|
||||||
|
|
||||||
|
|
|
@ -780,7 +780,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
|
||||||
bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN);
|
bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN);
|
||||||
|
|
||||||
// This one calls NativeResized if the size changed.
|
// 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
|
// Set variable here in case fullscreen was toggled by hotkey
|
||||||
if (g_Config.UseFullScreen() != fullscreen) {
|
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);
|
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;
|
bool mainThreadIsRender = g_Config.iGPUBackend == (int)GPUBackend::OPENGL;
|
||||||
|
|
||||||
|
|
|
@ -1129,6 +1129,12 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PopupSliderChoice *uiScale = systemSettings->Add(new PopupSliderChoice(&g_Config.iUIScaleFactor, -8, 8, 0, "UI scale factor (DPI adjustment)", screenManager()));
|
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 bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png";
|
||||||
const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg";
|
const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg";
|
||||||
|
|
|
@ -330,7 +330,7 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar
|
||||||
|
|
||||||
PSP_CoreParameter().pixelWidth = (int)(width * scale);
|
PSP_CoreParameter().pixelWidth = (int)(width * scale);
|
||||||
PSP_CoreParameter().pixelHeight = (int)(height * 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);
|
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool recalculateDpi(int pixel_xres, int pixel_yres) {
|
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: 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);
|
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);
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
#include "Common/System/NativeApp.h"
|
#include "Common/System/NativeApp.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
#include "Core/Config.h"
|
||||||
|
#include "Core/ConfigValues.h"
|
||||||
|
|
||||||
#import <AVFoundation/AVFoundation.h>
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
#define IS_IPAD() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
|
#define IS_IPAD() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
|
||||||
|
@ -151,7 +154,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
float dpi_scale = 240.0f / dpi;
|
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];
|
[[sharedViewController getView] setContentScaleFactor:scale];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue