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
|
@Override
|
||||||
public void onRotationChanged(int rotation) throws RemoteException {
|
public void onRotationChanged(int rotation) throws RemoteException {
|
||||||
synchronized (Device.this) {
|
synchronized (Device.this) {
|
||||||
screenInfo = screenInfo.withRotation(rotation);
|
screenInfo = screenInfo.withDeviceRotation(rotation);
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
if (rotationListener != null) {
|
if (rotationListener != null) {
|
||||||
|
@ -83,7 +83,7 @@ public final class Device {
|
||||||
ScreenInfo screenInfo = getScreenInfo(); // read with synchronization
|
ScreenInfo screenInfo = getScreenInfo(); // read with synchronization
|
||||||
Size videoSize = screenInfo.getVideoSize();
|
Size videoSize = screenInfo.getVideoSize();
|
||||||
|
|
||||||
int deviceRotation = screenInfo.getRotation();
|
int deviceRotation = screenInfo.getDeviceRotation();
|
||||||
int reverseVideoRotation = getReverseVideoRotation(deviceRotation);
|
int reverseVideoRotation = getReverseVideoRotation(deviceRotation);
|
||||||
// reverse the video rotation to apply the events
|
// reverse the video rotation to apply the events
|
||||||
Position devicePosition = position.rotate(reverseVideoRotation);
|
Position devicePosition = position.rotate(reverseVideoRotation);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
ScreenInfo screenInfo = device.getScreenInfo();
|
ScreenInfo screenInfo = device.getScreenInfo();
|
||||||
Rect contentRect = screenInfo.getContentRect();
|
Rect contentRect = screenInfo.getContentRect();
|
||||||
Rect videoRect = screenInfo.getVideoSize().toRect();
|
Rect videoRect = screenInfo.getVideoSize().toRect();
|
||||||
int videoRotation = device.getVideoRotation(screenInfo.getRotation());
|
int videoRotation = device.getVideoRotation(screenInfo.getDeviceRotation());
|
||||||
setSize(format, videoRotation, videoRect.width(), videoRect.height());
|
setSize(format, videoRotation, videoRect.width(), videoRect.height());
|
||||||
configure(codec, format);
|
configure(codec, format);
|
||||||
Surface surface = codec.createInputSurface();
|
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)
|
* 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.contentRect = contentRect;
|
||||||
this.videoSize = videoSize;
|
this.videoSize = videoSize;
|
||||||
this.rotation = rotation;
|
this.deviceRotation = deviceRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rect getContentRect() {
|
public Rect getContentRect() {
|
||||||
|
@ -32,16 +32,16 @@ public final class ScreenInfo {
|
||||||
return videoSize;
|
return videoSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRotation() {
|
public int getDeviceRotation() {
|
||||||
return rotation;
|
return deviceRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScreenInfo withRotation(int newRotation) {
|
public ScreenInfo withDeviceRotation(int newDeviceRotation) {
|
||||||
if (newRotation == rotation) {
|
if (newDeviceRotation == deviceRotation) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
// true if changed between portrait and landscape
|
// true if changed between portrait and landscape
|
||||||
boolean orientationChanged = (rotation + newRotation) % 2 != 0;
|
boolean orientationChanged = (deviceRotation + newDeviceRotation) % 2 != 0;
|
||||||
Rect newContentRect;
|
Rect newContentRect;
|
||||||
Size newVideoSize;
|
Size newVideoSize;
|
||||||
if (orientationChanged) {
|
if (orientationChanged) {
|
||||||
|
@ -51,7 +51,7 @@ public final class ScreenInfo {
|
||||||
newContentRect = contentRect;
|
newContentRect = contentRect;
|
||||||
newVideoSize = videoSize;
|
newVideoSize = videoSize;
|
||||||
}
|
}
|
||||||
return new ScreenInfo(newContentRect, newVideoSize, newRotation);
|
return new ScreenInfo(newContentRect, newVideoSize, newDeviceRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ScreenInfo computeScreenInfo(DisplayInfo displayInfo, Rect crop, int maxSize) {
|
public static ScreenInfo computeScreenInfo(DisplayInfo displayInfo, Rect crop, int maxSize) {
|
||||||
|
|
Loading…
Reference in a new issue