Skip to content

Commit

Permalink
Merge pull request #18704 from hrydgard/fix-crop-to-16x9
Browse files Browse the repository at this point in the history
Revert back to the old way of fitting into 16:9: Crop one line at the top and bottom
  • Loading branch information
hrydgard committed Jan 15, 2024
2 parents 8b282a5 + e908034 commit 98c061f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ static const ConfigSetting graphicsSettings[] = {
ConfigSetting("iShowStatusFlags", &g_Config.iShowStatusFlags, 0, CfgFlag::PER_GAME),
ConfigSetting("GraphicsBackend", &g_Config.iGPUBackend, &DefaultGPUBackend, &GPUBackendTranslator::To, &GPUBackendTranslator::From, CfgFlag::DEFAULT | CfgFlag::REPORT),
#if PPSSPP_PLATFORM(ANDROID) && PPSSPP_ARCH(ARM64)
ConfigSetting("CustomDriver", &g_Config.customDriver, "", CfgFlag::DEFAULT),
ConfigSetting("CustomDriver", &g_Config.customDriver, "", CfgFlag::DEFAULT),
#endif
ConfigSetting("FailedGraphicsBackends", &g_Config.sFailedGPUBackends, "", CfgFlag::DEFAULT),
ConfigSetting("DisabledGraphicsBackends", &g_Config.sDisabledGPUBackends, "", CfgFlag::DEFAULT),
Expand Down Expand Up @@ -647,6 +647,7 @@ static const ConfigSetting graphicsSettings[] = {
ConfigSetting("DisplayIntegerScale", &g_Config.bDisplayIntegerScale, false, CfgFlag::PER_GAME),
ConfigSetting("DisplayAspectRatio", &g_Config.fDisplayAspectRatio, 1.0f, CfgFlag::PER_GAME),
ConfigSetting("DisplayStretch", &g_Config.bDisplayStretch, false, CfgFlag::PER_GAME),
ConfigSetting("DisplayCropTo16x9", &g_Config.bDisplayCropTo16x9, true, CfgFlag::PER_GAME),

ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, true, CfgFlag::PER_GAME),
ConfigSetting("SustainedPerformanceMode", &g_Config.bSustainedPerformanceMode, false, CfgFlag::PER_GAME),
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct Config {
float fDisplayOffsetY;
float fDisplayScale; // Relative to the most constraining axis (x or y).
bool bDisplayIntegerScale; // Snaps scaling to integer scale factors in raw pixels.
bool bDisplayCropTo16x9; // Crops to 16:9 if the resolution is very close.
float fDisplayAspectRatio; // Stored relative to the PSP's native ratio, so 1.0 is the normal pixel aspect ratio.

bool bImmersiveMode; // Mode on Android Kitkat 4.4 and later that hides the back button etc.
Expand Down
17 changes: 9 additions & 8 deletions GPU/Common/PresentationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ void CalculateDisplayOutputRect(FRect *rc, float origW, float origH, const FRect
float scale = g_Config.fDisplayScale;
float aspectRatioAdjust = g_Config.fDisplayAspectRatio;

// Ye olde 1080p hack, new version: If everything is setup to exactly cover the screen (defaults), and the screen display aspect ratio is 16:9,
// stretch the PSP's aspect ratio veeery slightly to fill it completely.
if (scale == 1.0f && offsetX == 0.5f && offsetY == 0.5f && aspectRatioAdjust == 1.0f && !g_Config.bDisplayIntegerScale) {
if (fabsf(frame.w / frame.h - 16.0f / 9.0f) < 0.0001f) {
aspectRatioAdjust = (frame.w / frame.h) / (480.0f / 272.0f);
}
}

float origRatio = !rotated ? origW / origH : origH / origW;
float frameRatio = frame.w / frame.h;

Expand Down Expand Up @@ -121,6 +113,15 @@ void CalculateDisplayOutputRect(FRect *rc, float origW, float origH, const FRect
outH = scaledHeight;
}

// Ye olde 1080p hack: If everything is setup to exactly cover the screen (defaults), and the screen display aspect ratio is 16:9,
// cut off one line from the top and bottom.
if (scale == 1.0f && aspectRatioAdjust == 1.0f && offsetX == 0.5f && offsetY == 0.5f && !g_Config.bDisplayIntegerScale && g_Config.bDisplayCropTo16x9) {
if (fabsf(frame.w / frame.h - 16.0f / 9.0f) < 0.0001f) {
outW *= 272.0f / 270.0f;
outH *= 272.0f / 270.0f;
}
}

if (g_Config.bDisplayIntegerScale) {
float wDim = 480.0f;
if (rotated) {
Expand Down

0 comments on commit 98c061f

Please sign in to comment.