Round display scaling densities down to the nearest 2 DPI am: 656143240c

am: 86307ffd09

* commit '86307ffd09fb586c7a65c7bd26fe813803246937':
  Round display scaling densities down to the nearest 2 DPI
This commit is contained in:
Alan Viverette
2016-02-18 21:11:32 +00:00
committed by android-build-merger

View File

@@ -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;
}