summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-05-21 06:22:24 -0700
committerSteve Kondik <steve@cyngn.com>2015-10-27 15:11:36 -0700
commit617275f6af2398761f32f2ec09ef9946d990cfdb (patch)
tree022bf557148cda26d7d8a7bca59e319c2fcf959f /graphics/java
parent173a4d8ab994d5d0c1015887a077bd13f605f97f (diff)
downloadframeworks_base-617275f6af2398761f32f2ec09ef9946d990cfdb.zip
frameworks_base-617275f6af2398761f32f2ec09ef9946d990cfdb.tar.gz
frameworks_base-617275f6af2398761f32f2ec09ef9946d990cfdb.tar.bz2
unbreak density scaling
- Only apply density scaling to built in screens so we don't affect overlays. - Only apply density scaling for activities which fall under the 'default' compatibility bucket. Some apps may have different compatibility info setup (e.g. scaling) and we do not need to apply the user density to this activity. Change-Id: I0b4849141cf081694aae5668ae60764e70be7db1 Signed-off-by: Roman Birg <roman@cyngn.com> Density scaling: scale compatibility apps, wm command support Density scaling should work across all apps and different density configurations. It should also pass CTS. - force compatibility density if calculated compatibility density is different than what the user has requested - hook in "wm density" support, should behave the same as setting the density from Settings - clean up some logic Change-Id: I52c7c2ca200b78f9a5ee9170871ca62e1cab3bcb Signed-off-by: Roman Birg <roman@cyngn.com> Fix typo in density assignment. Change-Id: I35b3860a4991ebaee70c91f3878d63b8f28d7fce Density scaling: return device's default density When an application requests the Display's display metrics, always override the returned densityDpi to be the device's original density to ensure compatibility. Change-Id: I465d53bc189d4596aba0269f124ddc9d0d8097da Signed-off-by: Roman Birg <roman@cyngn.com> return default density only for primary display Change-Id: I70b35a7f4ba77d7c5744fdcb6c19ef78de3dcb15 Signed-off-by: Roman Birg <roman@cyngn.com> density: do not apply to virtual displays Check the incoming configuration density to ensure that it is the same as the device's default density before forcing preferred values. Only apply display metrics if the display is not a presentation. Ref: CYNGNOS-338 Change-Id: I437ac8cf45f1a6c568707e0733364b2495791d8a Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Bitmap.java11
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java2
2 files changed, 10 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 3279185..ba2a890 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -80,18 +80,25 @@ public final class Bitmap implements Parcelable {
private static volatile Matrix sScaleMatrix;
+ private static volatile int sDefaultDensity = -1;
+
/**
* For backwards compatibility, allows the app layer to change the default
* density when running old apps.
* @hide
*/
public static void setDefaultDensity(int density) {
- // Ignore
+ sDefaultDensity = density;
}
@SuppressWarnings("deprecation")
static int getDefaultDensity() {
- return DisplayMetrics.getDeviceDensity();
+ if (sDefaultDensity >= 0) {
+ return sDefaultDensity;
+ }
+ //noinspection deprecation
+ sDefaultDensity = DisplayMetrics.DENSITY_DEVICE;
+ return sDefaultDensity;
}
/**
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 7bd445f..3f1f76a 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -1076,7 +1076,7 @@ public abstract class Drawable {
// drawn to the screen.
if (opts == null) opts = new BitmapFactory.Options();
opts.inScreenDensity = res != null
- ? res.getDisplayMetrics().noncompatDensityDpi : DisplayMetrics.getDeviceDensity();
+ ? res.getDisplayMetrics().noncompatDensityDpi : DisplayMetrics.DENSITY_DEFAULT;
Bitmap bm = BitmapFactory.decodeResourceStream(res, value, is, pad, opts);
if (bm != null) {
byte[] np = bm.getNinePatchChunk();