OSDN Git Service

Make Gallery2 use platform RenderScript
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / filtershow / filters / ImageFilter.java
index b80fc7f..1fcd300 100644 (file)
@@ -19,12 +19,12 @@ package com.android.gallery3d.filtershow.filters;
 import android.app.Activity;
 import android.graphics.Bitmap;
 import android.graphics.Matrix;
-import android.support.v8.renderscript.Allocation;
+import android.renderscript.Allocation;
 import android.widget.Toast;
 
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.presets.FilterEnvironment;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
 
 public abstract class ImageFilter implements Cloneable {
     private FilterEnvironment mEnvironment = null;
@@ -69,10 +69,12 @@ public abstract class ImageFilter implements Cloneable {
     public boolean supportsAllocationInput() { return false; }
 
     public void apply(Allocation in, Allocation out) {
+        setGeneralParameters();
     }
 
     public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
         // do nothing here, subclasses will implement filtering here
+        setGeneralParameters();
         return bitmap;
     }
 
@@ -86,13 +88,8 @@ public abstract class ImageFilter implements Cloneable {
     }
 
     protected Matrix getOriginalToScreenMatrix(int w, int h) {
-        ImagePreset preset = getEnvironment().getImagePreset();
-        GeometryMetadata geo = getEnvironment().getImagePreset().mGeoData;
-        Matrix originalToScreen = geo.getOriginalToScreen(true,
-                preset.getImageLoader().getOriginalBounds().width(),
-                preset.getImageLoader().getOriginalBounds().height(),
-                w, h);
-        return originalToScreen;
+        return GeometryMathUtils.getImageToScreenMatrix(getEnvironment().getImagePreset()
+                .getGeometryFilters(), true, MasterImage.getImage().getOriginalBounds(), w, h);
     }
 
     public void setEnvironment(FilterEnvironment environment) {
@@ -102,4 +99,11 @@ public abstract class ImageFilter implements Cloneable {
     public FilterEnvironment getEnvironment() {
         return mEnvironment;
     }
+
+    public void setGeneralParameters() {
+        // should implement in subclass which like to transport
+        // some information to other filters. (like the style setting from RetroLux
+        // and Film to FixedFrame)
+        mEnvironment.clearGeneralParameters();
+    }
 }