summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-09-10 14:32:16 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-11 13:31:45 -0700
commit8cae124af2142687a6833dbaab8a43df6dd67b43 (patch)
tree662ea14668e4b07cb2336d62fdb0241713182480 /core/java/android
parent7ff269f359a8848fd0c39993d8fe21a8324806f9 (diff)
Various cleanup around resources and nine-patches.
Remove the stuff that doesn't use preloaded drawables when in compatibility mode, since this works fine ever since we were able to deal with drawables in a different density than the canvas. Change the snapshot function on View to return a snapshot at the same size that will actually be drawn on screen (when in compatibility mode), to be able to show scaling artifacts and all. This change was original an attempt to fix issue #2101917: Text field edges appears to be improperly rounded. That turns out to probably be something deeper in the graphics system, but also included here is the debugging code I did to try to track down the problem to make it easy to turn on again later. Change-Id: I34bfca629639c7ff103f3989d88874112ef778d9
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/res/AssetManager.java1
-rw-r--r--core/java/android/content/res/Resources.java10
-rw-r--r--core/java/android/view/View.java16
3 files changed, 13 insertions, 14 deletions
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index 0bc8a9d2e482..0d43b2a83c72 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -24,7 +24,6 @@ import android.util.TypedValue;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Locale;
/**
* Provides access to an application's raw asset files; see {@link Resources}
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 7d412a7b5554..ba5c9ed18a43 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -66,8 +66,6 @@ public class Resources {
= new SparseArray<ColorStateList>();
private static boolean mPreloaded;
- private final LongSparseArray<Drawable.ConstantState> mPreloadedDrawables;
-
/*package*/ final TypedValue mTmpValue = new TypedValue();
// These are protected by the mTmpValue lock.
@@ -158,11 +156,6 @@ public class Resources {
}
updateConfiguration(config, metrics);
assets.ensureStringBlocks();
- if (mCompatibilityInfo.isScalingRequired()) {
- mPreloadedDrawables = emptySparseArray();
- } else {
- mPreloadedDrawables = sPreloadedDrawables;
- }
}
/**
@@ -1669,7 +1662,7 @@ public class Resources {
return dr;
}
- Drawable.ConstantState cs = mPreloadedDrawables.get(key);
+ Drawable.ConstantState cs = sPreloadedDrawables.get(key);
if (cs != null) {
dr = cs.newDrawable();
} else {
@@ -1976,7 +1969,6 @@ public class Resources {
mMetrics.setToDefaults();
updateConfiguration(null, null);
mAssets.ensureStringBlocks();
- mPreloadedDrawables = sPreloadedDrawables;
mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
}
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 2f17bbc71ced..f63c2f1162e1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6038,16 +6038,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
* some form of this public, but should think about the API.
*/
Bitmap createSnapshot(Bitmap.Config quality, int backgroundColor) {
- final int width = mRight - mLeft;
- final int height = mBottom - mTop;
+ int width = mRight - mLeft;
+ int height = mBottom - mTop;
- Bitmap bitmap = Bitmap.createBitmap(width, height, quality);
+ final AttachInfo attachInfo = mAttachInfo;
+ final float scale = attachInfo.mApplicationScale;
+ 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);
if (bitmap == null) {
throw new OutOfMemoryError();
}
+ bitmap.setDensity(getResources().getDisplayMetrics().densityDpi);
+
Canvas canvas;
- final AttachInfo attachInfo = mAttachInfo;
if (attachInfo != null) {
canvas = attachInfo.mCanvas;
if (canvas == null) {
@@ -6070,6 +6077,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
computeScroll();
final int restoreCount = canvas.save();
+ canvas.scale(scale, scale);
canvas.translate(-mScrollX, -mScrollY);
// Temporarily remove the dirty mask