Skip to content

Commit

Permalink
Merge pull request #16794 from hrydgard/remove-android-resolution-sel…
Browse files Browse the repository at this point in the history
…ector

Remove the Android display resolution selector
  • Loading branch information
hrydgard committed Jan 12, 2023
2 parents 456a25e + ea0eaa3 commit 7813741
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 136 deletions.
29 changes: 0 additions & 29 deletions Core/Config.cpp
Expand Up @@ -669,34 +669,6 @@ static int DefaultFastForwardMode() {
#endif
}

static int DefaultAndroidHwScale() {
#ifdef __ANDROID__
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19 || System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
// Arbitrary cutoff at Kitkat - modern devices are usually powerful enough that hw scaling
// doesn't really help very much and mostly causes problems. See #11151
return 0;
}

// Get the real resolution as passed in during startup, not dp_xres and stuff
int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);

if (xres <= 960) {
// Smaller than the PSP*2, let's go native.
return 0;
} else if (xres <= 480 * 3) { // 720p xres
// Small-ish screen, we should default to 2x
return 2 + 1;
} else {
// Large or very large screen. Default to 3x psp resolution.
return 3 + 1;
}
return 0;
#else
return 1;
#endif
}

// See issue 14439. Should possibly even block these devices from selecting VK.
const char * const vulkanDefaultBlacklist[] = {
"Sony:BRAVIA VH1",
Expand Down Expand Up @@ -889,7 +861,6 @@ static ConfigSetting graphicsSettings[] = {
ReportedConfigSetting("TextureFiltering", &g_Config.iTexFiltering, 1, true, true),
ReportedConfigSetting("BufferFiltering", &g_Config.iBufFilter, SCALE_LINEAR, true, true),
ReportedConfigSetting("InternalResolution", &g_Config.iInternalResolution, &DefaultInternalResolution, true, true),
ReportedConfigSetting("AndroidHwScale", &g_Config.iAndroidHwScale, &DefaultAndroidHwScale),
ReportedConfigSetting("HighQualityDepth", &g_Config.bHighQualityDepth, true, true, true),
ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0, true, true),
ReportedConfigSetting("FrameSkipType", &g_Config.iFrameSkipType, 0, true, true),
Expand Down
3 changes: 0 additions & 3 deletions Core/Config.h
Expand Up @@ -419,9 +419,6 @@ struct Config {

bool bSystemControls;

// Use the hardware scaler to scale up the image to save fillrate. Similar to Windows' window size, really.
int iAndroidHwScale; // 0 = device resolution. 1 = 480x272 (extended to correct aspect), 2 = 960x544 etc.

// Risky JIT optimizations
bool bDiscardRegsOnJRRA;

Expand Down
3 changes: 0 additions & 3 deletions UI/ControlMappingScreen.cpp
Expand Up @@ -853,9 +853,6 @@ void RecreateActivity();

UI::EventReturn TouchTestScreen::OnImmersiveModeChange(UI::EventParams &e) {
System_SendMessage("immersive", "");
if (g_Config.iAndroidHwScale != 0) {
RecreateActivity();
}
return UI::EVENT_DONE;
}

Expand Down
23 changes: 0 additions & 23 deletions UI/GameSettingsScreen.cpp
Expand Up @@ -325,18 +325,6 @@ void GameSettingsScreen::CreateViews() {
}
}

#if PPSSPP_PLATFORM(ANDROID)
if ((deviceType != DEVICE_TYPE_TV) && (deviceType != DEVICE_TYPE_VR)) {
static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
int max_res_temp = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 2;
if (max_res_temp == 3)
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, gr->GetName(), screenManager()));
hwscale->OnChoice.Handle(this, &GameSettingsScreen::OnHwScaleChange); // To refresh the display mode
}
#endif

