Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65614324 authored by Alan Viverette's avatar Alan Viverette
Browse files

Round display scaling densities down to the nearest 2 DPI

This will prevent scaling artifacts due to odd densities. We will not
make any adjustments to the "normal" density, which will preserve
tvdpi or whatever the device manufacturer needed to use.

Rounding the density down is always safe, since it will not push us
below our 320dp lower bound on minimum effective screen dimension.

Bug: 27225670
Change-Id: Ib084bb3d4fc70a59106ac74df5394c21e9f8c7bd
parent adcec744
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -116,7 +116,8 @@ class DisplayDensityUtils {
        if (numSmaller > 0) {
            final float interval = (1 - minScale) / numSmaller;
            for (int i = numSmaller - 1; i >= 0; i--) {
                final int density = (int) (normalDensity * (1 - (i + 1) * interval));
                // Round down to a multiple of 2 by truncating the low bit.
                final int density = ((int) (normalDensity * (1 - (i + 1) * interval))) & ~1;
                if (currentDensity == density) {
                    currentDensityIndex = curIndex;
                }
@@ -136,7 +137,8 @@ class DisplayDensityUtils {
        if (numLarger > 0) {
            final float interval = (maxScale - 1) / numLarger;
            for (int i = 0; i < numLarger; i++) {
                final int density = (int) (normalDensity * (1 + (i + 1) * interval));
                // Round down to a multiple of 2 by truncating the low bit.
                final int density = ((int) (normalDensity * (1 + (i + 1) * interval))) & ~1;
                if (currentDensity == density) {
                    currentDensityIndex = curIndex;
                }