Make PositionMapper use affine transforms

This will allow applying transformations performed by video filters.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
This commit is contained in:
Romain Vimont
2024-11-10 13:47:14 +01:00
parent 019ce5eea4
commit e226950cfa
3 changed files with 14 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import com.genymobile.scrcpy.device.ConfigurationException;
import com.genymobile.scrcpy.device.Device;
import com.genymobile.scrcpy.device.DisplayInfo;
import com.genymobile.scrcpy.device.Size;
import com.genymobile.scrcpy.util.AffineMatrix;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.LogUtils;
import com.genymobile.scrcpy.wrappers.DisplayManager;
@@ -145,7 +146,7 @@ public class ScreenCapture extends SurfaceCapture {
.createVirtualDisplay("scrcpy", videoSize.getWidth(), videoSize.getHeight(), displayId, surface);
virtualDisplayId = virtualDisplay.getDisplay().getDisplayId();
// The position are relative to the virtual display, not the original display
positionMapper = new PositionMapper(videoSize, videoSize);
positionMapper = new PositionMapper(videoSize, null);
Ln.d("Display: using DisplayManager API");
} catch (Exception displayManagerException) {
try {
@@ -156,7 +157,9 @@ public class ScreenCapture extends SurfaceCapture {
setDisplaySurface(display, surface, deviceSize.toRect(), videoSize.toRect(), layerStack);
virtualDisplayId = displayId;
positionMapper = new PositionMapper(deviceSize, videoSize);
AffineMatrix videoToDeviceMatrix = videoSize.equals(deviceSize) ? null : AffineMatrix.scale(videoSize, deviceSize);
positionMapper = new PositionMapper(videoSize, videoToDeviceMatrix);
Ln.d("Display: using SurfaceControl API");
} catch (Exception surfaceControlException) {
Ln.e("Could not create display using DisplayManager", displayManagerException);