if (deviceType != DEVICE_TYPE_VR) {
#if !defined(MOBILE_DEVICE)
graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gr->T("FullScreen", "Full Screen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
Expand Down Expand Up @@ -1156,9 +1144,6 @@ UI::EventReturn GameSettingsScreen::OnAdhocGuides(UI::EventParams &e) {

UI::EventReturn GameSettingsScreen::OnImmersiveModeChange(UI::EventParams &e) {
System_SendMessage("immersive", "");
if (g_Config.iAndroidHwScale != 0) {
RecreateActivity();
}
return UI::EVENT_DONE;
}

Expand Down Expand Up @@ -1274,19 +1259,11 @@ UI::EventReturn GameSettingsScreen::OnFullscreenMultiChange(UI::EventParams &e)
}

UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
if (g_Config.iAndroidHwScale == 1) {
RecreateActivity();
}
Reporting::UpdateConfig();
NativeMessageReceived("gpu_renderResized", "");
return UI::EVENT_DONE;
}

UI::EventReturn GameSettingsScreen::OnHwScaleChange(UI::EventParams &e) {
RecreateActivity();
return UI::EVENT_DONE;
}

void GameSettingsScreen::onFinish(DialogResult result) {
if (g_Config.bEnableSound) {
if (PSP_IsInited() && !IsAudioInitialised())
Expand Down
1 change: 0 additions & 1 deletion UI/GameSettingsScreen.h
Expand Up @@ -98,7 +98,6 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
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 OnRenderingMode(UI::EventParams &e);
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
Expand Down
16 changes: 0 additions & 16 deletions UI/NativeApp.cpp
Expand Up @@ -236,22 +236,6 @@ std::string NativeQueryConfig(std::string query) {
return std::string(temp);
} else if (query == "immersiveMode") {
return std::string(g_Config.bImmersiveMode ? "1" : "0");
} else if (query == "hwScale") {
int scale = g_Config.iAndroidHwScale;
// Override hw scale for TV type devices.
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV)
scale = 0;

if (scale == 1) {
// If g_Config.iInternalResolution is also set to Auto (1), we fall back to "Device resolution" (0). It works out.
scale = g_Config.iInternalResolution;
} else if (scale >= 2) {
scale -= 1;
}

int max_res = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 1;
snprintf(temp, sizeof(temp), "%d", std::min(scale, max_res));
return std::string(temp);
} else if (query == "sustainedPerformanceMode") {
return std::string(g_Config.bSustainedPerformanceMode ? "1" : "0");
} else if (query == "androidJavaGL") {
Expand Down
56 changes: 0 additions & 56 deletions android/jni/app-android.cpp
Expand Up @@ -1236,50 +1236,6 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeActivity_requestExitVulkanR
}
}

void correctRatio(int &sz_x, int &sz_y, float scale) {
float x = (float)sz_x;
float y = (float)sz_y;
float ratio = x / y;
INFO_LOG(G3D, "CorrectRatio: Considering size: %0.2f/%0.2f=%0.2f for scale %f", x, y, ratio, scale);
float targetRatio;

// Try to get the longest dimension to match scale*PSP resolution.
if (x >= y) {
targetRatio = 480.0f / 272.0f;
x = 480.f * scale;
y = 272.f * scale;
} else {
targetRatio = 272.0f / 480.0f;
x = 272.0f * scale;
y = 480.0f * scale;
}

float correction = targetRatio / ratio;
INFO_LOG(G3D, "Target ratio: %0.2f ratio: %0.2f correction: %0.2f", targetRatio, ratio, correction);
if (ratio < targetRatio) {
y *= correction;
} else {
x /= correction;
}

sz_x = x;
sz_y = y;
INFO_LOG(G3D, "Corrected ratio: %dx%d", sz_x, sz_y);
}

void getDesiredBackbufferSize(int &sz_x, int &sz_y) {
sz_x = display_xres;
sz_y = display_yres;
std::string config = NativeQueryConfig("hwScale");
int scale;
if (1 == sscanf(config.c_str(), "%d", &scale) && scale > 0) {
correctRatio(sz_x, sz_y, scale);
} else {
sz_x = 0;
sz_y = 0;
}
}

extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JNIEnv *, jclass, jint xres, jint yres, jint dpi, jfloat refreshRate) {
INFO_LOG(G3D, "NativeApp.setDisplayParameters(%d x %d, dpi=%d, refresh=%0.2f)", xres, yres, dpi, refreshRate);

Expand Down Expand Up @@ -1308,18 +1264,6 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JN
}
}

extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_computeDesiredBackbufferDimensions() {
getDesiredBackbufferSize(desiredBackbufferSizeX, desiredBackbufferSizeY);
}

extern "C" jint JNICALL Java_org_ppsspp_ppsspp_NativeApp_getDesiredBackbufferWidth(JNIEnv *, jclass) {
return desiredBackbufferSizeX;
}

extern "C" jint JNICALL Java_org_ppsspp_ppsspp_NativeApp_getDesiredBackbufferHeight(JNIEnv *, jclass) {
return desiredBackbufferSizeY;
}

std::vector<std::string> __cameraGetDeviceList() {
jclass cameraClass = findClass("org/ppsspp/ppsspp/CameraHelper");
jmethodID deviceListMethod = getEnv()->GetStaticMethodID(cameraClass, "getDeviceList", "()Ljava/util/ArrayList;");
Expand Down
5 changes: 0 additions & 5 deletions android/src/org/ppsspp/ppsspp/SizeManager.java
Expand Up @@ -85,11 +85,6 @@ public void surfaceCreated(SurfaceHolder holder) {

Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight + " holder: " + holder.toString() + " or: " + requestedOr);
NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int)densityDpi, refreshRate);
getDesiredBackbufferSize(desiredSize);

// Note that desiredSize might be 0,0 here - but that's fine when calling setFixedSize! It means auto.
Log.d(TAG, "Setting fixed size " + desiredSize.x + " x " + desiredSize.y);
holder.setFixedSize(desiredSize.x, desiredSize.y);
}

@Override
Expand Down

0 comments on commit 7813741

Please sign in to comment.