package com.android.gallery3d.filtershow.pipeline;
import android.graphics.Bitmap;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.RenderScript;
+import android.graphics.Canvas;
+import android.renderscript.Allocation;
+import android.renderscript.RenderScript;
import android.util.Log;
import com.android.gallery3d.filtershow.cache.BitmapCache;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
RenderScript rs = CachingPipeline.getRenderScriptContext();
if (bitmap != null) {
BitmapCache cache = MasterImage.getImage().getBitmapCache();
- cache.cache(mBitmap);
- mBitmap = cache.getBitmapCopy(bitmap);
+ mBitmap = cache.getBitmapCopy(bitmap, BitmapCache.PREVIEW_CACHE);
}
if (mUseAllocation) {
// TODO: recreate the allocation when the RS context changes
}
}
- public Bitmap getBitmap() {
+ public boolean isSameSize(Bitmap bitmap) {
+ if (mBitmap == null || bitmap == null) {
+ return false;
+ }
+ if (mBitmap.getWidth() == bitmap.getWidth()
+ && mBitmap.getHeight() == bitmap.getHeight()) {
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized void useBitmap(Bitmap bitmap) {
+ Canvas canvas = new Canvas(mBitmap);
+ canvas.drawBitmap(bitmap, 0, 0, null);
+ }
+
+ public synchronized Bitmap getBitmap() {
return mBitmap;
}
public void remove() {
BitmapCache cache = MasterImage.getImage().getBitmapCache();
- cache.cache(mBitmap);
- mBitmap = null;
+ if (cache.cache(mBitmap)) {
+ mBitmap = null;
+ }
}
}