diff options
| author | nicolasroard <nicolasroard@google.com> | 2013-04-02 23:16:52 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-04-02 23:16:52 -0700 |
| commit | 0d74b562db388f87f146931c410ccf3da1c72681 (patch) | |
| tree | 2a798dfaaca96ea8cd14e35c1912d6b56b55eb13 | |
| parent | 62e921d237895fead41ad969cc03befcc760d6d5 (diff) | |
| parent | 2538c992dc70b3eda7487ef68dba0390b2f337d7 (diff) | |
| download | android_packages_apps_Gallery2-0d74b562db388f87f146931c410ccf3da1c72681.tar.gz android_packages_apps_Gallery2-0d74b562db388f87f146931c410ccf3da1c72681.tar.bz2 android_packages_apps_Gallery2-0d74b562db388f87f146931c410ccf3da1c72681.zip | |
am 2538c992: Fix segfaults in RS filters
* commit '2538c992dc70b3eda7487ef68dba0390b2f337d7':
Fix segfaults in RS filters
| -rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java index 2aeaed877..a0523c14e 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java @@ -16,7 +16,6 @@ package com.android.gallery3d.filtershow.filters; -import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v8.renderscript.*; @@ -28,6 +27,8 @@ import com.android.gallery3d.filtershow.cache.CachingPipeline; public abstract class ImageFilterRS extends ImageFilter { private static final String LOGTAG = "ImageFilterRS"; private boolean DEBUG = false; + private int mLastInputWidth = 0; + private int mLastInputHeight = 0; private volatile boolean mResourcesLoaded = false; @@ -65,11 +66,19 @@ public abstract class ImageFilterRS extends ImageFilter { Log.v(LOGTAG, "apply filter " + getName() + " in pipeline " + pipeline.getName()); } Resources rsc = pipeline.getResources(); + boolean sizeChanged = false; + if (getInPixelsAllocation() != null + && ((getInPixelsAllocation().getType().getX() != mLastInputWidth) + || (getInPixelsAllocation().getType().getY() != mLastInputHeight))) { + sizeChanged = true; + } if (pipeline.prepareRenderscriptAllocations(bitmap) - || !isResourcesLoaded()) { + || !isResourcesLoaded() || sizeChanged) { freeResources(); createFilter(rsc, scaleFactor, quality); setResourcesLoaded(true); + mLastInputWidth = getInPixelsAllocation().getType().getX(); + mLastInputHeight = getInPixelsAllocation().getType().getY(); } bindScriptValues(); runFilter(); |
