Compare commits
2 Commits
dev
...
keep_exist
Author | SHA1 | Date | |
---|---|---|---|
6bd32b8eed | |||
d73de2da3f |
@ -129,21 +129,19 @@ public class ScreenCapture extends SurfaceCapture {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Surface surface) {
|
public void start(Surface surface) {
|
||||||
if (display != null) {
|
|
||||||
SurfaceControl.destroyDisplay(display);
|
|
||||||
display = null;
|
|
||||||
}
|
|
||||||
if (virtualDisplay != null) {
|
|
||||||
virtualDisplay.release();
|
|
||||||
virtualDisplay = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int virtualDisplayId;
|
int virtualDisplayId;
|
||||||
PositionMapper positionMapper;
|
PositionMapper positionMapper;
|
||||||
try {
|
try {
|
||||||
Size videoSize = screenInfo.getVideoSize();
|
Size videoSize = screenInfo.getVideoSize();
|
||||||
virtualDisplay = ServiceManager.getDisplayManager()
|
if (virtualDisplay == null) {
|
||||||
.createVirtualDisplay("scrcpy", videoSize.getWidth(), videoSize.getHeight(), displayId, surface);
|
virtualDisplay = ServiceManager.getDisplayManager()
|
||||||
|
.createVirtualDisplay("scrcpy", videoSize.getWidth(), videoSize.getHeight(), displayId, surface);
|
||||||
|
} else {
|
||||||
|
// density doesn't matter since this virtual display is only used for mirroring
|
||||||
|
virtualDisplay.setSurface(surface);
|
||||||
|
virtualDisplay.resize(videoSize.getWidth(), videoSize.getHeight(), 1);
|
||||||
|
|
||||||
|
}
|
||||||
virtualDisplayId = virtualDisplay.getDisplay().getDisplayId();
|
virtualDisplayId = virtualDisplay.getDisplay().getDisplayId();
|
||||||
Rect contentRect = new Rect(0, 0, videoSize.getWidth(), videoSize.getHeight());
|
Rect contentRect = new Rect(0, 0, videoSize.getWidth(), videoSize.getHeight());
|
||||||
// The position are relative to the virtual display, not the original display
|
// The position are relative to the virtual display, not the original display
|
||||||
@ -151,7 +149,9 @@ public class ScreenCapture extends SurfaceCapture {
|
|||||||
Ln.d("Display: using DisplayManager API");
|
Ln.d("Display: using DisplayManager API");
|
||||||
} catch (Exception displayManagerException) {
|
} catch (Exception displayManagerException) {
|
||||||
try {
|
try {
|
||||||
display = createDisplay();
|
if (display == null) {
|
||||||
|
display = createDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
Rect contentRect = screenInfo.getContentRect();
|
Rect contentRect = screenInfo.getContentRect();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user