sResources = null;
}
+ public void stop() {
+ mEnvironment.setStop(true);
+ }
+
public synchronized void reset() {
synchronized (CachingPipeline.class) {
if (getRenderScriptContext() == null) {
}
mEnvironment.setQuality(ImagePreset.QUALITY_PREVIEW);
mEnvironment.setImagePreset(preset);
+ mEnvironment.setStop(false);
}
public void setOriginal(Bitmap bitmap) {
}
Bitmap bmp = preset.apply(bitmap, mEnvironment);
- request.setBitmap(bmp);
+ if (!mEnvironment.needsStop()) {
+ request.setBitmap(bmp);
+ }
mFiltersManager.freeFilterResources(preset);
}
}
} else {
mAccessoryPipeline.render(request);
}
- Message uimsg = mUIHandler.obtainMessage(NEW_RENDERING_REQUEST);
- uimsg.obj = request;
- mUIHandler.sendMessage(uimsg);
+ if (request.getBitmap() != null) {
+ Message uimsg = mUIHandler.obtainMessage(NEW_RENDERING_REQUEST);
+ uimsg.obj = request;
+ mUIHandler.sendMessage(uimsg);
+ }
break;
}
}
return;
}
mHasUnhandledPreviewRequest = true;
+ mHighresPreviewPipeline.stop();
if (mProcessingHandler.hasMessages(COMPUTE_PRESET)) {
return;
}
private int mQuality;
private FiltersManager mFiltersManager;
private CachingPipeline mCachingPipeline;
+ private volatile boolean mStop = false;
+
+ public synchronized boolean needsStop() {
+ return mStop;
+ }
+
+ public synchronized void setStop(boolean stop) {
+ this.mStop = stop;
+ }
+
private HashMap<Long, WeakReference<Bitmap>>
bitmapCach = new HashMap<Long, WeakReference<Bitmap>>();
representation.synchronizeRepresentation();
}
bitmap = environment.applyRepresentation(representation, bitmap);
+ if (environment.needsStop()) {
+ return bitmap;
+ }
}
}