Balls test app.
Change-Id: I842f43e37145f8112120e2bd49925f81c588c40c
This commit is contained in:
@@ -76,78 +76,5 @@ public class ScriptC extends Script {
|
||||
rs.nScriptCSetScript(pgm, 0, pgmLength);
|
||||
return rs.nScriptCCreate();
|
||||
}
|
||||
|
||||
public static class Builder extends Script.Builder {
|
||||
byte[] mProgram;
|
||||
int mProgramLength;
|
||||
|
||||
public Builder(RenderScript rs) {
|
||||
super(rs);
|
||||
}
|
||||
|
||||
public void setScript(String s) {
|
||||
try {
|
||||
mProgram = s.getBytes("UTF-8");
|
||||
mProgramLength = mProgram.length;
|
||||
} catch (java.io.UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setScript(Resources resources, int id) {
|
||||
InputStream is = resources.openRawResource(id);
|
||||
try {
|
||||
try {
|
||||
setScript(is);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
throw new Resources.NotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
public void setScript(InputStream is) throws IOException {
|
||||
byte[] buf = new byte[1024];
|
||||
int currentPos = 0;
|
||||
while(true) {
|
||||
int bytesLeft = buf.length - currentPos;
|
||||
if (bytesLeft == 0) {
|
||||
byte[] buf2 = new byte[buf.length * 2];
|
||||
System.arraycopy(buf, 0, buf2, 0, buf.length);
|
||||
buf = buf2;
|
||||
bytesLeft = buf.length - currentPos;
|
||||
}
|
||||
int bytesRead = is.read(buf, currentPos, bytesLeft);
|
||||
if (bytesRead <= 0) {
|
||||
break;
|
||||
}
|
||||
currentPos += bytesRead;
|
||||
}
|
||||
mProgram = buf;
|
||||
mProgramLength = currentPos;
|
||||
}
|
||||
|
||||
static synchronized ScriptC internalCreate(Builder b) {
|
||||
b.mRS.nScriptCBegin();
|
||||
|
||||
android.util.Log.e("rs", "len = " + b.mProgramLength);
|
||||
b.mRS.nScriptCSetScript(b.mProgram, 0, b.mProgramLength);
|
||||
|
||||
int id = b.mRS.nScriptCCreate();
|
||||
ScriptC obj = new ScriptC(id, b.mRS);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void addDefine(String name, int value) {}
|
||||
public void addDefine(String name, float value) {}
|
||||
public void addDefines(Class cl) {}
|
||||
public void addDefines(Object o) {}
|
||||
void addDefines(Field[] fields, int mask, Object o) {}
|
||||
|
||||
public ScriptC create() {
|
||||
return internalCreate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user