am 2dafe771: Merge "DO NOT MERGE. Fix density compat mode." into honeycomb-mr2
* commit '2dafe771bb7ad4b15db6b740fd3ccb8f0fae836d': DO NOT MERGE. Fix density compat mode.
This commit is contained in:
@@ -432,17 +432,17 @@ public class CompatibilityInfo implements Parcelable {
|
||||
// compatible with large screens, so diddle it.
|
||||
CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm);
|
||||
} else {
|
||||
inoutDm.widthPixels = inoutDm.unscaledWidthPixels;
|
||||
inoutDm.heightPixels = inoutDm.unscaledHeightPixels;
|
||||
inoutDm.widthPixels = inoutDm.noncompatWidthPixels;
|
||||
inoutDm.heightPixels = inoutDm.noncompatHeightPixels;
|
||||
}
|
||||
|
||||
if (isScalingRequired()) {
|
||||
float invertedRatio = applicationInvertedScale;
|
||||
inoutDm.density *= invertedRatio;
|
||||
inoutDm.density = inoutDm.noncompatDensity * invertedRatio;
|
||||
inoutDm.densityDpi = (int)((inoutDm.density*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
||||
inoutDm.scaledDensity *= invertedRatio;
|
||||
inoutDm.xdpi *= invertedRatio;
|
||||
inoutDm.ydpi *= invertedRatio;
|
||||
inoutDm.scaledDensity = inoutDm.noncompatScaledDensity * invertedRatio;
|
||||
inoutDm.xdpi = inoutDm.noncompatXdpi * invertedRatio;
|
||||
inoutDm.ydpi = inoutDm.noncompatYdpi * invertedRatio;
|
||||
inoutDm.widthPixels = (int) (inoutDm.widthPixels * invertedRatio + 0.5f);
|
||||
inoutDm.heightPixels = (int) (inoutDm.heightPixels * invertedRatio + 0.5f);
|
||||
}
|
||||
@@ -471,8 +471,8 @@ public class CompatibilityInfo implements Parcelable {
|
||||
* @return Returns the scaling factor for the window.
|
||||
*/
|
||||
public static float computeCompatibleScaling(DisplayMetrics dm, DisplayMetrics outDm) {
|
||||
final int width = dm.unscaledWidthPixels;
|
||||
final int height = dm.unscaledHeightPixels;
|
||||
final int width = dm.noncompatWidthPixels;
|
||||
final int height = dm.noncompatHeightPixels;
|
||||
int shortSize, longSize;
|
||||
if (width < height) {
|
||||
shortSize = width;
|
||||
@@ -532,7 +532,9 @@ public class CompatibilityInfo implements Parcelable {
|
||||
sb.append(applicationDensity);
|
||||
sb.append("dpi");
|
||||
if (isScalingRequired()) {
|
||||
sb.append(" scaling");
|
||||
sb.append(" ");
|
||||
sb.append(applicationScale);
|
||||
sb.append("x");
|
||||
}
|
||||
if (!supportsScreen()) {
|
||||
sb.append(" resizing");
|
||||
|
||||
@@ -1416,23 +1416,19 @@ public class Resources {
|
||||
}
|
||||
if (metrics != null) {
|
||||
mMetrics.setTo(metrics);
|
||||
// NOTE: We should re-arrange this code to create a Display
|
||||
// with the CompatibilityInfo that is used everywhere we deal
|
||||
// with the display in relation to this app, rather than
|
||||
// doing the conversion here. This impl should be okay because
|
||||
// we make sure to return a compatible display in the places
|
||||
// where there are public APIs to retrieve the display... but
|
||||
// it would be cleaner and more maintainble to just be
|
||||
// consistently dealing with a compatible display everywhere in
|
||||
// the framework.
|
||||
if (mCompatibilityInfo != null) {
|
||||
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
||||
}
|
||||
}
|
||||
// NOTE: We should re-arrange this code to create a Display
|
||||
// with the CompatibilityInfo that is used everywhere we deal
|
||||
// with the display in relation to this app, rather than
|
||||
// doing the conversion here. This impl should be okay because
|
||||
// we make sure to return a compatible display in the places
|
||||
// where there are public APIs to retrieve the display... but
|
||||
// it would be cleaner and more maintainble to just be
|
||||
// consistently dealing with a compatible display everywhere in
|
||||
// the framework.
|
||||
if (mCompatibilityInfo != null) {
|
||||
mCompatibilityInfo.applyToDisplayMetrics(mMetrics);
|
||||
}
|
||||
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
||||
int configChanges = 0xfffffff;
|
||||
if (config != null) {
|
||||
mTmpConfig.setTo(config);
|
||||
@@ -1448,6 +1444,7 @@ public class Resources {
|
||||
if (mConfiguration.locale == null) {
|
||||
mConfiguration.locale = Locale.getDefault();
|
||||
}
|
||||
mMetrics.scaledDensity = mMetrics.density * mConfiguration.fontScale;
|
||||
|
||||
String locale = null;
|
||||
if (mConfiguration.locale != null) {
|
||||
|
||||
@@ -119,13 +119,37 @@ public class DisplayMetrics {
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public int unscaledWidthPixels;
|
||||
public int noncompatWidthPixels;
|
||||
/**
|
||||
* The reported display height prior to any compatibility mode scaling
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public int unscaledHeightPixels;
|
||||
public int noncompatHeightPixels;
|
||||
/**
|
||||
* The reported display density prior to any compatibility mode scaling
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public float noncompatDensity;
|
||||
/**
|
||||
* The reported scaled density prior to any compatibility mode scaling
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public float noncompatScaledDensity;
|
||||
/**
|
||||
* The reported display xdpi prior to any compatibility mode scaling
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public float noncompatXdpi;
|
||||
/**
|
||||
* The reported display ydpi prior to any compatibility mode scaling
|
||||
* being applied.
|
||||
* @hide
|
||||
*/
|
||||
public float noncompatYdpi;
|
||||
|
||||
public DisplayMetrics() {
|
||||
}
|
||||
@@ -138,8 +162,12 @@ public class DisplayMetrics {
|
||||
scaledDensity = o.scaledDensity;
|
||||
xdpi = o.xdpi;
|
||||
ydpi = o.ydpi;
|
||||
unscaledWidthPixels = o.unscaledWidthPixels;
|
||||
unscaledHeightPixels = o.unscaledHeightPixels;
|
||||
noncompatWidthPixels = o.noncompatWidthPixels;
|
||||
noncompatHeightPixels = o.noncompatHeightPixels;
|
||||
noncompatDensity = o.noncompatDensity;
|
||||
noncompatScaledDensity = o.noncompatScaledDensity;
|
||||
noncompatXdpi = o.noncompatXdpi;
|
||||
noncompatYdpi = o.noncompatYdpi;
|
||||
}
|
||||
|
||||
public void setToDefaults() {
|
||||
@@ -150,8 +178,8 @@ public class DisplayMetrics {
|
||||
scaledDensity = density;
|
||||
xdpi = DENSITY_DEVICE;
|
||||
ydpi = DENSITY_DEVICE;
|
||||
unscaledWidthPixels = 0;
|
||||
unscaledHeightPixels = 0;
|
||||
noncompatWidthPixels = 0;
|
||||
noncompatHeightPixels = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,8 +107,8 @@ public class Display {
|
||||
CompatibilityInfo ci;
|
||||
if (doCompat && (ci=mCompatibilityInfo.getIfNeeded()) != null) {
|
||||
synchronized (mTmpMetrics) {
|
||||
mTmpMetrics.unscaledWidthPixels = outSize.x;
|
||||
mTmpMetrics.unscaledHeightPixels = outSize.y;
|
||||
mTmpMetrics.noncompatWidthPixels = outSize.x;
|
||||
mTmpMetrics.noncompatHeightPixels = outSize.y;
|
||||
mTmpMetrics.density = mDensity;
|
||||
ci.applyToDisplayMetrics(mTmpMetrics);
|
||||
outSize.x = mTmpMetrics.widthPixels;
|
||||
@@ -268,14 +268,15 @@ public class Display {
|
||||
}
|
||||
|
||||
private void getNonSizeMetrics(DisplayMetrics outMetrics) {
|
||||
outMetrics.density = mDensity;
|
||||
outMetrics.densityDpi = (int)((mDensity*DisplayMetrics.DENSITY_DEFAULT)+.5f);
|
||||
outMetrics.scaledDensity= outMetrics.density;
|
||||
outMetrics.xdpi = mDpiX;
|
||||
outMetrics.ydpi = mDpiY;
|
||||
|
||||
outMetrics.unscaledWidthPixels = outMetrics.widthPixels;
|
||||
outMetrics.unscaledHeightPixels = outMetrics.heightPixels;
|
||||
outMetrics.noncompatWidthPixels = outMetrics.widthPixels;
|
||||
outMetrics.noncompatHeightPixels = outMetrics.heightPixels;
|
||||
|
||||
outMetrics.density = outMetrics.noncompatDensity = mDensity;
|
||||
outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density;
|
||||
outMetrics.xdpi = outMetrics.noncompatXdpi = mDpiX;
|
||||
outMetrics.ydpi = outMetrics.noncompatYdpi = mDpiY;
|
||||
}
|
||||
|
||||
static IWindowManager getWindowManager() {
|
||||
|
||||
@@ -5552,10 +5552,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
private int reduceCompatConfigWidthSize(int curSize, int rotation, DisplayMetrics dm,
|
||||
int dw, int dh) {
|
||||
dm.unscaledWidthPixels = mPolicy.getNonDecorDisplayWidth(rotation, dw);
|
||||
dm.unscaledHeightPixels = mPolicy.getNonDecorDisplayHeight(rotation, dh);
|
||||
dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(rotation, dw);
|
||||
dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(rotation, dh);
|
||||
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
|
||||
int size = (int)(((dm.unscaledWidthPixels / scale) / dm.density) + .5f);
|
||||
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
|
||||
if (curSize == 0 || size < curSize) {
|
||||
curSize = size;
|
||||
}
|
||||
@@ -5630,9 +5630,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
// Override display width and height with what we are computing,
|
||||
// to be sure they remain consistent.
|
||||
dm.widthPixels = dm.unscaledWidthPixels = mAppDisplayWidth
|
||||
dm.widthPixels = dm.noncompatWidthPixels = mAppDisplayWidth
|
||||
= mPolicy.getNonDecorDisplayWidth(mRotation, dw);
|
||||
dm.heightPixels = dm.unscaledHeightPixels = mAppDisplayHeight
|
||||
dm.heightPixels = dm.noncompatHeightPixels = mAppDisplayHeight
|
||||
= mPolicy.getNonDecorDisplayHeight(mRotation, dh);
|
||||
|
||||
mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm,
|
||||
|
||||
Reference in New Issue
Block a user