summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-02-08 11:19:11 -0800
committerRomain Guy <romainguy@google.com>2012-02-08 11:19:11 -0800
commit4e525a6e5ac7499f79f306e0a418f6f6b72c765d (patch)
tree3e1281d50c083183b1954291574f96220bb4c7c3 /graphics/java
parente1a409ba68087c66238c986b270c17932e39f0ba (diff)
downloadframeworks_base-4e525a6e5ac7499f79f306e0a418f6f6b72c765d.zip
frameworks_base-4e525a6e5ac7499f79f306e0a418f6f6b72c765d.tar.gz
frameworks_base-4e525a6e5ac7499f79f306e0a418f6f6b72c765d.tar.bz2
Tentative fix for mysteriously recycled bitmap
This code should not be triggered with scale == 1.0f because of the density comparisons above though. Change-Id: I9e39e3769a3b6550c97df3b213457947ec1f554b
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/BitmapFactory.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 8d17561..bff2a76 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -518,15 +518,16 @@ public class BitmapFactory {
byte[] np = bm.getNinePatchChunk();
final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
if (opts.inScaled || isNinePatch) {
- float scale = targetDensity / (float)density;
- // TODO: This is very inefficient and should be done in native by Skia
- final Bitmap oldBitmap = bm;
- bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
- (int) (bm.getHeight() * scale + 0.5f), true);
- oldBitmap.recycle();
+ float scale = targetDensity / (float) density;
+ if (scale != 1.0f) {
+ final Bitmap oldBitmap = bm;
+ bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
+ (int) (bm.getHeight() * scale + 0.5f), true);
+ if (bm != oldBitmap) oldBitmap.recycle();
+ }
if (isNinePatch) {
- np = nativeScaleNinePatch(np, scale, outPadding);
+ if (scale != 1.0f) np = nativeScaleNinePatch(np, scale, outPadding);
bm.setNinePatchChunk(np);
}
bm.setDensity(targetDensity);