mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-16 22:01:14 +00:00
Allow display resolution adjustment when streaming at a native resolution
This commit is contained in:
@@ -630,6 +630,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
// On M, we can explicitly set the optimal display mode
|
// On M, we can explicitly set the optimal display mode
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
Display.Mode bestMode = display.getMode();
|
Display.Mode bestMode = display.getMode();
|
||||||
|
boolean isNativeResolutionStream = PreferenceConfiguration.isNativeResolution(prefConfig.width, prefConfig.height);
|
||||||
boolean refreshRateIsGood = isRefreshRateGoodMatch(bestMode.getRefreshRate());
|
boolean refreshRateIsGood = isRefreshRateGoodMatch(bestMode.getRefreshRate());
|
||||||
for (Display.Mode candidate : display.getSupportedModes()) {
|
for (Display.Mode candidate : display.getSupportedModes()) {
|
||||||
boolean refreshRateReduced = candidate.getRefreshRate() < bestMode.getRefreshRate();
|
boolean refreshRateReduced = candidate.getRefreshRate() < bestMode.getRefreshRate();
|
||||||
@@ -641,14 +642,15 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
LimeLog.info("Examining display mode: "+candidate.getPhysicalWidth()+"x"+
|
LimeLog.info("Examining display mode: "+candidate.getPhysicalWidth()+"x"+
|
||||||
candidate.getPhysicalHeight()+"x"+candidate.getRefreshRate());
|
candidate.getPhysicalHeight()+"x"+candidate.getRefreshRate());
|
||||||
|
|
||||||
if (candidate.getPhysicalWidth() > 4096) {
|
if (candidate.getPhysicalWidth() > 4096 && prefConfig.width <= 4096) {
|
||||||
// Avoid resolutions options above 4K to be safe
|
// Avoid resolutions options above 4K to be safe
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On non-4K streams, we force the resolution to never change unless it's above
|
// On non-4K streams, we force the resolution to never change unless it's above
|
||||||
// 60 FPS, which may require a resolution reduction due to HDMI bandwidth limitations.
|
// 60 FPS, which may require a resolution reduction due to HDMI bandwidth limitations,
|
||||||
if (prefConfig.width < 3840 && prefConfig.fps <= 60) {
|
// or it's a native resolution stream.
|
||||||
|
if (prefConfig.width < 3840 && prefConfig.fps <= 60 && !isNativeResolutionStream) {
|
||||||
if (display.getMode().getPhysicalWidth() != candidate.getPhysicalWidth() ||
|
if (display.getMode().getPhysicalWidth() != candidate.getPhysicalWidth() ||
|
||||||
display.getMode().getPhysicalHeight() != candidate.getPhysicalHeight()) {
|
display.getMode().getPhysicalHeight() != candidate.getPhysicalHeight()) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -109,6 +109,30 @@ public class PreferenceConfiguration {
|
|||||||
public boolean touchscreenTrackpad;
|
public boolean touchscreenTrackpad;
|
||||||
public MoonBridge.AudioConfiguration audioConfiguration;
|
public MoonBridge.AudioConfiguration audioConfiguration;
|
||||||
|
|
||||||
|
public static boolean isNativeResolution(int width, int height) {
|
||||||
|
// It's not a native resolution if it matches an existing resolution option
|
||||||
|
if (width == 640 && height == 360) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (width == 854 && height == 480) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (width == 1280 && height == 720) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (width == 1920 && height == 1080) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (width == 2560 && height == 1440) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (width == 3840 && height == 2160) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static String convertFromLegacyResolutionString(String resString) {
|
private static String convertFromLegacyResolutionString(String resString) {
|
||||||
if (resString.equalsIgnoreCase("360p")) {
|
if (resString.equalsIgnoreCase("360p")) {
|
||||||
return RES_360P;
|
return RES_360P;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<item>1440p</item>
|
<item>1440p</item>
|
||||||
<item>4K</item>
|
<item>4K</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Keep this in sync with PreferenceConfiguration.isNativeResolution()! -->
|
||||||
<string-array name="resolution_values" translatable="false">
|
<string-array name="resolution_values" translatable="false">
|
||||||
<item>640x360</item>
|
<item>640x360</item>
|
||||||
<item>854x480</item>
|
<item>854x480</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user