TopologyScale: limit vertical padding

In the original design, we don't allow the vertical padding to be more
than the tallest display block on the top or bottom. This patch simply
applies that strategy that was in the design.

Test: TopologyScaleTest
Bug: b/352648432
Flag: com.android.settings.flags.display_topology_pane_in_display_list
Change-Id: Icd3e0c93e4201d8251de0be4ca636352115c657d
This commit is contained in:
Matthew DeVore
2024-12-03 20:05:54 +00:00
parent 5d2ddfc6dd
commit 607b01760f
2 changed files with 34 additions and 6 deletions

View File

@@ -40,11 +40,11 @@ class TopologyScaleTest {
// blockRatio is higher than 0.05 in order to make the smallest display edge (480 dp) 48dp
// in the pane.
assertEquals(
"{TopoScale blockRatio=0.100000 originPaneXY=288,216 paneHeight=480}", "" + scale)
"{TopoScale blockRatio=0.100000 originPaneXY=288,48 paneHeight=144}", "" + scale)
assertEquals(Point(352, 264), scale.displayToPaneCoor(PointF(640f, 480f)))
assertEquals(Point(320, 240), scale.displayToPaneCoor(PointF(320f, 240f)))
assertEquals(PointF(640f, 480f), scale.paneToDisplayCoor(Point(352, 264)))
assertEquals(Point(352, 96), scale.displayToPaneCoor(PointF(640f, 480f)))
assertEquals(Point(320, 72), scale.displayToPaneCoor(PointF(320f, 240f)))
assertEquals(PointF(640f, 480f), scale.paneToDisplayCoor(Point(352, 96)))
}
@Test
@@ -76,4 +76,22 @@ class TopologyScaleTest {
assertEquals(Point(96, 64), scale.displayToPaneCoor(PointF(0f, -320f)))
assertPointF(220f, -430f, 0.001f, scale.paneToDisplayCoor(Point(140, 42)))
}
@Test
fun paneVerticalPaddingLimitedByTallestDisplay() {
val scale = TopologyScale(
/* paneWidth= */ 300,
listOf(
RectF(0f, 0f, 640f, 480f),
RectF(0f, 480f, 640f, 960f),
RectF(0f, 960f, 640f, 1440f),
RectF(0f, 1440f, 640f, 1920f),
RectF(0f, 1920f, 640f, 2400f),
RectF(0f, 2400f, 640f, 2880f)))
assertEquals(
"{TopoScale blockRatio=0.100000 originPaneXY=118,48 paneHeight=384}", "" + scale)
assertEquals(Point(150, 48), scale.displayToPaneCoor(PointF(320f, 0f)))
assertPointF(-180f, 2880f, 0.001f, scale.paneToDisplayCoor(Point(100, 336)))
}
}