summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-02-12 17:27:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-12 17:27:44 +0000
commit0c5bacd7e45c4f08796ce047fbc356e696c4da65 (patch)
treedd71cb389c64b27ac2a9d20d73b67004981cd883
parente7f63075622f37d40bbbc8b17eb1b4be1cb2cf82 (diff)
parentb4bab5ddbbb6aa15ae8646686b30021083718a3d (diff)
downloadandroid_packages_apps_Snap-0c5bacd7e45c4f08796ce047fbc356e696c4da65.tar.gz
android_packages_apps_Snap-0c5bacd7e45c4f08796ce047fbc356e696c4da65.tar.bz2
android_packages_apps_Snap-0c5bacd7e45c4f08796ce047fbc356e696c4da65.zip
Merge "Generate thumbnails asynchronously" into gb-ub-photos-bryce
-rw-r--r--src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java20
-rw-r--r--src/com/android/gallery3d/filtershow/cache/RenderingRequest.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java8
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java4
-rw-r--r--src/com/android/gallery3d/filtershow/ui/FilterIconButton.java52
-rw-r--r--src/com/android/gallery3d/filtershow/ui/IconButton.java2
6 files changed, 67 insertions, 22 deletions
diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
index 08a9a718e..472fad759 100644
--- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
+++ b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
@@ -130,10 +130,12 @@ public class FilteringPipeline implements Handler.Callback {
}
mResizedOriginalBitmap = Bitmap.createScaledBitmap(mOriginalBitmap, w, h, true);
*/
+
GeometryMetadata geometry = preset.getGeometry();
if (mPreviousGeometry != null && geometry.equals(mPreviousGeometry)) {
return false;
}
+
RenderScript RS = ImageFilterRS.getRenderScriptContext();
if (mFiltersOnlyOriginalAllocation != null) {
mFiltersOnlyOriginalAllocation.destroy();
@@ -146,7 +148,9 @@ public class FilteringPipeline implements Handler.Callback {
mResizedOriginalBitmap = preset.applyGeometry(mOriginalBitmap);
mOriginalAllocation = Allocation.createFromBitmap(RS, mResizedOriginalBitmap,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+
mPreviousGeometry = new GeometryMetadata(geometry);
+
return true;
}
@@ -193,15 +197,24 @@ public class FilteringPipeline implements Handler.Callback {
}
Bitmap bitmap = request.getBitmap();
ImagePreset preset = request.getImagePreset();
- updateOriginalAllocation(preset);
+ setPresetParameters(preset);
+ if (request.getType() != RenderingRequest.ICON_RENDERING) {
+ updateOriginalAllocation(preset);
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight()
+ +" ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x"
+ + mResizedOriginalBitmap.getHeight());
+ }
if (request.getType() == RenderingRequest.FULL_RENDERING
|| request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
mOriginalAllocation.copyTo(bitmap);
- } else {
+ } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
mFiltersOnlyOriginalAllocation.copyTo(bitmap);
}
if (request.getType() == RenderingRequest.FULL_RENDERING
- || request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ || request.getType() == RenderingRequest.FILTERS_RENDERING
+ || request.getType() == RenderingRequest.ICON_RENDERING) {
Bitmap bmp = preset.apply(bitmap);
request.setBitmap(bmp);
}
@@ -228,6 +241,7 @@ public class FilteringPipeline implements Handler.Callback {
}
mOriginalAllocation.copyTo(bitmap);
+ setPresetParameters(preset);
bitmap = preset.apply(bitmap);
time = System.currentTimeMillis() - time;
diff --git a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java b/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
index c995a9ff3..2815936f8 100644
--- a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
+++ b/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
@@ -30,6 +30,7 @@ public class RenderingRequest {
public static int FULL_RENDERING = 0;
public static int FILTERS_RENDERING = 1;
public static int GEOMETRY_RENDERING = 2;
+ public static int ICON_RENDERING = 3;
private static final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
public static void post(Bitmap source, ImagePreset preset, int type,
@@ -40,7 +41,7 @@ public class RenderingRequest {
}
RenderingRequest request = new RenderingRequest();
Bitmap bitmap = null;
- if (type == FULL_RENDERING || type == GEOMETRY_RENDERING) {
+ if (type == FULL_RENDERING || type == GEOMETRY_RENDERING || type == ICON_RENDERING) {
bitmap = preset.applyGeometry(source);
} else {
bitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), mConfig);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 21046b56c..463756839 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -406,8 +406,12 @@ public class ImageShow extends View implements OnGestureListener,
paint.setTextSize(mOriginalTextSize);
paint.getTextBounds(mOriginalText, 0, mOriginalText.length(), bounds);
paint.setColor(Color.BLACK);
- canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin + 1,
- mImageBounds.top + bounds.height() + mOriginalTextMargin + 1, paint);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(3);
+ canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
+ mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
+ paint.setStyle(Paint.Style.FILL);
+ paint.setStrokeWidth(1);
paint.setColor(Color.WHITE);
canvas.drawText(mOriginalText, mImageBounds.left + mOriginalTextMargin,
mImageBounds.top + bounds.height() + mOriginalTextMargin, paint);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 296954cf9..1e830b04b 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -76,6 +76,10 @@ public class MasterImage implements RenderingRequestCaller {
mActivity = activity;
}
+ public ImageLoader getLoader() {
+ return mLoader;
+ }
+
public synchronized ImagePreset getPreset() {
return mPreset;
}
diff --git a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
index a753f46b9..19807e6af 100644
--- a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
@@ -24,20 +24,29 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
+import com.android.gallery3d.app.Log;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.PanelController;
import com.android.gallery3d.filtershow.cache.FilteringPipeline;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.cache.RenderingRequest;
+import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.presets.ImagePreset;
-public class FilterIconButton extends IconButton implements View.OnClickListener {
+public class FilterIconButton extends IconButton implements View.OnClickListener, RenderingRequestCaller {
+ private static final String LOGTAG = "FilterIconButton";
private Bitmap mOverlayBitmap = null;
private PanelController mController = null;
- private ImageFilter mImageFilter = null;
private FilterRepresentation mFilterRepresentation = null;
private LinearLayout mParentContainer = null;
private View.OnClickListener mListener = null;
+ private Bitmap mIconBitmap = null;
+ private ImagePreset mPreset = null;
+ private Rect mDestination = null;
public FilterIconButton(Context context) {
super(context);
@@ -61,20 +70,19 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
@Override
protected Bitmap drawImage(Bitmap dst, Bitmap image, Rect destination) {
- dst = super.drawImage(dst, image, destination);
- if (mImageFilter == null && mFilterRepresentation != null) {
- mImageFilter = FiltersManager.getManager().getFilterForRepresentation(mFilterRepresentation);
+ if (mIconBitmap == null && mPreset == null) {
+ ImageLoader loader = MasterImage.getImage().getLoader();
+ if (loader != null) {
+ dst = super.drawImage(dst, image, destination);
+ ImagePreset mPreset = new ImagePreset();
+ mPreset.addFilter(mFilterRepresentation);
+ mDestination = destination;
+ RenderingRequest.post(dst.copy(Bitmap.Config.ARGB_8888, true), mPreset, RenderingRequest.ICON_RENDERING, this);
+ }
+ return dst;
+ } else {
+ return mIconBitmap;
}
- if (mFilterRepresentation != null && mImageFilter != null) {
- mImageFilter.useRepresentation(mFilterRepresentation);
- }
- if (mImageFilter != null) {
- dst = mImageFilter.iconApply(dst, 1.0f, false);
- }
- if (mOverlayBitmap != null) {
- dst = super.drawImage(dst, mOverlayBitmap, destination);
- }
- return dst;
}
@Override
@@ -104,5 +112,19 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
mOverlayBitmap = BitmapFactory.decodeResource(getResources(),
mFilterRepresentation.getOverlayId());
}
+ invalidate();
+ }
+
+ @Override
+ public void available(RenderingRequest request) {
+ if (request.getBitmap() == null) {
+ return;
+ }
+ mIconBitmap = request.getBitmap();
+ if (mOverlayBitmap != null) {
+ mIconBitmap = super.drawImage(mIconBitmap, mOverlayBitmap, mDestination);
+ }
+ invalidate();
+ stale_icon = true;
}
}
diff --git a/src/com/android/gallery3d/filtershow/ui/IconButton.java b/src/com/android/gallery3d/filtershow/ui/IconButton.java
index 55dfb8043..28d01dfd9 100644
--- a/src/com/android/gallery3d/filtershow/ui/IconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/IconButton.java
@@ -38,7 +38,7 @@ public class IconButton extends Button {
protected Bitmap mImageMirror = null;
protected Bitmap mIcon = null;
- private boolean stale_icon = true;
+ protected boolean stale_icon = true;
public IconButton(Context context) {
this(context, null);