From 12d5ca4d5ee870ed6112b5fa396924a090b206b2 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 12 Oct 2024 09:23:31 +0200 Subject: [PATCH] Move local variables in ScreenCapture Do not initialize variables when they are not used. PR #5370 --- .../com/genymobile/scrcpy/video/ScreenCapture.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java index df7cd8f216..e279f569d3 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java +++ b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java @@ -116,12 +116,6 @@ public void onDisplayFoldChanged(int displayId, boolean folded) { @Override public void start(Surface surface) { - Rect contentRect = screenInfo.getContentRect(); - - // does not include the locked video orientation - Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect(); - int videoRotation = screenInfo.getVideoRotation(); - if (display != null) { SurfaceControl.destroyDisplay(display); display = null; @@ -139,6 +133,13 @@ public void start(Surface surface) { } catch (Exception displayManagerException) { try { display = createDisplay(); + + Rect contentRect = screenInfo.getContentRect(); + + // does not include the locked video orientation + Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect(); + int videoRotation = screenInfo.getVideoRotation(); + setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack); Ln.d("Display: using SurfaceControl API"); } catch (Exception surfaceControlException) {