summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/renderscript/Script.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/renderscript/Script.java')
-rw-r--r--graphics/java/android/renderscript/Script.java114
1 files changed, 57 insertions, 57 deletions
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index 57ccfa3..d9aec59 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -42,6 +42,19 @@ public class Script extends BaseObj {
}
}
+ protected void invoke(int slot) {
+ mRS.nScriptInvoke(mID, slot);
+ }
+
+ protected void invoke(int slot, FieldPacker v) {
+ if (v != null) {
+ mRS.nScriptInvokeV(mID, slot, v.getData());
+ } else {
+ mRS.nScriptInvoke(mID, slot);
+ }
+ }
+
+
Script(int id, RenderScript rs) {
super(rs);
mID = id;
@@ -49,22 +62,27 @@ public class Script extends BaseObj {
public void bindAllocation(Allocation va, int slot) {
mRS.validate();
- mRS.nScriptBindAllocation(mID, va.mID, slot);
+ if (va != null) {
+ mRS.nScriptBindAllocation(mID, va.mID, slot);
+ } else {
+ mRS.nScriptBindAllocation(mID, 0, slot);
+ }
}
- public void setClearColor(float r, float g, float b, float a) {
- mRS.validate();
- mRS.nScriptSetClearColor(mID, r, g, b, a);
+ public void setVar(int index, float v) {
+ mRS.nScriptSetVarF(mID, index, v);
}
- public void setClearDepth(float d) {
- mRS.validate();
- mRS.nScriptSetClearDepth(mID, d);
+ public void setVar(int index, int v) {
+ mRS.nScriptSetVarI(mID, index, v);
}
- public void setClearStencil(int stencil) {
- mRS.validate();
- mRS.nScriptSetClearStencil(mID, stencil);
+ public void setVar(int index, boolean v) {
+ mRS.nScriptSetVarI(mID, index, v ? 1 : 0);
+ }
+
+ public void setVar(int index, FieldPacker v) {
+ mRS.nScriptSetVarV(mID, index, v.getData());
}
public void setTimeZone(String timeZone) {
@@ -78,72 +96,54 @@ public class Script extends BaseObj {
public static class Builder {
RenderScript mRS;
- boolean mIsRoot = false;
- Type[] mTypes;
- String[] mNames;
- boolean[] mWritable;
- int mInvokableCount = 0;
- Invokable[] mInvokables;
Builder(RenderScript rs) {
mRS = rs;
- mTypes = new Type[MAX_SLOT];
- mNames = new String[MAX_SLOT];
- mWritable = new boolean[MAX_SLOT];
- mInvokables = new Invokable[MAX_SLOT];
}
+ }
+
+
+ public static class FieldBase {
+ protected Element mElement;
+ protected Type mType;
+ protected Allocation mAllocation;
- public void setType(Type t, int slot) {
- mTypes[slot] = t;
- mNames[slot] = null;
+ protected void init(RenderScript rs, int dimx) {
+ mAllocation = Allocation.createSized(rs, mElement, dimx);
+ mType = mAllocation.getType();
}
- public void setType(Type t, String name, int slot) {
- mTypes[slot] = t;
- mNames[slot] = name;
+ protected FieldBase() {
}
- public Invokable addInvokable(String func) {
- Invokable i = new Invokable();
- i.mName = func;
- i.mRS = mRS;
- i.mSlot = mInvokableCount;
- mInvokables[mInvokableCount++] = i;
- return i;
+ public Element getElement() {
+ return mElement;
}
- public void setType(boolean writable, int slot) {
- mWritable[slot] = writable;
+ public Type getType() {
+ return mType;
}
- void transferCreate() {
- mRS.nScriptSetRoot(mIsRoot);
- for(int ct=0; ct < mTypes.length; ct++) {
- if(mTypes[ct] != null) {
- mRS.nScriptSetType(mTypes[ct].mID, mWritable[ct], mNames[ct], ct);
- }
- }
- for(int ct=0; ct < mInvokableCount; ct++) {
- mRS.nScriptSetInvokable(mInvokables[ct].mName, ct);
- }
+ public Allocation getAllocation() {
+ return mAllocation;
}
- void transferObject(Script s) {
- s.mIsRoot = mIsRoot;
- s.mTypes = mTypes;
- s.mInvokables = new Invokable[mInvokableCount];
- for(int ct=0; ct < mInvokableCount; ct++) {
- s.mInvokables[ct] = mInvokables[ct];
- s.mInvokables[ct].mScript = s;
- }
- s.mInvokables = null;
+ //@Override
+ public void updateAllocation() {
}
- public void setRoot(boolean r) {
- mIsRoot = r;
+
+ //
+ /*
+ public class ScriptField_UserField
+ extends android.renderscript.Script.FieldBase {
+
+ protected
+
}
- }
+ */
+ }
}