Support scaled cutout & roundedcorners when resolution is overridden

In current desgin, the confgis for cutout and rounded corner are based
on the original display size. If the display resolution is overridden,
cutous and rounded corners will be drawn in incorrect places with
incorrect size.

We should load the cutout & rounded corners with the orignal display
size and then scale the results with the display ratio which is
calculated by dividing current size with original size.

Bug: 209592558
Test: manual:
      1. Go Settings-> Display-> Screen Resolution
      2. Switch between FHD+ and QHD+
      3. Check if the cutout and rounded corner looks the same as they
	 are in the original display size.
Test: manual:
      1. adb shell wm size 1080x2340
      2. Check if the cutout and rounded corner looks the same as they
         are in the original display size.
Test: atest DisplayCutoutTest LocalDisplayAdapterTest
          ScreenDecorationsTest RoundedCornerResDelegateTest
Change-Id: Iea42b73c0276b82983c1ddbce9455355afdc164d
This commit is contained in:
shawnlin
2022-03-17 16:18:41 +08:00
parent b45f0e8ac6
commit bcea9fd89e
14 changed files with 320 additions and 102 deletions

View File

@@ -423,8 +423,9 @@ public class DisplayLayout {
}
final DisplayCutout.CutoutPathParserInfo info = cutout.getCutoutPathParserInfo();
final DisplayCutout.CutoutPathParserInfo newInfo = new DisplayCutout.CutoutPathParserInfo(
info.getDisplayWidth(), info.getDisplayHeight(), info.getDensity(),
info.getCutoutSpec(), rotation, info.getScale());
info.getDisplayWidth(), info.getDisplayHeight(), info.getStableDisplayWidth(),
info.getStableDisplayHeight(), info.getDensity(), info.getCutoutSpec(), rotation,
info.getScale(), info.getPhysicalPixelDisplaySizeRatio());
return computeSafeInsets(
DisplayCutout.constructDisplayCutout(newBounds, waterfallInsets, newInfo),
rotated ? displayHeight : displayWidth,