OSDN Git Service

Revert "Revert "Make Gallery2 use platform RenderScript""
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / filtershow / pipeline / FilterEnvironment.java
index 2757aff..0b84f52 100644 (file)
@@ -18,8 +18,9 @@ package com.android.gallery3d.filtershow.pipeline;
 
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
-import android.support.v8.renderscript.Allocation;
+import android.renderscript.Allocation;
 
+import com.android.gallery3d.app.Log;
 import com.android.gallery3d.filtershow.cache.BitmapCache;
 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
 import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
@@ -66,12 +67,12 @@ public class FilterEnvironment {
         mBitmapCache.cache(bitmap);
     }
 
-    public Bitmap getBitmap(int w, int h) {
-        return mBitmapCache.getBitmap(w, h);
+    public Bitmap getBitmap(int w, int h, int type) {
+        return mBitmapCache.getBitmap(w, h, type);
     }
 
-    public Bitmap getBitmapCopy(Bitmap source) {
-        return mBitmapCache.getBitmapCopy(source);
+    public Bitmap getBitmapCopy(Bitmap source, int type) {
+        return mBitmapCache.getBitmapCopy(source, type);
     }
 
     public void setImagePreset(ImagePreset imagePreset) {
@@ -126,9 +127,15 @@ public class FilterEnvironment {
             return bitmap;
         }
         ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
+        if (filter == null){
+            Log.e(LOGTAG,"No ImageFilter for "+representation.getSerializationName());
+        }
         filter.useRepresentation(representation);
         filter.setEnvironment(this);
         Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality);
+        if (bitmap != ret) {
+            cache(bitmap);
+        }
         filter.setGeneralParameters();
         filter.setEnvironment(null);
         return ret;
@@ -161,4 +168,7 @@ public class FilterEnvironment {
         generalParameters.put(id, value);
     }
 
+    public BitmapCache getBimapCache() {
+        return mBitmapCache;
+    }
 }