From c5f5d1e45669d676f74eaebb532f55aae99c65f4 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 4 Mar 2020 22:04:56 +0100 Subject: [PATCH] Rename "rotation" to "device rotation" This paves the way to reduce confusion in ScreenInfo when it will handle locked video orientation. --- .../java/com/genymobile/scrcpy/Device.java | 4 ++-- .../com/genymobile/scrcpy/ScreenEncoder.java | 2 +- .../java/com/genymobile/scrcpy/ScreenInfo.java | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index c60761cf..1eebc679 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -34,7 +34,7 @@ public final class Device { @Override public void onRotationChanged(int rotation) throws RemoteException { synchronized (Device.this) { - screenInfo = screenInfo.withRotation(rotation); + screenInfo = screenInfo.withDeviceRotation(rotation); // notify if (rotationListener != null) { @@ -83,7 +83,7 @@ public final class Device { ScreenInfo screenInfo = getScreenInfo(); // read with synchronization Size videoSize = screenInfo.getVideoSize(); - int deviceRotation = screenInfo.getRotation(); + int deviceRotation = screenInfo.getDeviceRotation(); int reverseVideoRotation = getReverseVideoRotation(deviceRotation); // reverse the video rotation to apply the events Position devicePosition = position.rotate(reverseVideoRotation); diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 0ef61e9a..61bccc93 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -67,7 +67,7 @@ public class ScreenEncoder implements Device.RotationListener { ScreenInfo screenInfo = device.getScreenInfo(); Rect contentRect = screenInfo.getContentRect(); Rect videoRect = screenInfo.getVideoSize().toRect(); - int videoRotation = device.getVideoRotation(screenInfo.getRotation()); + int videoRotation = device.getVideoRotation(screenInfo.getDeviceRotation()); setSize(format, videoRotation, videoRect.width(), videoRect.height()); configure(codec, format); Surface surface = codec.createInputSurface(); diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenInfo.java b/server/src/main/java/com/genymobile/scrcpy/ScreenInfo.java index 6dd8460c..3e7cadc3 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenInfo.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenInfo.java @@ -16,12 +16,12 @@ public final class ScreenInfo { /** * Device rotation, related to the natural device orientation (0, 1, 2 or 3) */ - private final int rotation; + private final int deviceRotation; - public ScreenInfo(Rect contentRect, Size videoSize, int rotation) { + public ScreenInfo(Rect contentRect, Size videoSize, int deviceRotation) { this.contentRect = contentRect; this.videoSize = videoSize; - this.rotation = rotation; + this.deviceRotation = deviceRotation; } public Rect getContentRect() { @@ -32,16 +32,16 @@ public final class ScreenInfo { return videoSize; } - public int getRotation() { - return rotation; + public int getDeviceRotation() { + return deviceRotation; } - public ScreenInfo withRotation(int newRotation) { - if (newRotation == rotation) { + public ScreenInfo withDeviceRotation(int newDeviceRotation) { + if (newDeviceRotation == deviceRotation) { return this; } // true if changed between portrait and landscape - boolean orientationChanged = (rotation + newRotation) % 2 != 0; + boolean orientationChanged = (deviceRotation + newDeviceRotation) % 2 != 0; Rect newContentRect; Size newVideoSize; if (orientationChanged) { @@ -51,7 +51,7 @@ public final class ScreenInfo { newContentRect = contentRect; newVideoSize = videoSize; } - return new ScreenInfo(newContentRect, newVideoSize, newRotation); + return new ScreenInfo(newContentRect, newVideoSize, newDeviceRotation); } public static ScreenInfo computeScreenInfo(DisplayInfo displayInfo, Rect crop, int maxSize) {