mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Merge pull request #13100 from hrydgard/screen-size-ignore-notch
Android: Add option to ignore camera notches when sizing the game display
This commit is contained in:
7 files changed
+32
-17
No files matched your search
@@ -758,6 +758,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ConfigSetting("SmallDisplayZoomLevel", &g_Config.fSmallDisplayZoomLevel, 1.0f, true, true),
|
||||
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),
|
||||
ConfigSetting("SustainedPerformanceMode", &g_Config.bSustainedPerformanceMode, false, true, true),
|
||||
ConfigSetting("IgnoreScreenInsets", &g_Config.bIgnoreScreenInsets, true, true, false),
|
||||
|
||||
ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true),
|
||||
ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true),
|
||||
|
||||
@@ -156,6 +156,7 @@ public:
|
||||
float fSmallDisplayZoomLevel; //This is used for zoom values, both in and out.
|
||||
bool bImmersiveMode; // Mode on Android Kitkat 4.4 that hides the back button etc.
|
||||
bool bSustainedPerformanceMode; // Android: Slows clocks down to avoid overheating/speed fluctuations.
|
||||
bool bIgnoreScreenInsets; // Android: Center screen disregarding insets if this is enabled.
|
||||
bool bVSync;
|
||||
int iFrameSkip;
|
||||
int iFrameSkipType;
|
||||
|
||||
@@ -661,7 +661,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int
|
||||
std::swap(v0, v1);
|
||||
flags = g_Config.iBufFilter == SCALE_LINEAR ? DRAWTEX_LINEAR : DRAWTEX_NEAREST;
|
||||
flags = flags | DRAWTEX_TO_BACKBUFFER;
|
||||
FRect frame = GetInsetScreenFrame(pixelWidth_, pixelHeight_);
|
||||
FRect frame = GetScreenFrame(pixelWidth_, pixelHeight_);
|
||||
FRect rc;
|
||||
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, frame, ROTATION_LOCKED_HORIZONTAL);
|
||||
SetViewport2D(rc.x, rc.y, rc.w, rc.h);
|
||||
|
||||
@@ -557,7 +557,7 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
|
||||
} else {
|
||||
float pixelW = PSP_CoreParameter().pixelWidth;
|
||||
float pixelH = PSP_CoreParameter().pixelHeight;
|
||||
FRect frame = GetInsetScreenFrame(pixelW, pixelH);
|
||||
FRect frame = GetScreenFrame(pixelW, pixelH);
|
||||
FRect rc;
|
||||
CenterDisplayOutputRect(&rc, 480, 272, frame, ROTATION_LOCKED_HORIZONTAL);
|
||||
displayOffsetX = rc.x;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct Vertex {
|
||||
uint32_t rgba;
|
||||
};
|
||||
|
||||
FRect GetInsetScreenFrame(float pixelWidth, float pixelHeight) {
|
||||
FRect GetScreenFrame(float pixelWidth, float pixelHeight) {
|
||||
FRect rc = FRect{
|
||||
0.0f,
|
||||
0.0f,
|
||||
@@ -49,17 +49,21 @@ FRect GetInsetScreenFrame(float pixelWidth, float pixelHeight) {
|
||||
pixelHeight,
|
||||
};
|
||||
|
||||
// Remove the DPI scale to get back to pixels.
|
||||
float left = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT) / g_dpi_scale_x;
|
||||
float right = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_RIGHT) / g_dpi_scale_x;
|
||||
float top = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP) / g_dpi_scale_y;
|
||||
float bottom = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_BOTTOM) / g_dpi_scale_y;
|
||||
bool applyInset = !g_Config.bIgnoreScreenInsets;
|
||||
|
||||
// Adjust left edge to compensate for cutouts (notches) if any.
|
||||
rc.x += left;
|
||||
rc.w -= (left + right);
|
||||
rc.y += top;
|
||||
rc.h -= (top + bottom);
|
||||
if (applyInset) {
|
||||
// Remove the DPI scale to get back to pixels.
|
||||
float left = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT) / g_dpi_scale_x;
|
||||
float right = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_RIGHT) / g_dpi_scale_x;
|
||||
float top = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP) / g_dpi_scale_y;
|
||||
float bottom = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_BOTTOM) / g_dpi_scale_y;
|
||||
|
||||
// Adjust left edge to compensate for cutouts (notches) if any.
|
||||
rc.x += left;
|
||||
rc.w -= (left + right);
|
||||
rc.y += top;
|
||||
rc.h -= (top + bottom);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -281,7 +285,7 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha
|
||||
} else if (shaderInfo->outputResolution) {
|
||||
// If the current shader uses output res (not next), we will use output res for it.
|
||||
FRect rc;
|
||||
FRect frame = GetInsetScreenFrame((float)pixelWidth_, (float)pixelHeight_);
|
||||
FRect frame = GetScreenFrame((float)pixelWidth_, (float)pixelHeight_);
|
||||
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, frame, g_Config.iInternalScreenRotation);
|
||||
nextWidth = (int)rc.w;
|
||||
nextHeight = (int)rc.h;
|
||||
@@ -528,7 +532,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
|
||||
int lastHeight = srcHeight_;
|
||||
|
||||
// These are the output coordinates.
|
||||
FRect frame = GetInsetScreenFrame((float)pixelWidth_, (float)pixelHeight_);
|
||||
FRect frame = GetScreenFrame((float)pixelWidth_, (float)pixelHeight_);
|
||||
FRect rc;
|
||||
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, frame, uvRotation);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ struct FRect {
|
||||
float h;
|
||||
};
|
||||
|
||||
FRect GetInsetScreenFrame(float pixelWidth, float pixelHeight);
|
||||
FRect GetScreenFrame(float pixelWidth, float pixelHeight);
|
||||
void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &frame, int rotation);
|
||||
|
||||
namespace Draw {
|
||||
|
||||
@@ -313,7 +313,16 @@ void GameSettingsScreen::CreateViews() {
|
||||
displayEditor_ = graphicsSettings->Add(new Choice(gr->T("Display layout editor")));
|
||||
displayEditor_->OnClick.Handle(this, &GameSettingsScreen::OnDisplayLayoutEditor);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
// Hide insets option if no insets, or OS too old.
|
||||
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 29 &&
|
||||
(System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT) != 0.0f ||
|
||||
System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP) != 0.0f ||
|
||||
System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_RIGHT) != 0.0f ||
|
||||
System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_BOTTOM) != 0.0f)) {
|
||||
graphicsSettings->Add(new CheckBox(&g_Config.bIgnoreScreenInsets, gr->T("Ignore camera inset when centering")));
|
||||
}
|
||||
|
||||
// Hide Immersive Mode on pre-kitkat Android
|
||||
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19) {
|
||||
// Let's reuse the Fullscreen translation string from desktop.
|
||||
|
||||
Reference in new issue
Block a user