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
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user