summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-04-10 19:27:57 -0700
committernicolasroard <nicolasroard@google.com>2013-04-12 11:55:51 -0700
commit6675f242f747d60da2429d7ef949731a05b612c7 (patch)
tree6094aee85c3ee6e5e9a801724d29f9b08be3f017 /src
parent8f315c85d5222e5dc402b3a0580017771b850b89 (diff)
downloadandroid_packages_apps_Snap-6675f242f747d60da2429d7ef949731a05b612c7.tar.gz
android_packages_apps_Snap-6675f242f747d60da2429d7ef949731a05b612c7.tar.bz2
android_packages_apps_Snap-6675f242f747d60da2429d7ef949731a05b612c7.zip
Add a direct rendering mode
This takes input and output allocations. Also added a utility method in ImageFilterRS to scale textures at screen resolution. bug:8603245 bug:8588853 Change-Id: Ic5e4dea2289f0edd7518fc07f04b523be5316e82
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java12
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java23
2 files changed, 35 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
index b474b8412..7b0e0193f 100644
--- a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
+++ b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.presets;
import android.graphics.Bitmap;
+import android.support.v8.renderscript.Allocation;
import com.android.gallery3d.filtershow.cache.CachingPipeline;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
@@ -61,6 +62,17 @@ public class FilterEnvironment {
return mFiltersManager;
}
+ public void applyRepresentation(FilterRepresentation representation,
+ Allocation in, Allocation out) {
+ ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
+ filter.useRepresentation(representation);
+ filter.setEnvironment(this);
+ if (filter.supportsAllocationInput()) {
+ filter.apply(in, out);
+ }
+ filter.setEnvironment(null);
+ }
+
public Bitmap applyRepresentation(FilterRepresentation representation, Bitmap bitmap) {
ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
filter.useRepresentation(representation);
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 2858ea6e5..791164f5c 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.filtershow.presets;
import android.graphics.Bitmap;
import android.graphics.Rect;
+import android.support.v8.renderscript.Allocation;
import android.util.Log;
import com.android.gallery3d.filtershow.ImageStateAdapter;
@@ -473,6 +474,28 @@ public class ImagePreset {
return bitmap;
}
+ public void applyFilters(int from, int to, Allocation in, Allocation out, FilterEnvironment environment) {
+ if (mDoApplyFilters) {
+ if (from < 0) {
+ from = 0;
+ }
+ if (to == -1) {
+ to = mFilters.size();
+ }
+ for (int i = from; i < to; i++) {
+ FilterRepresentation representation = null;
+ synchronized (mFilters) {
+ representation = mFilters.elementAt(i);
+ representation.synchronizeRepresentation();
+ }
+ if (i > from) {
+ in.copyFrom(out);
+ }
+ environment.applyRepresentation(representation, in, out);
+ }
+ }
+ }
+
public boolean canDoPartialRendering() {
if (mGeoData.hasModifications()) {
return false;