summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-04-24 11:09:12 -0400
committerMike Reed <reed@google.com>2009-04-24 17:20:29 -0400
commitc70e06bbfac0d92ec218a32e35d9d7fa80f23cc9 (patch)
tree3a758b6a05e7b60dec8c16c42d246e1e991a3854 /graphics
parent44ff0514c2c8b8917ef81182c8f9d84a1617ec57 (diff)
downloadframeworks_base-c70e06bbfac0d92ec218a32e35d9d7fa80f23cc9.zip
frameworks_base-c70e06bbfac0d92ec218a32e35d9d7fa80f23cc9.tar.gz
frameworks_base-c70e06bbfac0d92ec218a32e35d9d7fa80f23cc9.tar.bz2
Add (hidden for now) purgeable bitmaps
BitmapFactory::Options now let you specify if the resulting bitmap can be "purgeable". If so, then its decoded pixels may be purged when not actively being drawn, freeing up that RAM. When such a bitmap is drawn, it will automatically be re-decoded on demand. This is done by having the bitmap keep a reference/copy of the encoded data. Where it is a reference or a copy is controlled by the "shareable" flag in Options. If this is true, the implementation *may* just reference the encode data (e.g. a file descriptor) rathern than making a complete copy of it. Currently, purgeable is not supported for generic inputstreams, but is enabled for byte-array, file-descriptor, and assets, though for impl reasons only file-descripts are currently enabled for "shareable", but that may change in the future.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/BitmapFactory.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 3813d8f..9e88d7e 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -103,6 +103,36 @@ public class BitmapFactory {
public boolean inScaled;
/**
+ * If this is set to true, then the resulting bitmap will allocate its
+ * pixels such that they can be purged if the system needs to reclaim
+ * memory. In that instance, when the pixels need to be accessed again
+ * (e.g. the bitmap is drawn, getPixels() is called), they will be
+ * automatically re-decoded.
+ *
+ * For the re-decode to happen, the bitmap must have access to the
+ * encoded data, either by sharing a reference to the input
+ * or by making a copy of it. This distinction is controlled by
+ * inInputShareable. If this is true, then the bitmap may keep a shallow
+ * reference to the input. If this is false, then the bitmap will
+ * explicitly make a copy of the input data, and keep that. Even if
+ * sharing is allowed, the implementation may still decide to make a
+ * deep copy of the input data.
+ *
+ * @hide pending API council approval
+ */
+ public boolean inPurgeable;
+
+ /**
+ * This field works in conjuction with inPurgeable. If inPurgeable is
+ * false, then this field is ignored. If inPurgeable is true, then this
+ * field determines whether the bitmap can share a reference to the
+ * input data (inputstream, array, etc.) or if it must make a deep copy.
+ *
+ * @hide pending API council approval
+ */
+ public boolean inInputShareable;
+
+ /**
* The resulting width of the bitmap, set independent of the state of
* inJustDecodeBounds. However, if there is an error trying to decode,
* outWidth will be set to -1.