OSDN Git Service

Remove the use of native allocation.
authorChih-Chung Chang <chihchung@google.com>
Thu, 11 Feb 2010 22:05:50 +0000 (14:05 -0800)
committerChih-Chung Chang <chihchung@google.com>
Fri, 12 Feb 2010 17:20:46 +0000 (09:20 -0800)
src/com/android/camera/ImageGetter.java
src/com/android/camera/Util.java
src/com/android/camera/gallery/BaseImage.java
src/com/android/camera/gallery/IImage.java
src/com/android/camera/gallery/UriImage.java
src/com/android/camera/gallery/VideoObject.java

index 76b60bf..24c9d98 100644 (file)
@@ -201,7 +201,7 @@ class ImageGetter {
                     int sizeToUse = mCB.fullImageSizeToUse(
                             mCurrentPosition, offset);
                     Bitmap b = image.fullSizeBitmap(sizeToUse, 3 * 1024 * 1024,
-                            IImage.NO_ROTATE, IImage.USE_NATIVE);
+                            IImage.NO_ROTATE);
 
                     if (b == null) continue;
                     if (mCancel) {
index 362914a..df014cd 100644 (file)
@@ -171,16 +171,12 @@ public class Util {
      * @param uri
      */
     public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels,
-            Uri uri, ContentResolver cr, boolean useNative) {
+            Uri uri, ContentResolver cr) {
         ParcelFileDescriptor input = null;
         try {
             input = cr.openFileDescriptor(uri, "r");
-            BitmapFactory.Options options = null;
-            if (useNative) {
-                options = createNativeAllocOptions();
-            }
             return makeBitmap(minSideLength, maxNumOfPixels, uri, cr, input,
-                    options);
+                    null);
         } catch (IOException ex) {
             return null;
         } finally {
@@ -189,13 +185,9 @@ public class Util {
     }
 
     public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels,
-            ParcelFileDescriptor pfd, boolean useNative) {
-        BitmapFactory.Options options = null;
-        if (useNative) {
-            options = createNativeAllocOptions();
-        }
+            ParcelFileDescriptor pfd) {
         return makeBitmap(minSideLength, maxNumOfPixels, null, null, pfd,
-                options);
+                null);
     }
 
     public static Bitmap makeBitmap(int minSideLength, int maxNumOfPixels,
@@ -281,13 +273,6 @@ public class Util {
         return intent;
     }
 
-    // Returns Options that set the puregeable flag for Bitmap decode.
-    public static BitmapFactory.Options createNativeAllocOptions() {
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inNativeAlloc = true;
-        return options;
-    }
-
     public static void showFatalErrorAndFinish(
             final Activity activity, String title, String message) {
         DialogInterface.OnClickListener buttonListener =
index b0eab7a..bbd45f1 100644 (file)
@@ -86,16 +86,16 @@ public abstract class BaseImage implements IImage {
 
     public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels) {
         return fullSizeBitmap(minSideLength, maxNumberOfPixels,
-                IImage.ROTATE_AS_NEEDED, IImage.NO_NATIVE);
+                IImage.ROTATE_AS_NEEDED);
     }
 
     public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels,
-            boolean rotateAsNeeded, boolean useNative) {
+            boolean rotateAsNeeded) {
         Uri url = mContainer.contentUri(mId);
         if (url == null) return null;
 
         Bitmap b = Util.makeBitmap(minSideLength, maxNumberOfPixels,
-                url, mContentResolver, useNative);
+                url, mContentResolver);
 
         if (b != null && rotateAsNeeded) {
             b = Util.rotate(b, getDegreesRotated());
index 22e1228..4b72de6 100644 (file)
@@ -38,12 +38,10 @@ public interface IImage {
     public abstract Bitmap fullSizeBitmap(int minSideLength,
             int maxNumberOfPixels);
     public abstract Bitmap fullSizeBitmap(int minSideLength,
-            int maxNumberOfPixels, boolean rotateAsNeeded, boolean useNative);
+            int maxNumberOfPixels, boolean rotateAsNeeded);
     public abstract int getDegreesRotated();
     public static final boolean ROTATE_AS_NEEDED = true;
     public static final boolean NO_ROTATE = false;
-    public static final boolean USE_NATIVE = true;
-    public static final boolean NO_NATIVE = false;
 
     /** Get the input stream associated with a given full size image. */
     public abstract InputStream fullSizeImageData();
index 1d04257..a229f76 100644 (file)
@@ -78,21 +78,15 @@ class UriImage implements IImage {
 
     public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels) {
         return fullSizeBitmap(minSideLength, maxNumberOfPixels,
-                IImage.ROTATE_AS_NEEDED, IImage.NO_NATIVE);
+                IImage.ROTATE_AS_NEEDED);
     }
 
     public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels,
             boolean rotateAsNeeded) {
-        return fullSizeBitmap(minSideLength, maxNumberOfPixels,
-                rotateAsNeeded, IImage.NO_NATIVE);
-    }
-
-    public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels,
-            boolean rotateAsNeeded, boolean useNative) {
         try {
             ParcelFileDescriptor pfdInput = getPFD();
             Bitmap b = Util.makeBitmap(minSideLength, maxNumberOfPixels,
-                    pfdInput, useNative);
+                    pfdInput);
             return b;
         } catch (Exception ex) {
             Log.e(TAG, "got exception decoding bitmap ", ex);
index fd759b8..0a72209 100644 (file)
@@ -62,7 +62,7 @@ public class VideoObject extends BaseImage implements IImage {
 
     @Override
     public Bitmap fullSizeBitmap(int minSideLength, int maxNumberOfPixels,
-            boolean rotateAsNeeded, boolean useNative) {
+            boolean rotateAsNeeded) {
         return ThumbnailUtils.createVideoThumbnail(mDataPath);
     }