Rename "rotation" to "device rotation"
This paves the way to reduce confusion in ScreenInfo when it will handle locked video orientation.
This commit is contained in:
parent
63286424bb
commit
c5f5d1e456
3 changed files with 12 additions and 12 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue