Apply display density to topology pane scaling
Account for high DPI screens in topology pane scaling. Flag: com.android.settings.flags.display_topology_pane_in_display_list Bug: b/352650922 Test: atest DisplayTopologyPreferenceTest.kt Test: atest TopologyScaleTest.kt Test: compare appearance on mid-dpi and high-dpi screens with a single 1080p external display Change-Id: I192fccd402c20e00beacdb5ad55eed406252eb93
This commit is contained in:
@@ -25,6 +25,7 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.hardware.display.DisplayTopology
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
@@ -71,6 +72,8 @@ class DisplayTopologyPreferenceTest {
|
||||
override val wallpaper: Bitmap?
|
||||
get() = systemWallpaper!!
|
||||
|
||||
override val densityDpi = DisplayMetrics.DENSITY_DEFAULT
|
||||
|
||||
override fun registerTopologyListener(listener: Consumer<DisplayTopology>) {
|
||||
if (topologyListener != null) {
|
||||
throw IllegalStateException(
|
||||
|
@@ -35,7 +35,7 @@ class TopologyScaleTest {
|
||||
fun oneDisplay4to3Aspect() {
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 640, minPaneHeight = 0f,
|
||||
minEdgeLength = 48, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 48f, maxBlockRatio = 0.05f,
|
||||
listOf(RectF(0f, 0f, 640f, 480f)))
|
||||
|
||||
// blockRatio is higher than 0.05 in order to make the smallest display edge (480 dp) 48dp
|
||||
@@ -52,7 +52,7 @@ class TopologyScaleTest {
|
||||
// The paneHeight and origin coordinates are changed but the block ratio is the same.
|
||||
val taller = TopologyScale(
|
||||
/* paneWidth= */ 640, minPaneHeight = 155.0f,
|
||||
minEdgeLength = 48, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 48f, maxBlockRatio = 0.05f,
|
||||
listOf(RectF(0f, 0f, 640f, 480f)))
|
||||
|
||||
assertEquals(
|
||||
@@ -64,7 +64,7 @@ class TopologyScaleTest {
|
||||
fun twoUnalignedDisplays() {
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 300, minPaneHeight = 0f,
|
||||
minEdgeLength = 48, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 48f, maxBlockRatio = 0.05f,
|
||||
listOf(RectF(0f, 0f, 1920f, 1200f), RectF(1920f, -300f, 3840f, 900f)))
|
||||
|
||||
assertEquals(
|
||||
@@ -80,7 +80,7 @@ class TopologyScaleTest {
|
||||
fun twoDisplaysBlockRatioBumpedForGarSizeMinimumHorizontal() {
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 192, minPaneHeight = 0f,
|
||||
minEdgeLength = 48, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 48f, maxBlockRatio = 0.05f,
|
||||
listOf(RectF(0f, 0f, 240f, 320f), RectF(-240f, -320f, 0f, 0f)))
|
||||
|
||||
// blockRatio is higher than 0.05 in order to make the smallest display edge (240 dp) 48dp
|
||||
@@ -98,7 +98,7 @@ class TopologyScaleTest {
|
||||
fun paneVerticalPaddingLimitedByTallestDisplay() {
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 300, minPaneHeight = 0f,
|
||||
minEdgeLength = 48, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 48f, maxBlockRatio = 0.05f,
|
||||
listOf(
|
||||
RectF(0f, 0f, 640f, 480f),
|
||||
RectF(0f, 480f, 640f, 960f),
|
||||
@@ -118,7 +118,7 @@ class TopologyScaleTest {
|
||||
fun limitedByCustomMaxBlockRatio() {
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 300, minPaneHeight = 0f,
|
||||
minEdgeLength = 24, maxBlockRatio = 0.12f,
|
||||
minEdgeLength = 24f, maxBlockRatio = 0.12f,
|
||||
listOf(
|
||||
RectF(0f, 0f, 640f, 480f),
|
||||
RectF(0f, 480f, 640f, 960f)))
|
||||
@@ -135,7 +135,7 @@ class TopologyScaleTest {
|
||||
// minBlockEdgeLength/minDisplayEdgeLength = 80/480 = 1/6, so the block ratio will be 1/6
|
||||
val scale = TopologyScale(
|
||||
/* paneWidth= */ 300, minPaneHeight = 0f,
|
||||
minEdgeLength = 80, maxBlockRatio = 0.05f,
|
||||
minEdgeLength = 80f, maxBlockRatio = 0.05f,
|
||||
listOf(
|
||||
RectF(0f, 0f, 640f, 480f),
|
||||
RectF(0f, 480f, 640f, 960f)))
|
||||
|
Reference in New Issue
Block a user