diff options
| author | Dianne Hackborn <hackbod@google.com> | 2012-08-03 14:01:57 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2012-08-03 17:27:29 -0700 |
| commit | dde331cebd87982faded6818ad5f9927ff994c96 (patch) | |
| tree | c2f9c4c62113fc93948d3988fc09cc3727c4b9ca /core/java/android/view | |
| parent | 5345c310af8363948cee6a91d11add3ec51e8a9c (diff) | |
We can now (kind-of) change screen density on the fly.
Preloaded drawables now have a density associated with them, so we
can load the correct drawable if we are using a different density.
Window manager now formally keeps track of the density for each
screen, allowing it to be overridden like you can already do with
size, and relies on this density to drive itself internally and
the configurations it reports.
There are a new set of Bitmap constructors where you provide a
DisplayMetrics so they can be constructed with the correct density.
(This will be for when you can have different windows in the same
app running at different densities.)
ActivityThread now watches for density changes, and pushes them
to the DENSITY_DEVICE and Bitmap global density values for that
process.
A new am command allows you to change the density.
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/Display.java | 1 | ||||
| -rw-r--r-- | core/java/android/view/IWindowManager.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/view/TextureView.java | 3 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/ViewDebug.java | 5 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 2 |
6 files changed, 12 insertions, 7 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index c59f1bff9fba..2b0c14df21f2 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -16,7 +16,6 @@ package android.view; -import android.content.res.CompatibilityInfo; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index f58cd836f9f3..5bccdd4b34be 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -59,6 +59,8 @@ interface IWindowManager void setForcedDisplaySize(int displayId, int longDimen, int shortDimen); void clearForcedDisplaySize(int displayId); + void setForcedDisplayDensity(int displayId, int density); + void clearForcedDisplayDensity(int displayId); // Is the device configured to have a full system bar for larger screens? boolean hasSystemNavBar(); diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index a719a0159c18..fe14c88cfe9c 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -534,7 +534,8 @@ public class TextureView extends View { */ public Bitmap getBitmap(int width, int height) { if (isAvailable() && width > 0 && height > 0) { - return getBitmap(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)); + return getBitmap(Bitmap.createBitmap(getResources().getDisplayMetrics(), + width, height, Bitmap.Config.ARGB_8888)); } return null; } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 50c34076a267..cd35002d3a1d 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -12402,7 +12402,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (bitmap != null) bitmap.recycle(); try { - bitmap = Bitmap.createBitmap(width, height, quality); + bitmap = Bitmap.createBitmap(mResources.getDisplayMetrics(), + width, height, quality); bitmap.setDensity(getResources().getDisplayMetrics().densityDpi); if (autoScale) { mDrawingCache = bitmap; @@ -12494,7 +12495,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, width = (int) ((width * scale) + 0.5f); height = (int) ((height * scale) + 0.5f); - Bitmap bitmap = Bitmap.createBitmap(width > 0 ? width : 1, height > 0 ? height : 1, quality); + Bitmap bitmap = Bitmap.createBitmap(mResources.getDisplayMetrics(), + width > 0 ? width : 1, height > 0 ? height : 1, quality); if (bitmap == null) { throw new OutOfMemoryError(); } diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index 00d4fc76a219..dae9265ab1fb 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -546,7 +546,7 @@ public class ViewDebug { (view != null && view.getResources() != null) ? view.getResources().getDisplayMetrics() : null; final Bitmap bitmap = metrics != null ? - Bitmap.createBitmap(metrics.widthPixels, + Bitmap.createBitmap(metrics, metrics.widthPixels, metrics.heightPixels, Bitmap.Config.RGB_565) : null; final Canvas canvas = bitmap != null ? new Canvas(bitmap) : null; return new Object[] { @@ -706,7 +706,8 @@ public class ViewDebug { Log.w("View", "Failed to create capture bitmap!"); // Send an empty one so that it doesn't get stuck waiting for // something. - b = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); + b = Bitmap.createBitmap(root.getResources().getDisplayMetrics(), + 1, 1, Bitmap.Config.ARGB_8888); } BufferedOutputStream out = null; diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 9522a1bd5642..407bae5da2cf 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -483,7 +483,7 @@ public interface WindowManagerPolicy { * Called by window manager once it has the initial, default native * display dimensions. */ - public void setInitialDisplaySize(Display display, int width, int height); + public void setInitialDisplaySize(Display display, int width, int height, int density); /** * Check permissions when adding a window. |
