diff options
author | nicolasroard <nicolasroard@google.com> | 2013-04-17 08:37:22 -0700 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-04-17 08:42:42 -0700 |
commit | e7abc9ca7565ba123032784e9b14d2d6d1590393 (patch) | |
tree | f8f92358a60721225671ca49cad733dbc27ee2eb /src/com | |
parent | a40200389cc61d6164dcbce0299dbcb77b810c66 (diff) | |
download | android_packages_apps_Snap-e7abc9ca7565ba123032784e9b14d2d6d1590393.tar.gz android_packages_apps_Snap-e7abc9ca7565ba123032784e9b14d2d6d1590393.tar.bz2 android_packages_apps_Snap-e7abc9ca7565ba123032784e9b14d2d6d1590393.zip |
Fix border apply if no filter applied
Change-Id: Ic5b319625b42adb298094c4ad202d6c161538644
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/filtershow/cache/CachingPipeline.java | 7 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/presets/ImagePreset.java | 18 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java b/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java index 8cb8f8f9e..fb0a29ebd 100644 --- a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java +++ b/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java @@ -308,8 +308,11 @@ public class CachingPipeline { setupEnvironment(preset, false); mFiltersManager.freeFilterResources(preset); preset.applyFilters(-1, -1, in, out, mEnvironment); - // TODO: we should render the border onto a different bitmap instead - preset.applyBorder(in, out, mEnvironment); + boolean copyOut = false; + if (preset.nbFilters() > 0) { + copyOut = true; + } + preset.applyBorder(in, out, copyOut, mEnvironment); } } diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java index bd2f494cd..48975a1e8 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -457,6 +457,10 @@ public class ImagePreset { return bitmap; } + public int nbFilters() { + return mFilters.size(); + } + public Bitmap applyFilters(Bitmap bitmap, int from, int to, FilterEnvironment environment) { if (mDoApplyFilters) { if (from < 0) { @@ -478,17 +482,23 @@ public class ImagePreset { return bitmap; } - public void applyBorder(Allocation in, Allocation out, FilterEnvironment environment) { + public void applyBorder(Allocation in, Allocation out, + boolean copyOut, FilterEnvironment environment) { if (mBorder != null && mDoApplyGeometry) { mBorder.synchronizeRepresentation(); // TODO: should keep the bitmap around - Allocation bitmapIn = Allocation.createTyped(CachingPipeline.getRenderScriptContext(), in.getType()); - bitmapIn.copyFrom(out); + Allocation bitmapIn = in; + if (copyOut) { + bitmapIn = Allocation.createTyped( + CachingPipeline.getRenderScriptContext(), in.getType()); + bitmapIn.copyFrom(out); + } environment.applyRepresentation(mBorder, bitmapIn, out); } } - public void applyFilters(int from, int to, Allocation in, Allocation out, FilterEnvironment environment) { + public void applyFilters(int from, int to, Allocation in, Allocation out, + FilterEnvironment environment) { if (mDoApplyFilters) { if (from < 0) { from = 0; |