From 7341d7a104b47996445d069a695e155a07184606 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 14 Aug 2009 11:37:52 -0700 Subject: More work on wallpapers. - Do better about figuring out when to stop them and other related window management. - Fix problem where we were not redrawing the surface when the orientation changed. This was the cause of the device hang. --- graphics/java/android/graphics/BitmapFactory.java | 16 +++++++++++----- graphics/java/android/graphics/drawable/Drawable.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index 076cd0c..2abb777 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -73,7 +73,7 @@ public class BitmapFactory { public Bitmap.Config inPreferredConfig; /** - * If dither is true, the decoder will atttempt to dither the decoded + * If dither is true, the decoder will attempt to dither the decoded * image. */ public boolean inDither; @@ -452,6 +452,10 @@ public class BitmapFactory { bm = nativeDecodeStream(is, tempStorage, outPadding, opts); } + return finishDecode(bm, outPadding, opts); + } + + private static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) { if (bm == null || opts == null) { return bm; } @@ -487,7 +491,7 @@ public class BitmapFactory { return bm; } - + /** * Decode an input stream into a bitmap. If the input stream is null, or * cannot be used to decode a bitmap, the function returns null. @@ -507,7 +511,7 @@ public class BitmapFactory { /** * Decode a bitmap from the file descriptor. If the bitmap cannot be decoded * return null. The position within the descriptor will not be changed when - * this returns, so the descriptor can be used again as is. + * this returns, so the descriptor can be used again as-is. * * @param fd The file descriptor containing the bitmap data to decode * @param outPadding If not null, return the padding rect for the bitmap if @@ -524,13 +528,15 @@ public class BitmapFactory { int mappedlength = MemoryFile.getMappedSize(fd); MemoryFile file = new MemoryFile(fd, mappedlength, "r"); InputStream is = file.getInputStream(); - return decodeStream(is, outPadding, opts); + Bitmap bm = decodeStream(is, outPadding, opts); + return finishDecode(bm, outPadding, opts); } } catch (IOException ex) { // invalid filedescriptor, no need to call nativeDecodeFileDescriptor() return null; } - return nativeDecodeFileDescriptor(fd, outPadding, opts); + Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts); + return finishDecode(bm, outPadding, opts); } /** diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index 193f399..33748ae 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -663,6 +663,15 @@ public abstract class Drawable { */ public static Drawable createFromResourceStream(Resources res, TypedValue value, InputStream is, String srcName) { + return createFromResourceStream(res, value, is, srcName); + } + + /** + * Create a drawable from an inputstream, using the given resources and + * value to determine density information. + */ + public static Drawable createFromResourceStream(Resources res, TypedValue value, + InputStream is, String srcName, BitmapFactory.Options opts) { if (is == null) { return null; @@ -683,7 +692,7 @@ public abstract class Drawable { // an application in compatibility mode, without scaling those down // to the compatibility density only to have them scaled back up when // drawn to the screen. - BitmapFactory.Options opts = new BitmapFactory.Options(); + if (opts == null) opts = new BitmapFactory.Options(); opts.inScreenDensity = DisplayMetrics.DENSITY_DEVICE; Bitmap bm = BitmapFactory.decodeResourceStream(res, value, is, pad, opts); if (bm != null) { -- cgit v1.1