mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
Align the virtual display size
When the virtual display size is not aligned, a resize filter may be inserted to compensate for small dimension mismatches, increasing processing and resulting in a blurry image. PR #6771 <https://github.com/Genymobile/scrcpy/pull/6771>
This commit is contained in:
parent
965d0e6856
commit
266e2eaf14
2 changed files with 16 additions and 1 deletions
|
|
@ -84,6 +84,15 @@ public final class Size {
|
|||
return new Size(w, h);
|
||||
}
|
||||
|
||||
public Size align(int alignment) {
|
||||
int w = width / alignment * alignment;
|
||||
int h = height / alignment * alignment;
|
||||
if (w == width && h == height) {
|
||||
return this;
|
||||
}
|
||||
return new Size(w, h);
|
||||
}
|
||||
|
||||
private static int round(int value, int alignment) {
|
||||
return (value + (alignment / 2)) / alignment * alignment;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ public class NewDisplayCapture extends SurfaceCapture {
|
|||
if (!newDisplay.hasExplicitSize()) {
|
||||
displaySize = mainDisplaySize;
|
||||
}
|
||||
|
||||
// Align the physical display size to avoid unnecessary mismatches with the output size
|
||||
displaySize = displaySize.align(getVideoConstraints().getAlignment());
|
||||
|
||||
if (!newDisplay.hasExplicitDpi()) {
|
||||
dpi = scaleDpi(mainDisplaySize, mainDisplayDpi, displaySize);
|
||||
}
|
||||
|
|
@ -117,9 +121,11 @@ public class NewDisplayCapture extends SurfaceCapture {
|
|||
displayMonitor.setSessionDisplayProperties(new DisplayProperties(displaySize, displayRotation));
|
||||
} else {
|
||||
DisplayInfo displayInfo = ServiceManager.getDisplayManager().getDisplayInfo(virtualDisplay.getDisplay().getDisplayId());
|
||||
displaySize = displayInfo.getSize();
|
||||
dpi = displayInfo.getDpi();
|
||||
displayRotation = displayInfo.getRotation();
|
||||
|
||||
// Align the physical display size to avoid unnecessary mismatches with the output size
|
||||
displaySize = displayInfo.getSize().align(getVideoConstraints().getAlignment());
|
||||
}
|
||||
|
||||
VideoFilter filter = new VideoFilter(displaySize);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue