private volatile GeometryMetadata mPreviousGeometry = null;
private volatile float mPreviewScaleFactor = 1.0f;
+ private volatile String mName = "";
- public CachingPipeline(FiltersManager filtersManager) {
+ public CachingPipeline(FiltersManager filtersManager, String name) {
mFiltersManager = filtersManager;
+ mName = name;
}
public synchronized void reset() {
}
private synchronized void destroyPixelAllocations() {
+ if (DEBUG) {
+ Log.v(LOGTAG, "destroyPixelAllocations in " + getName());
+ }
if (mInPixelsAllocation != null) {
mInPixelsAllocation.destroy();
mInPixelsAllocation = null;
}
+ public synchronized Bitmap renderFinalImage(Bitmap bitmap, ImagePreset preset) {
+ setPresetParameters(preset);
+ mFiltersManager.freeFilterResources(preset);
+ bitmap = preset.applyGeometry(bitmap);
+ bitmap = preset.apply(bitmap);
+ return bitmap;
+ }
+
public synchronized void compute(TripleBufferBitmap buffer, ImagePreset preset, int type) {
if (DEBUG) {
Log.v(LOGTAG, "compute preset " + preset);
mHeight = bitmap.getHeight();
needsUpdate = true;
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "prepareRenderscriptAllocations: " + needsUpdate + " in " + getName());
+ }
return needsUpdate;
}
- public Allocation getInPixelsAllocation() {
+ public synchronized Allocation getInPixelsAllocation() {
return mInPixelsAllocation;
}
- public Allocation getOutPixelsAllocation() {
+ public synchronized Allocation getOutPixelsAllocation() {
return mOutPixelsAllocation;
}
+
+ public String getName() {
+ return mName;
+ }
}
Process.THREAD_PRIORITY_FOREGROUND);
mHandlerThread.start();
mProcessingHandler = new Handler(mHandlerThread.getLooper(), this);
- mAccessoryPipeline = new CachingPipeline(FiltersManager.getManager());
- mPreviewPipeline = new CachingPipeline(FiltersManager.getPreviewManager());
+ mAccessoryPipeline = new CachingPipeline(FiltersManager.getManager(), "Accessory");
+ mPreviewPipeline = new CachingPipeline(FiltersManager.getPreviewManager(), "Preview");
}
public synchronized static FilteringPipeline getPipeline() {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
- if (mFxBitmap == null || mFxBitmapId != getParameters().getBitmapResource()) {
+ int bitmapResourceId = getParameters().getBitmapResource();
+ if (bitmapResourceId == 0) { // null filter fx
+ return bitmap;
+ }
+
+ if (mFxBitmap == null || mFxBitmapId != bitmapResourceId) {
BitmapFactory.Options o = new BitmapFactory.Options();
o.inScaled = false;
- mFxBitmapId = getParameters().getBitmapResource();
+ mFxBitmapId = bitmapResourceId;
if (mFxBitmapId != 0) {
mFxBitmap = BitmapFactory.decodeResource(mResources, mFxBitmapId, o);
} else {
public abstract class ImageFilterRS extends ImageFilter {
private static final String LOGTAG = "ImageFilterRS";
+ private boolean DEBUG = false;
private static volatile RenderScript sRS = null;
private static volatile Resources sResources = null;
return bitmap;
}
CachingPipeline pipeline = getEnvironment().getCachingPipeline();
+ if (DEBUG) {
+ Log.v(LOGTAG, "apply filter " + getName() + " in pipeline " + pipeline.getName());
+ }
boolean needsUpdate = pipeline.prepareRenderscriptAllocations(bitmap);
if (needsUpdate || !isResourcesLoaded()) {
// the allocations changed size
}
runFilter();
update(bitmap);
+ if (DEBUG) {
+ Log.v(LOGTAG, "DONE apply filter " + getName() + " in pipeline " + pipeline.getName());
+ }
}
} catch (android.renderscript.RSIllegalArgumentException e) {
Log.e(LOGTAG, "Illegal argument? " + e);
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.exif.ExifInterface;
+import com.android.gallery3d.filtershow.cache.CachingPipeline;
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.presets.ImagePreset;
import com.android.gallery3d.util.XmpUtilHelper;
if (bitmap == null) {
return null;
}
- preset.setupEnvironment();
- bitmap = preset.applyGeometry(bitmap);
- bitmap = preset.apply(bitmap);
+ CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(), "Saving");
+ bitmap = pipeline.renderFinalImage(bitmap, preset);
Object xmp = getPanoramaXMPData(sourceUri, preset);
ExifInterface exif = getExifData(sourceUri);