summaryrefslogtreecommitdiffstats
path: root/rs/java
diff options
context:
space:
mode:
Diffstat (limited to 'rs/java')
-rw-r--r--rs/java/android/renderscript/Element.java45
-rw-r--r--rs/java/android/renderscript/RenderScript.java101
-rw-r--r--rs/java/android/renderscript/Script.java114
-rw-r--r--rs/java/android/renderscript/ScriptGroup2.java319
-rw-r--r--rs/java/android/renderscript/ScriptIntrinsicResize.java8
5 files changed, 493 insertions, 94 deletions
diff --git a/rs/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java
index c6b5b0d..287b3f1 100644
--- a/rs/java/android/renderscript/Element.java
+++ b/rs/java/android/renderscript/Element.java
@@ -118,7 +118,10 @@ public class Element extends BaseObj {
*/
public enum DataType {
NONE (0, 0),
- //FLOAT_16 (1, 2),
+ /**
+ * @hide
+ */
+ FLOAT_16 (1, 2),
FLOAT_32 (2, 4),
FLOAT_64 (3, 8),
SIGNED_8 (4, 1),
@@ -386,6 +389,16 @@ public class Element extends BaseObj {
return rs.mElement_I64;
}
+ /**
+ * @hide
+ */
+ public static Element F16(RenderScript rs) {
+ if(rs.mElement_F16 == null) {
+ rs.mElement_F16 = createUser(rs, DataType.FLOAT_16);
+ }
+ return rs.mElement_F16;
+ }
+
public static Element F32(RenderScript rs) {
if(rs.mElement_F32 == null) {
rs.mElement_F32 = createUser(rs, DataType.FLOAT_32);
@@ -520,6 +533,36 @@ public class Element extends BaseObj {
return rs.mElement_RGBA_8888;
}
+ /**
+ * @hide
+ */
+ public static Element F16_2(RenderScript rs) {
+ if(rs.mElement_HALF_2 == null) {
+ rs.mElement_HALF_2 = createVector(rs, DataType.FLOAT_16, 2);
+ }
+ return rs.mElement_HALF_2;
+ }
+
+ /**
+ * @hide
+ */
+ public static Element F16_3(RenderScript rs) {
+ if(rs.mElement_FLOAT_3 == null) {
+ rs.mElement_FLOAT_3 = createVector(rs, DataType.FLOAT_16, 3);
+ }
+ return rs.mElement_HALF_3;
+ }
+
+ /**
+ * @hide
+ */
+ public static Element F16_4(RenderScript rs) {
+ if(rs.mElement_HALF_4 == null) {
+ rs.mElement_HALF_4 = createVector(rs, DataType.FLOAT_16, 4);
+ }
+ return rs.mElement_HALF_4;
+ }
+
public static Element F32_2(RenderScript rs) {
if(rs.mElement_FLOAT_2 == null) {
rs.mElement_FLOAT_2 = createVector(rs, DataType.FLOAT_32, 2);
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index e86c461..271fe05 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -302,6 +302,46 @@ public class RenderScript {
rsnContextResume(mContext);
}
+ native long rsnClosureCreate(long con, long kernelID, long returnValue,
+ long[] fieldIDs, long[] values, int[] sizes, long[] depClosures,
+ long[] depFieldIDs);
+ synchronized long nClosureCreate(long kernelID, long returnValue,
+ long[] fieldIDs, long[] values, int[] sizes, long[] depClosures,
+ long[] depFieldIDs) {
+ validate();
+ return rsnClosureCreate(mContext, kernelID, returnValue, fieldIDs, values,
+ sizes, depClosures, depFieldIDs);
+ }
+
+ native void rsnClosureSetArg(long con, long closureID, int index,
+ long value, int size);
+ synchronized void nClosureSetArg(long closureID, int index, long value,
+ int size) {
+ validate();
+ rsnClosureSetArg(mContext, closureID, index, value, size);
+ }
+
+ native void rsnClosureSetGlobal(long con, long closureID, long fieldID,
+ long value, int size);
+ // Does this have to be synchronized?
+ synchronized void nClosureSetGlobal(long closureID, long fieldID,
+ long value, int size) {
+ validate(); // TODO: is this necessary?
+ rsnClosureSetGlobal(mContext, closureID, fieldID, value, size);
+ }
+
+ native long rsnScriptGroup2Create(long con, long[] closures);
+ synchronized long nScriptGroup2Create(long[] closures) {
+ validate();
+ return rsnScriptGroup2Create(mContext, closures);
+ }
+
+ native void rsnScriptGroup2Execute(long con, long groupID);
+ synchronized void nScriptGroup2Execute(long groupID) {
+ validate();
+ rsnScriptGroup2Execute(mContext, groupID);
+ }
+
native void rsnAssignName(long con, long obj, byte[] name);
synchronized void nAssignName(long obj, byte[] name) {
validate();
@@ -605,52 +645,14 @@ public class RenderScript {
validate();
rsnScriptInvoke(mContext, id, slot);
}
- native void rsnScriptForEach(long con, long id, int slot, long ain, long aout, byte[] params);
- native void rsnScriptForEach(long con, long id, int slot, long ain, long aout);
- native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, byte[] params,
- int xstart, int xend, int ystart, int yend, int zstart, int zend);
- native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout,
- int xstart, int xend, int ystart, int yend, int zstart, int zend);
- synchronized void nScriptForEach(long id, int slot, long ain, long aout, byte[] params) {
- validate();
- if (params == null) {
- rsnScriptForEach(mContext, id, slot, ain, aout);
- } else {
- rsnScriptForEach(mContext, id, slot, ain, aout, params);
- }
- }
- synchronized void nScriptForEachClipped(long id, int slot, long ain, long aout, byte[] params,
- int xstart, int xend, int ystart, int yend, int zstart, int zend) {
- validate();
- if (params == null) {
- rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend);
- } else {
- rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend);
- }
- }
+ native void rsnScriptForEach(long con, long id, int slot, long[] ains,
+ long aout, byte[] params, int[] limits);
- /**
- * Multi-input code.
- *
- */
-
- // @hide
- native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout, byte[] params,
- int xstart, int xend, int ystart, int yend, int zstart, int zend);
- // @hide
- native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout,
- int xstart, int xend, int ystart, int yend, int zstart, int zend);
-
- // @hide
- synchronized void nScriptForEachMultiClipped(long id, int slot, long[] ains, long aout, byte[] params,
- int xstart, int xend, int ystart, int yend, int zstart, int zend) {
- validate();
- if (params == null) {
- rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, xstart, xend, ystart, yend, zstart, zend);
- } else {
- rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, params, xstart, xend, ystart, yend, zstart, zend);
- }
+ synchronized void nScriptForEach(long id, int slot, long[] ains, long aout,
+ byte[] params, int[] limits) {
+ validate();
+ rsnScriptForEach(mContext, id, slot, ains, aout, params, limits);
}
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
@@ -869,6 +871,7 @@ public class RenderScript {
Element mElement_I32;
Element mElement_U64;
Element mElement_I64;
+ Element mElement_F16;
Element mElement_F32;
Element mElement_F64;
Element mElement_BOOLEAN;
@@ -892,6 +895,10 @@ public class RenderScript {
Element mElement_RGBA_4444;
Element mElement_RGBA_8888;
+ Element mElement_HALF_2;
+ Element mElement_HALF_3;
+ Element mElement_HALF_4;
+
Element mElement_FLOAT_2;
Element mElement_FLOAT_3;
Element mElement_FLOAT_4;
@@ -1040,8 +1047,10 @@ public class RenderScript {
* their priority to LOW to avoid starving forground processes.
*/
public enum Priority {
- LOW (Process.THREAD_PRIORITY_BACKGROUND + (5 * Process.THREAD_PRIORITY_LESS_FAVORABLE)),
- NORMAL (Process.THREAD_PRIORITY_DISPLAY);
+ // These values used to represent official thread priority values
+ // now they are simply enums to be used by the runtime side
+ LOW (15),
+ NORMAL (-8);
int mID;
Priority(int id) {
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index c49ef94..eb1687a 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -48,7 +48,8 @@ public class Script extends BaseObj {
/**
* Only to be used by generated reflected classes.
*/
- protected KernelID createKernelID(int slot, int sig, Element ein, Element eout) {
+ protected KernelID createKernelID(int slot, int sig, Element ein,
+ Element eout) {
KernelID k = mKIDs.get(slot);
if (k != null) {
return k;
@@ -127,59 +128,56 @@ public class Script extends BaseObj {
* Only intended for use by generated reflected code.
*
*/
- protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
- mRS.validate();
- mRS.validateObject(ain);
- mRS.validateObject(aout);
- if (ain == null && aout == null) {
- throw new RSIllegalArgumentException(
- "At least one of ain or aout is required to be non-null.");
- }
- long in_id = 0;
- if (ain != null) {
- in_id = ain.getID(mRS);
- }
- long out_id = 0;
- if (aout != null) {
- out_id = aout.getID(mRS);
- }
- byte[] params = null;
- if (v != null) {
- params = v.getData();
- }
- mRS.nScriptForEach(getID(mRS), slot, in_id, out_id, params);
+ protected void forEach(int slot, Allocation ain, Allocation aout,
+ FieldPacker v) {
+ forEach(slot, ain, aout, v, null);
}
/**
* Only intended for use by generated reflected code.
*
*/
- protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
+ protected void forEach(int slot, Allocation ain, Allocation aout,
+ FieldPacker v, LaunchOptions sc) {
+ // TODO: Is this necessary if nScriptForEach calls validate as well?
mRS.validate();
mRS.validateObject(ain);
mRS.validateObject(aout);
+
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
}
- if (sc == null) {
- forEach(slot, ain, aout, v);
- return;
- }
- long in_id = 0;
+ long[] in_ids = null;
if (ain != null) {
- in_id = ain.getID(mRS);
+ in_ids = mInIdsBuffer;
+ in_ids[0] = ain.getID(mRS);
}
+
long out_id = 0;
if (aout != null) {
out_id = aout.getID(mRS);
}
+
byte[] params = null;
if (v != null) {
params = v.getData();
}
- mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
+
+ int[] limits = null;
+ if (sc != null) {
+ limits = new int[6];
+
+ limits[0] = sc.xstart;
+ limits[1] = sc.xend;
+ limits[2] = sc.ystart;
+ limits[3] = sc.yend;
+ limits[4] = sc.zstart;
+ limits[5] = sc.zend;
+ }
+
+ mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
}
/**
@@ -187,8 +185,9 @@ public class Script extends BaseObj {
*
* @hide
*/
- protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v) {
- forEach(slot, ains, aout, v, new LaunchOptions());
+ protected void forEach(int slot, Allocation[] ains, Allocation aout,
+ FieldPacker v) {
+ forEach(slot, ains, aout, v, null);
}
/**
@@ -196,24 +195,20 @@ public class Script extends BaseObj {
*
* @hide
*/
- protected void forEach(int slot, Allocation[] ains, Allocation aout, FieldPacker v, LaunchOptions sc) {
+ protected void forEach(int slot, Allocation[] ains, Allocation aout,
+ FieldPacker v, LaunchOptions sc) {
+ // TODO: Is this necessary if nScriptForEach calls validate as well?
mRS.validate();
-
for (Allocation ain : ains) {
mRS.validateObject(ain);
}
-
mRS.validateObject(aout);
+
if (ains == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
}
- if (sc == null) {
- forEach(slot, ains, aout, v);
- return;
- }
-
long[] in_ids = new long[ains.length];
for (int index = 0; index < ains.length; ++index) {
in_ids[index] = ains[index].getID(mRS);
@@ -223,15 +218,33 @@ public class Script extends BaseObj {
if (aout != null) {
out_id = aout.getID(mRS);
}
+
byte[] params = null;
if (v != null) {
params = v.getData();
}
- mRS.nScriptForEachMultiClipped(getID(mRS), slot, in_ids, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend);
+
+ int[] limits = null;
+ if (sc != null) {
+ limits = new int[6];
+
+ limits[0] = sc.xstart;
+ limits[1] = sc.xend;
+ limits[2] = sc.ystart;
+ limits[3] = sc.yend;
+ limits[4] = sc.zstart;
+ limits[5] = sc.zend;
+ }
+
+ mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
}
+ long[] mInIdsBuffer;
+
Script(long id, RenderScript rs) {
super(id, rs);
+
+ mInIdsBuffer = new long[1];
}
@@ -243,11 +256,17 @@ public class Script extends BaseObj {
mRS.validate();
mRS.validateObject(va);
if (va != null) {
- if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
+
+ android.content.Context context = mRS.getApplicationContext();
+
+ if (context.getApplicationInfo().targetSdkVersion >= 20) {
final Type t = va.mType;
- if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) || (t.getZ() != 0)) {
+ if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) ||
+ (t.getZ() != 0)) {
+
throw new RSIllegalArgumentException(
- "API 20+ only allows simple 1D allocations to be used with bind.");
+ "API 20+ only allows simple 1D allocations to be " +
+ "used with bind.");
}
}
mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
@@ -378,11 +397,14 @@ public class Script extends BaseObj {
protected Allocation mAllocation;
protected void init(RenderScript rs, int dimx) {
- mAllocation = Allocation.createSized(rs, mElement, dimx, Allocation.USAGE_SCRIPT);
+ mAllocation = Allocation.createSized(rs, mElement, dimx,
+ Allocation.USAGE_SCRIPT);
}
protected void init(RenderScript rs, int dimx, int usages) {
- mAllocation = Allocation.createSized(rs, mElement, dimx, Allocation.USAGE_SCRIPT | usages);
+ mAllocation =
+ Allocation.createSized(rs, mElement, dimx,
+ Allocation.USAGE_SCRIPT | usages);
}
protected FieldBase() {
diff --git a/rs/java/android/renderscript/ScriptGroup2.java b/rs/java/android/renderscript/ScriptGroup2.java
new file mode 100644
index 0000000..dcad787
--- /dev/null
+++ b/rs/java/android/renderscript/ScriptGroup2.java
@@ -0,0 +1,319 @@
+package android.renderscript;
+
+import android.util.Log;
+import android.util.Pair;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ @hide Pending Android public API approval.
+ */
+/**
+
+******************************
+You have tried to change the API from what has been previously approved.
+
+To make these errors go away, you have two choices:
+ 1) You can add "@hide" javadoc comments to the methods, etc. listed in the
+ errors above.
+
+ 2) You can update current.txt by executing the following command:
+ make update-api
+
+To submit the revised current.txt to the main Android repository,
+you will need approval.
+******************************
+
+ @hide Pending Android public API approval.
+ */
+public class ScriptGroup2 extends BaseObj {
+
+ public static class Closure extends BaseObj {
+ private Allocation mReturnValue;
+ private Map<Script.FieldID, Object> mBindings;
+
+ private Future mReturnFuture;
+ private Map<Script.FieldID, Future> mGlobalFuture;
+
+ private static final String TAG = "Closure";
+
+ public Closure(long id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ public Closure(RenderScript rs, Script.KernelID kernelID, Type returnType,
+ Object[] args, Map<Script.FieldID, Object> globals) {
+ super(0, rs);
+
+ mReturnValue = Allocation.createTyped(rs, returnType);
+ mBindings = new HashMap<Script.FieldID, Object>();
+ mGlobalFuture = new HashMap<Script.FieldID, Future>();
+
+ int numValues = args.length + globals.size();
+
+ long[] fieldIDs = new long[numValues];
+ long[] values = new long[numValues];
+ int[] sizes = new int[numValues];
+ long[] depClosures = new long[numValues];
+ long[] depFieldIDs = new long[numValues];
+
+ int i;
+ for (i = 0; i < args.length; i++) {
+ Object obj = args[i];
+ fieldIDs[i] = 0;
+ if (obj instanceof UnboundValue) {
+ UnboundValue unbound = (UnboundValue)obj;
+ unbound.addReference(this, i);
+ } else {
+ retrieveValueAndDependenceInfo(rs, i, args[i], values, sizes,
+ depClosures, depFieldIDs);
+ }
+ }
+
+ for (Map.Entry<Script.FieldID, Object> entry : globals.entrySet()) {
+ Object obj = entry.getValue();
+ Script.FieldID fieldID = entry.getKey();
+ fieldIDs[i] = fieldID.getID(rs);
+ if (obj instanceof UnboundValue) {
+ UnboundValue unbound = (UnboundValue)obj;
+ unbound.addReference(this, fieldID);
+ } else {
+ retrieveValueAndDependenceInfo(rs, i, obj, values,
+ sizes, depClosures, depFieldIDs);
+ }
+ i++;
+ }
+
+ long id = rs.nClosureCreate(kernelID.getID(rs), mReturnValue.getID(rs),
+ fieldIDs, values, sizes, depClosures, depFieldIDs);
+
+ setID(id);
+ }
+
+ private static void retrieveValueAndDependenceInfo(RenderScript rs,
+ int index, Object obj, long[] values, int[] sizes, long[] depClosures,
+ long[] depFieldIDs) {
+
+ if (obj instanceof Future) {
+ Future f = (Future)obj;
+ obj = f.getValue();
+ depClosures[index] = f.getClosure().getID(rs);
+ Script.FieldID fieldID = f.getFieldID();
+ depFieldIDs[index] = fieldID != null ? fieldID.getID(rs) : 0;
+ } else {
+ depClosures[index] = 0;
+ depFieldIDs[index] = 0;
+ }
+
+ ValueAndSize vs = new ValueAndSize(rs, obj);
+ values[index] = vs.value;
+ sizes[index] = vs.size;
+ }
+
+ public Future getReturn() {
+ if (mReturnFuture == null) {
+ mReturnFuture = new Future(this, null, mReturnValue);
+ }
+
+ return mReturnFuture;
+ }
+
+ public Future getGlobal(Script.FieldID field) {
+ Future f = mGlobalFuture.get(field);
+
+ if (f == null) {
+ f = new Future(this, field, mBindings.get(field));
+ mGlobalFuture.put(field, f);
+ }
+
+ return f;
+ }
+
+ void setArg(int index, Object obj) {
+ ValueAndSize vs = new ValueAndSize(mRS, obj);
+ mRS.nClosureSetArg(getID(mRS), index, vs.value, vs.size);
+ }
+
+ void setGlobal(Script.FieldID fieldID, Object obj) {
+ ValueAndSize vs = new ValueAndSize(mRS, obj);
+ mRS.nClosureSetGlobal(getID(mRS), fieldID.getID(mRS), vs.value, vs.size);
+ }
+
+ private static final class ValueAndSize {
+ public ValueAndSize(RenderScript rs, Object obj) {
+ if (obj instanceof Allocation) {
+ value = ((Allocation)obj).getID(rs);
+ size = -1;
+ } else if (obj instanceof Boolean) {
+ value = ((Boolean)obj).booleanValue() ? 1 : 0;
+ size = 4;
+ } else if (obj instanceof Integer) {
+ value = ((Integer)obj).longValue();
+ size = 4;
+ } else if (obj instanceof Long) {
+ value = ((Long)obj).longValue();
+ size = 8;
+ } else if (obj instanceof Float) {
+ value = ((Float)obj).longValue();
+ size = 4;
+ } else if (obj instanceof Double) {
+ value = ((Double)obj).longValue();
+ size = 8;
+ }
+ }
+
+ public long value;
+ public int size;
+ }
+ }
+
+ public static class Future {
+ Closure mClosure;
+ Script.FieldID mFieldID;
+ Object mValue;
+
+ Future(Closure closure, Script.FieldID fieldID, Object value) {
+ mClosure = closure;
+ mFieldID = fieldID;
+ mValue = value;
+ }
+
+ Closure getClosure() { return mClosure; }
+ Script.FieldID getFieldID() { return mFieldID; }
+ Object getValue() { return mValue; }
+ }
+
+ public static class UnboundValue {
+ // Either mFieldID or mArgIndex should be set but not both.
+ List<Pair<Closure, Script.FieldID>> mFieldID;
+ // -1 means unset. Legal values are 0 .. n-1, where n is the number of
+ // arguments for the referencing closure.
+ List<Pair<Closure, Integer>> mArgIndex;
+
+ UnboundValue() {
+ mFieldID = new ArrayList<Pair<Closure, Script.FieldID>>();
+ mArgIndex = new ArrayList<Pair<Closure, Integer>>();
+ }
+
+ void addReference(Closure closure, int index) {
+ mArgIndex.add(Pair.create(closure, Integer.valueOf(index)));
+ }
+
+ void addReference(Closure closure, Script.FieldID fieldID) {
+ mFieldID.add(Pair.create(closure, fieldID));
+ }
+
+ void set(Object value) {
+ for (Pair<Closure, Integer> p : mArgIndex) {
+ Closure closure = p.first;
+ int index = p.second.intValue();
+ closure.setArg(index, value);
+ }
+ for (Pair<Closure, Script.FieldID> p : mFieldID) {
+ Closure closure = p.first;
+ Script.FieldID fieldID = p.second;
+ closure.setGlobal(fieldID, value);
+ }
+ }
+ }
+
+ List<Closure> mClosures;
+ List<UnboundValue> mInputs;
+ Future[] mOutputs;
+
+ private static final String TAG = "ScriptGroup2";
+
+ public ScriptGroup2(long id, RenderScript rs) {
+ super(id, rs);
+ }
+
+ ScriptGroup2(RenderScript rs, List<Closure> closures,
+ List<UnboundValue> inputs, Future[] outputs) {
+ super(0, rs);
+ mClosures = closures;
+ mInputs = inputs;
+ mOutputs = outputs;
+
+ long[] closureIDs = new long[closures.size()];
+ for (int i = 0; i < closureIDs.length; i++) {
+ closureIDs[i] = closures.get(i).getID(rs);
+ }
+ long id = rs.nScriptGroup2Create(closureIDs);
+ setID(id);
+ }
+
+ // TODO: If this was reflected method, we could enforce the number of
+ // arguments.
+ public Object[] execute(Object... inputs) {
+ if (inputs.length < mInputs.size()) {
+ Log.e(TAG, this.toString() + " receives " + inputs.length + " inputs, " +
+ "less than expected " + mInputs.size());
+ return null;
+ }
+
+ if (inputs.length > mInputs.size()) {
+ Log.i(TAG, this.toString() + " receives " + inputs.length + " inputs, " +
+ "more than expected " + mInputs.size());
+ }
+
+ for (int i = 0; i < mInputs.size(); i++) {
+ Object obj = inputs[i];
+ if (obj instanceof Future || obj instanceof UnboundValue) {
+ Log.e(TAG, this.toString() + ": input " + i +
+ " is a future or unbound value");
+ return null;
+ }
+ UnboundValue unbound = mInputs.get(i);
+ unbound.set(obj);
+ }
+
+ mRS.nScriptGroup2Execute(getID(mRS));
+
+ Object[] outputObjs = new Object[mOutputs.length];
+ int i = 0;
+ for (Future f : mOutputs) {
+ outputObjs[i++] = f.getValue();
+ }
+ return outputObjs;
+ }
+
+ /**
+ @hide Pending Android public API approval.
+ */
+ public static final class Builder {
+ RenderScript mRS;
+ List<Closure> mClosures;
+ List<UnboundValue> mInputs;
+
+ private static final String TAG = "ScriptGroup2.Builder";
+
+ public Builder(RenderScript rs) {
+ mRS = rs;
+ mClosures = new ArrayList<Closure>();
+ mInputs = new ArrayList<UnboundValue>();
+ }
+
+ public Closure addKernel(Script.KernelID k, Type returnType, Object[] args,
+ Map<Script.FieldID, Object> globalBindings) {
+ Closure c = new Closure(mRS, k, returnType, args, globalBindings);
+ mClosures.add(c);
+ return c;
+ }
+
+ public UnboundValue addInput() {
+ UnboundValue unbound = new UnboundValue();
+ mInputs.add(unbound);
+ return unbound;
+ }
+
+ public ScriptGroup2 create(Future... outputs) {
+ // TODO: Save all script groups that have been created and return one that was
+ // saved and matches the outputs.
+ ScriptGroup2 ret = new ScriptGroup2(mRS, mClosures, mInputs, outputs);
+ return ret;
+ }
+
+ }
+}
diff --git a/rs/java/android/renderscript/ScriptIntrinsicResize.java b/rs/java/android/renderscript/ScriptIntrinsicResize.java
index d6764cc..cee4c33 100644
--- a/rs/java/android/renderscript/ScriptIntrinsicResize.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicResize.java
@@ -29,6 +29,8 @@ public final class ScriptIntrinsicResize extends ScriptIntrinsic {
/**
* Supported elements types are {@link Element#U8}, {@link
* Element#U8_2}, {@link Element#U8_3}, {@link Element#U8_4}
+ * {@link Element#F32}, {@link Element#F32_2}, {@link
+ * Element#F32_3}, {@link Element#F32_4}
*
* @param rs The RenderScript context
*
@@ -52,7 +54,11 @@ public final class ScriptIntrinsicResize extends ScriptIntrinsic {
if (!e.isCompatible(Element.U8(mRS)) &&
!e.isCompatible(Element.U8_2(mRS)) &&
!e.isCompatible(Element.U8_3(mRS)) &&
- !e.isCompatible(Element.U8_4(mRS))) {
+ !e.isCompatible(Element.U8_4(mRS)) &&
+ !e.isCompatible(Element.F32(mRS)) &&
+ !e.isCompatible(Element.F32_2(mRS)) &&
+ !e.isCompatible(Element.F32_3(mRS)) &&
+ !e.isCompatible(Element.F32_4(mRS))) {
throw new RSIllegalArgumentException("Unsuported element type.");
}