Implement named slots and convert script.addType to script.setType to remove ordering restrictions.
This commit is contained in:
@@ -20,6 +20,8 @@ package android.renderscript;
|
||||
* @hide
|
||||
**/
|
||||
public class Script extends BaseObj {
|
||||
public static final int MAX_SLOT = 16;
|
||||
|
||||
boolean mIsRoot;
|
||||
Type[] mTypes;
|
||||
|
||||
@@ -64,39 +66,36 @@ public class Script extends BaseObj {
|
||||
RenderScript mRS;
|
||||
boolean mIsRoot = false;
|
||||
Type[] mTypes;
|
||||
int mTypeCount;
|
||||
String[] mNames;
|
||||
|
||||
Builder(RenderScript rs) {
|
||||
mRS = rs;
|
||||
mTypes = new Type[4];
|
||||
mTypeCount = 0;
|
||||
mTypes = new Type[MAX_SLOT];
|
||||
mNames = new String[MAX_SLOT];
|
||||
}
|
||||
|
||||
public void addType(Type t) {
|
||||
if(mTypeCount >= mTypes.length) {
|
||||
Type[] nt = new Type[mTypeCount * 2];
|
||||
for(int ct=0; ct < mTypeCount; ct++) {
|
||||
nt[ct] = mTypes[ct];
|
||||
}
|
||||
mTypes = nt;
|
||||
}
|
||||
mTypes[mTypeCount] = t;
|
||||
mTypeCount++;
|
||||
public void setType(Type t, int slot) {
|
||||
mTypes[slot] = t;
|
||||
mNames[slot] = null;
|
||||
}
|
||||
|
||||
public void setType(Type t, String name, int slot) {
|
||||
mTypes[slot] = t;
|
||||
mNames[slot] = name;
|
||||
}
|
||||
|
||||
void transferCreate() {
|
||||
mRS.nScriptCSetRoot(mIsRoot);
|
||||
for(int ct=0; ct < mTypeCount; ct++) {
|
||||
mRS.nScriptCAddType(mTypes[ct].mID);
|
||||
mRS.nScriptSetRoot(mIsRoot);
|
||||
for(int ct=0; ct < mTypes.length; ct++) {
|
||||
if(mTypes[ct] != null) {
|
||||
mRS.nScriptSetType(mTypes[ct].mID, mNames[ct], ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void transferObject(Script s) {
|
||||
s.mIsRoot = mIsRoot;
|
||||
s.mTypes = new Type[mTypeCount];
|
||||
for(int ct=0; ct < mTypeCount; ct++) {
|
||||
s.mTypes[ct] = mTypes[ct];
|
||||
}
|
||||
s.mTypes = mTypes;
|
||||
}
|
||||
|
||||
public void setRoot(boolean r) {
|
||||
|
||||
Reference in New Issue
Block a user