Populate java objects with native data from a3d file.

Remove legacy constructor from programraster
Make a3d object creation synchronous

Change-Id: Ic7d7547cf6eee6f9a7c6e3ee12cd104e80056a7b
This commit is contained in:
Alex Sakhartchouk
2010-07-15 11:33:03 -07:00
parent 506821b406
commit dfac814c18
10 changed files with 236 additions and 21 deletions

View File

@@ -17,6 +17,7 @@
package android.renderscript;
import java.lang.reflect.Field;
import android.util.Log;
/**
* @hide
@@ -308,6 +309,45 @@ public class Element extends BaseObj {
mID = rs.nElementCreate(dt.mID, dk.mID, norm, size);
}
Element(RenderScript rs, int id) {
super(rs);
mID = id;
}
@Override
void updateFromNative() {
// we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
int[] dataBuffer = new int[5];
mRS.nElementGetNativeData(mID, dataBuffer);
for (DataType dt: DataType.values()) {
if(dt.mID == dataBuffer[0]){
mType = dt;
}
}
for (DataKind dk: DataKind.values()) {
if(dk.mID == dataBuffer[1]){
mKind = dk;
}
}
mNormalized = dataBuffer[2] == 1 ? true : false;
mVectorSize = dataBuffer[3];
int numSubElements = dataBuffer[4];
if(numSubElements > 0) {
mElements = new Element[numSubElements];
mElementNames = new String[numSubElements];
int[] subElementIds = new int[numSubElements];
mRS.nElementGetSubElements(mID, subElementIds, mElementNames);
for(int i = 0; i < numSubElements; i ++) {
mElements[i] = new Element(mRS, subElementIds[i]);
mElements[i].updateFromNative();
}
}
}
public void destroy() throws IllegalStateException {
super.destroy();
}