diff options
Diffstat (limited to 'graphics/java/android')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 10 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Element.java | 40 | ||||
-rw-r--r-- | graphics/java/android/renderscript/FileA3D.java | 32 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramRaster.java | 8 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 4 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Type.java | 23 |
6 files changed, 97 insertions, 20 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index bfa61f3..87735b5 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -45,6 +45,16 @@ public class Allocation extends BaseObj { mID = id; } + @Override + void updateFromNative() { + mRS.validate(); + int typeID = mRS.nAllocationGetType(mID); + if(typeID != 0) { + mType = new Type(typeID, mRS); + mType.updateFromNative(); + } + } + public Type getType() { return mType; } diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 308d663..5d2a059 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -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(); } diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index 3b3711b..302a5f4 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -56,7 +56,7 @@ public class FileA3D extends BaseObj { } // Read only class with index entries - public class IndexEntry { + public static class IndexEntry { RenderScript mRS; int mIndex; int mID; @@ -73,34 +73,40 @@ public class FileA3D extends BaseObj { } public BaseObj getObject() { - if(mLoadedObj != null) { - return mLoadedObj; + mRS.validate(); + BaseObj obj = internalCreate(mRS, this); + return obj; + } + + static synchronized BaseObj internalCreate(RenderScript rs, IndexEntry entry) { + if(entry.mLoadedObj != null) { + return entry.mLoadedObj; } - if(mClassID == ClassID.UNKNOWN) { + if(entry.mClassID == ClassID.UNKNOWN) { return null; } - int objectID = mRS.nFileA3DGetEntryByIndex(mID, mIndex); + int objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex); if(objectID == 0) { return null; } - switch (mClassID) { + switch (entry.mClassID) { case MESH: - mLoadedObj = new Mesh(objectID, mRS); + entry.mLoadedObj = new Mesh(objectID, rs); break; case TYPE: - mLoadedObj = new Type(objectID, mRS); + entry.mLoadedObj = new Type(objectID, rs); break; case ELEMENT: - mLoadedObj = null; + entry.mLoadedObj = null; break; case ALLOCATION: - mLoadedObj = null; + entry.mLoadedObj = null; break; case PROGRAM_VERTEX: - mLoadedObj = new ProgramVertex(objectID, mRS); + entry.mLoadedObj = new ProgramVertex(objectID, rs); break; case PROGRAM_RASTER: break; @@ -122,7 +128,9 @@ public class FileA3D extends BaseObj { break; } - return mLoadedObj; + entry.mLoadedObj.updateFromNative(); + + return entry.mLoadedObj; } IndexEntry(RenderScript rs, int index, int id, String name, ClassID classID) { diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/graphics/java/android/renderscript/ProgramRaster.java index 55e6586..6fc9fff 100644 --- a/graphics/java/android/renderscript/ProgramRaster.java +++ b/graphics/java/android/renderscript/ProgramRaster.java @@ -74,14 +74,6 @@ public class ProgramRaster extends BaseObj { boolean mPointSmooth; boolean mLineSmooth; - // Legacy to not break app in other projects, will be removed in cleanup pass - public Builder(RenderScript rs, Element in, Element out) { - mRS = rs; - mPointSmooth = false; - mLineSmooth = false; - mPointSprite = false; - } - public Builder(RenderScript rs) { mRS = rs; mPointSmooth = false; diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 240d544..1135a75 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -90,12 +90,15 @@ public class RenderScript { native int nElementCreate(int type, int kind, boolean norm, int vecSize); native int nElementCreate2(int[] elements, String[] names); + native void nElementGetNativeData(int id, int[] elementData); + native void nElementGetSubElements(int id, int[] IDs, String[] names); native void nTypeBegin(int elementID); native void nTypeAdd(int dim, int val); native int nTypeCreate(); native void nTypeFinalDestroy(Type t); native void nTypeSetupFields(Type t, int[] types, int[] bits, Field[] IDs); + native void nTypeGetNativeData(int id, int[] typeData); native int nAllocationCreateTyped(int type); native int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp); @@ -117,6 +120,7 @@ public class RenderScript { native void nAllocationRead(int id, float[] d); native void nAllocationSubDataFromObject(int id, Type t, int offset, Object o); native void nAllocationSubReadFromObject(int id, Type t, int offset, Object o); + native int nAllocationGetType(int id); native int nFileA3DCreateFromAssetStream(int assetStream); native int nFileA3DGetNumIndexEntries(int fileA3D); diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index 14422b2..8e45f2b 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -16,7 +16,9 @@ package android.renderscript; + import java.lang.reflect.Field; +import android.util.Log; /** * @hide @@ -108,6 +110,27 @@ public class Type extends BaseObj { super.finalize(); } + @Override + void updateFromNative() { + // We have 6 integer to obtain mDimX; mDimY; mDimZ; + // mDimLOD; mDimFaces; mElement; + int[] dataBuffer = new int[6]; + mRS.nTypeGetNativeData(mID, dataBuffer); + + mDimX = dataBuffer[0]; + mDimY = dataBuffer[1]; + mDimZ = dataBuffer[2]; + mDimLOD = dataBuffer[3] == 1 ? true : false; + mDimFaces = dataBuffer[4] == 1 ? true : false; + + int elementID = dataBuffer[5]; + if(elementID != 0) { + mElement = new Element(mRS, elementID); + mElement.updateFromNative(); + } + calcElementCount(); + } + public static Type createFromClass(RenderScript rs, Class c, int size, String scriptName) { android.util.Log.e("RenderScript", "Calling depricated createFromClass"); return null; |