mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-07 08:39:01 +00:00
Recreate the display on rotation
On Android 14 (Pixel 8), a device rotation while the camera app was running resulted in an incorrect capture. Destroying and recreating the display fixes the issue.
This commit is contained in:
parent
abcb100597
commit
7e3b935932
1 changed files with 8 additions and 2 deletions
|
@ -18,7 +18,6 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
display = createDisplay();
|
|
||||||
device.setRotationListener(this);
|
device.setRotationListener(this);
|
||||||
device.setFoldListener(this);
|
device.setFoldListener(this);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +31,11 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
||||||
Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect();
|
Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect();
|
||||||
int videoRotation = screenInfo.getVideoRotation();
|
int videoRotation = screenInfo.getVideoRotation();
|
||||||
int layerStack = device.getLayerStack();
|
int layerStack = device.getLayerStack();
|
||||||
|
|
||||||
|
if (display != null) {
|
||||||
|
SurfaceControl.destroyDisplay(display);
|
||||||
|
}
|
||||||
|
display = createDisplay();
|
||||||
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
|
setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +43,9 @@ public class ScreenCapture extends SurfaceCapture implements Device.RotationList
|
||||||
public void release() {
|
public void release() {
|
||||||
device.setRotationListener(null);
|
device.setRotationListener(null);
|
||||||
device.setFoldListener(null);
|
device.setFoldListener(null);
|
||||||
SurfaceControl.destroyDisplay(display);
|
if (display != null) {
|
||||||
|
SurfaceControl.destroyDisplay(display);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue