summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-08-14 11:37:52 -0700
committerDianne Hackborn <hackbod@google.com>2009-08-17 10:42:59 -0700
commit7341d7a104b47996445d069a695e155a07184606 (patch)
tree1be8efee3847179fbb0ed4d556be029ad23f5832 /graphics/java
parent56e7ba2928bce62283a62ad1c9d9f1ec7b54c24c (diff)
downloadframeworks_base-7341d7a104b47996445d069a695e155a07184606.zip
frameworks_base-7341d7a104b47996445d069a695e155a07184606.tar.gz
frameworks_base-7341d7a104b47996445d069a695e155a07184606.tar.bz2
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.
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/BitmapFactory.java16
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java11
2 files changed, 21 insertions, 6 deletions
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) {