diff options
author | Owen Lin <owenlin@google.com> | 2012-09-04 00:29:11 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-04 00:29:12 -0700 |
commit | f88808169c995219ba9651df8c52161b56d2fedb (patch) | |
tree | a8e0a938ef492b990df8725a277248e6e116df25 /src/com | |
parent | 25d33864d28f6acf25d2e835a85bf04a9a22f57e (diff) | |
parent | d01a96e278ea96ee6ee43b37e60c4d37a8959e95 (diff) | |
download | android_packages_apps_Snap-f88808169c995219ba9651df8c52161b56d2fedb.tar.gz android_packages_apps_Snap-f88808169c995219ba9651df8c52161b56d2fedb.tar.bz2 android_packages_apps_Snap-f88808169c995219ba9651df8c52161b56d2fedb.zip |
Merge "Set inMutable to true if we may reuse the bitmap." into gb-ub-photos-arches
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/data/DecodeUtils.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java index 773af74bb..4d3c99653 100644 --- a/src/com/android/gallery3d/data/DecodeUtils.java +++ b/src/com/android/gallery3d/data/DecodeUtils.java @@ -25,6 +25,7 @@ import android.graphics.BitmapRegionDecoder; import android.os.Build; import android.util.FloatMath; +import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.common.Utils; import com.android.gallery3d.ui.Log; @@ -51,9 +52,15 @@ public class DecodeUtils { } } + @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) + public static void setOptionsMutable(Options options) { + if (ApiHelper.HAS_OPTIONS_IN_MUTABLE) options.inMutable = true; + } + public static Bitmap decode(JobContext jc, FileDescriptor fd, Options options) { if (options == null) options = new Options(); jc.setCancelListener(new DecodeCanceller(options)); + setOptionsMutable(options); return ensureGLCompatibleBitmap( BitmapFactory.decodeFileDescriptor(fd, null, options)); } @@ -75,6 +82,7 @@ public class DecodeUtils { int length, Options options) { if (options == null) options = new Options(); jc.setCancelListener(new DecodeCanceller(options)); + setOptionsMutable(options); return ensureGLCompatibleBitmap( BitmapFactory.decodeByteArray(bytes, offset, length, options)); } @@ -135,6 +143,7 @@ public class DecodeUtils { } options.inJustDecodeBounds = false; + setOptionsMutable(options); Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options); if (result == null) return null; @@ -170,6 +179,8 @@ public class DecodeUtils { options.inSampleSize = BitmapUtils.computeSampleSizeLarger( options.outWidth, options.outHeight, targetSize); options.inJustDecodeBounds = false; + setOptionsMutable(options); + return ensureGLCompatibleBitmap( BitmapFactory.decodeByteArray(data, 0, data.length, options)); } |