mirror of https://github.com/Genymobile/scrcpy
Handle resized video stream
Accept a parameter to limit the video size. For instance, with "-m 960", the great side of the video will be scaled down to 960 (if necessary), while the other side will be scaled down so that the aspect ratio is preserved. Both dimensions must be a multiple of 8, so black bands might be added, and the mouse positions must be computed accordingly.hidpi
parent
2c4ea6869e
commit
89f6a3cfe7
@ -0,0 +1,20 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
public final class DisplayInfo {
|
||||
private final Size size;
|
||||
private final int rotation;
|
||||
|
||||
public DisplayInfo(Size size, int rotation) {
|
||||
this.size = size;
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
public Size getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
public class Options {
|
||||
private int maximumSize;
|
||||
|
||||
public int getMaximumSize() {
|
||||
return maximumSize;
|
||||
}
|
||||
|
||||
public void setMaximumSize(int maximumSize) {
|
||||
this.maximumSize = maximumSize;
|
||||
}
|
||||
}
|
@ -1,42 +1,48 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Position {
|
||||
private Point point;
|
||||
private Size screenSize;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
public Position(Point point, Size screenSize) {
|
||||
this.point = point;
|
||||
this.screenSize = screenSize;
|
||||
}
|
||||
|
||||
public Position(int x, int y, int screenWidth, int screenHeight) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
this(new Point(x, y), new Size(screenWidth, screenHeight));
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
public Point getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
public Size getScreenSize() {
|
||||
return screenSize;
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return screenWidth;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Position position = (Position) o;
|
||||
return Objects.equals(point, position.point) &&
|
||||
Objects.equals(screenSize, position.screenSize);
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return screenHeight;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(point, screenSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Point{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", screenWidth=" + screenWidth +
|
||||
", screenHeight=" + screenHeight +
|
||||
return "Position{" +
|
||||
"point=" + point +
|
||||
", screenSize=" + screenSize +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,26 +1,39 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
public class ScreenInfo {
|
||||
private final int width;
|
||||
private final int height;
|
||||
private int rotation;
|
||||
public final class ScreenInfo {
|
||||
private final Size deviceSize;
|
||||
private final Size videoSize;
|
||||
private final int padding; // padding inside the video stream, along the smallest dimension
|
||||
private final boolean rotated;
|
||||
|
||||
public ScreenInfo(int width, int height, int rotation) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.rotation = rotation;
|
||||
public ScreenInfo(Size deviceSize, Size videoSize, int padding, boolean rotated) {
|
||||
this.deviceSize = deviceSize;
|
||||
this.videoSize = videoSize;
|
||||
this.padding = padding;
|
||||
this.rotated = rotated;
|
||||
}
|
||||
|
||||
public ScreenInfo withRotation(int rotation) {
|
||||
return new ScreenInfo(width, height, rotation);
|
||||
public Size getDeviceSize() {
|
||||
return deviceSize;
|
||||
}
|
||||
|
||||
public int getLogicalWidth() {
|
||||
return (rotation & 1) == 0 ? width : height;
|
||||
public Size getVideoSize() {
|
||||
return videoSize;
|
||||
}
|
||||
|
||||
public int getLogicalHeight() {
|
||||
return (rotation & 1) == 0 ? height : width;
|
||||
public int getXPadding() {
|
||||
return videoSize.getWidth() < videoSize.getHeight() ? padding : 0;
|
||||
}
|
||||
|
||||
public int getYPadding() {
|
||||
return videoSize.getHeight() < videoSize.getWidth() ? padding : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public ScreenInfo withRotation(int rotation) {
|
||||
boolean newRotated = (rotation & 1) != 0;
|
||||
if (rotated == newRotated) {
|
||||
return this;
|
||||
}
|
||||
return new ScreenInfo(deviceSize.rotate(), videoSize.rotate(), padding, newRotated);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Size {
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public Size(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public Size rotate() {
|
||||
return new Size(height, width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Size size = (Size) o;
|
||||
return width == size.width &&
|
||||
height == size.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Size{" +
|
||||
"width=" + width +
|
||||
", height=" + height +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue