feat: remove resolution factor from NewDisplay and Options for simplification

This commit is contained in:
Reynaldo San Juan 2025-09-14 00:21:58 +02:00
parent 34037115a0
commit 5d79f8d0dc
2 changed files with 5 additions and 33 deletions

View file

@ -1,5 +1,8 @@
package com.genymobile.scrcpy;
import android.graphics.Rect;
import android.util.Pair;
import com.genymobile.scrcpy.audio.AudioCodec;
import com.genymobile.scrcpy.audio.AudioSource;
import com.genymobile.scrcpy.device.Device;
@ -14,9 +17,6 @@ import com.genymobile.scrcpy.video.VideoCodec;
import com.genymobile.scrcpy.video.VideoSource;
import com.genymobile.scrcpy.wrappers.WindowManager;
import android.graphics.Rect;
import android.util.Pair;
import java.util.List;
import java.util.Locale;
@ -603,23 +603,9 @@ public class Options {
// Check for resizable flag and resolution factor
boolean resizable = false;
float resolutionFactor = 1.0f;
int rIndex = newDisplay.indexOf(":r");
if (rIndex >= 0) {
resizable = true;
String factorStr = newDisplay.substring(rIndex + 2);
if (!factorStr.isEmpty()) {
try {
resolutionFactor = Float.parseFloat(factorStr);
if (resolutionFactor <= 0.1f) {
resolutionFactor = 0.1f;
} else if (resolutionFactor > 10.0f) {
resolutionFactor = 10.0f;
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid resolution factor: " + factorStr);
}
}
newDisplay = newDisplay.substring(0, rIndex);
}
@ -642,7 +628,7 @@ public class Options {
dpi = 0;
}
return new NewDisplay(size, dpi, resizable, resolutionFactor);
return new NewDisplay(size, dpi, resizable);
}
private static Pair<Orientation.Lock, Orientation> parseCaptureOrientation(String value) {

View file

@ -4,23 +4,16 @@ public final class NewDisplay {
private Size size;
private int dpi;
private final boolean resizable;
private float resolutionFactor;
public NewDisplay() {
// Auto size and dpi, not resizable
this.resizable = false;
this.resolutionFactor = 1.0f;
}
public NewDisplay(Size size, int dpi, boolean resizable) {
this(size, dpi, resizable, 1.0f);
}
public NewDisplay(Size size, int dpi, boolean resizable, float resolutionFactor) {
this.size = size;
this.dpi = dpi;
this.resizable = resizable;
this.resolutionFactor = resolutionFactor;
}
public Size getSize() {
@ -42,12 +35,5 @@ public final class NewDisplay {
public boolean hasExplicitDpi() {
return dpi != 0;
}
public float getResolutionFactor() {
return resolutionFactor;
}
public boolean hasResolutionFactor() {
return resolutionFactor != 1.0f;
}
}