summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2013-08-21 18:57:10 -0700
committerSascha Haeberling <haeberling@google.com>2013-08-21 18:57:10 -0700
commit1259bc49d956887477ad6d789668fb61f572b046 (patch)
tree0d38e759768921f6a2902f41d38033d3cb2effd4
parent15396ca68c47a4ef14e6b23c6cd009d8915f8ea2 (diff)
downloadandroid_packages_apps_Snap-1259bc49d956887477ad6d789668fb61f572b046.tar.gz
android_packages_apps_Snap-1259bc49d956887477ad6d789668fb61f572b046.tar.bz2
android_packages_apps_Snap-1259bc49d956887477ad6d789668fb61f572b046.zip
Speed up filmstrip by not decoding with default 3000px.
Bug: 10330214 Bug: 10430152 We need to tell the wrapped data adapters about the size we need. Also, use a more efficient way to determine the sample size. Change-Id: Ie2c6fb438f06d97d6e5420afdceccccf41040020
-rw-r--r--src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java1
-rw-r--r--src/com/android/camera/data/LocalMediaData.java18
2 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java b/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java
index 5df87f5a8..ef1e4258c 100644
--- a/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java
+++ b/src/com/android/camera/data/AbstractLocalDataAdapterWrapper.java
@@ -51,6 +51,7 @@ public abstract class AbstractLocalDataAdapterWrapper implements LocalDataAdapte
public void suggestViewSizeBound(int w, int h) {
mSuggestedWidth = w;
mSuggestedHeight = h;
+ mAdapter.suggestViewSizeBound(w, h);
}
@Override
diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java
index f80b4a02f..48db0df4c 100644
--- a/src/com/android/camera/data/LocalMediaData.java
+++ b/src/com/android/camera/data/LocalMediaData.java
@@ -426,20 +426,20 @@ public abstract class LocalMediaData implements LocalData {
@Override
protected Bitmap doInBackground(Void... v) {
- BitmapFactory.Options opts = null;
- Bitmap b;
- int sample = 1;
- while (mDecodeWidth * sample < width
- || mDecodeHeight * sample < height) {
- sample *= 2;
+ int sampleSize = 1;
+ if (width > mDecodeWidth || height > mDecodeHeight) {
+ int heightRatio = Math.round((float) height / (float) mDecodeHeight);
+ int widthRatio = Math.round((float) width / (float) mDecodeWidth);
+ sampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
- opts = new BitmapFactory.Options();
- opts.inSampleSize = sample;
+
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inSampleSize = sampleSize;
opts.inTempStorage = DECODE_TEMP_STORAGE;
if (isCancelled() || !isUsing()) {
return null;
}
- b = BitmapFactory.decodeFile(path, opts);
+ Bitmap b = BitmapFactory.decodeFile(path, opts);
if (orientation != 0) {
if (isCancelled() || !isUsing()) {
return null;