diff options
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 12 | ||||
-rw-r--r-- | graphics/java/android/renderscript/BaseObj.java | 4 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Element.java | 50 | ||||
-rw-r--r-- | graphics/java/android/renderscript/FileA3D.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Font.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Light.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Mesh.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Program.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramRaster.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramStore.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScriptGL.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Sampler.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Script.java | 3 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Type.java | 5 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_types.rsh | 5 |
15 files changed, 51 insertions, 55 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 46f3eae..f1f673b 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -35,14 +35,12 @@ public class Allocation extends BaseObj { Bitmap mBitmap; Allocation(int id, RenderScript rs, Type t) { - super(rs); - mID = id; + super(id, rs); mType = t; } Allocation(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } @Override @@ -182,8 +180,7 @@ public class Allocation extends BaseObj { public class Adapter1D extends BaseObj { Adapter1D(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public void setConstraint(Dimension dim, int value) { @@ -225,8 +222,7 @@ public class Allocation extends BaseObj { public class Adapter2D extends BaseObj { Adapter2D(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public void setConstraint(Dimension dim, int value) { diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index 28675dc..5dce18f 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -24,10 +24,10 @@ import android.util.Log; **/ class BaseObj { - BaseObj(RenderScript rs) { + BaseObj(int id, RenderScript rs) { rs.validate(); mRS = rs; - mID = 0; + mID = id; mDestroyed = false; } diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 5d2a059..b811479 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -286,32 +286,27 @@ public class Element extends BaseObj { } - Element(RenderScript rs, Element[] e, String[] n) { - super(rs); + Element(int id, RenderScript rs, Element[] e, String[] n) { + super(id, rs); mSize = 0; mElements = e; mElementNames = n; - int[] ids = new int[mElements.length]; for (int ct = 0; ct < mElements.length; ct++ ) { mSize += mElements[ct].mSize; - ids[ct] = mElements[ct].mID; } - mID = rs.nElementCreate2(ids, mElementNames); } - Element(RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { - super(rs); + Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { + super(id, rs); mSize = dt.mSize * size; mType = dt; mKind = dk; mNormalized = norm; mVectorSize = size; - mID = rs.nElementCreate(dt.mID, dk.mID, norm, size); } - Element(RenderScript rs, int id) { - super(rs); - mID = id; + Element(int id, RenderScript rs) { + super(id, rs); } @Override @@ -320,9 +315,14 @@ public class Element extends BaseObj { // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements int[] dataBuffer = new int[5]; mRS.nElementGetNativeData(mID, dataBuffer); + + mNormalized = dataBuffer[2] == 1 ? true : false; + mVectorSize = dataBuffer[3]; + mSize = 0; for (DataType dt: DataType.values()) { if(dt.mID == dataBuffer[0]){ mType = dt; + mSize = mType.mSize * mVectorSize; } } for (DataKind dk: DataKind.values()) { @@ -331,8 +331,6 @@ public class Element extends BaseObj { } } - mNormalized = dataBuffer[2] == 1 ? true : false; - mVectorSize = dataBuffer[3]; int numSubElements = dataBuffer[4]; if(numSubElements > 0) { mElements = new Element[numSubElements]; @@ -341,8 +339,9 @@ public class Element extends BaseObj { 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] = new Element(subElementIds[i], mRS); mElements[i].updateFromNative(); + mSize += mElements[i].mSize; } } @@ -354,14 +353,21 @@ public class Element extends BaseObj { ///////////////////////////////////////// public static Element createUser(RenderScript rs, DataType dt) { - return new Element(rs, dt, DataKind.USER, false, 1); + DataKind dk = DataKind.USER; + boolean norm = false; + int vecSize = 1; + int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize); + return new Element(id, rs, dt, dk, norm, vecSize); } public static Element createVector(RenderScript rs, DataType dt, int size) { if (size < 2 || size > 4) { throw new IllegalArgumentException("Bad size"); } - return new Element(rs, dt, DataKind.USER, false, size); + DataKind dk = DataKind.USER; + boolean norm = false; + int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); + return new Element(id, rs, dt, dk, norm, size); } public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) { @@ -399,7 +405,9 @@ public class Element extends BaseObj { size = 4; } - return new Element(rs, dt, dk, true, size); + boolean norm = true; + int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); + return new Element(id, rs, dt, dk, norm, size); } public static class Builder { @@ -435,7 +443,13 @@ public class Element extends BaseObj { String[] sin = new String[mCount]; java.lang.System.arraycopy(mElements, 0, ein, 0, mCount); java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount); - return new Element(mRS, ein, sin); + + int[] ids = new int[ein.length]; + for (int ct = 0; ct < ein.length; ct++ ) { + ids[ct] = ein[ct].mID; + } + int id = mRS.nElementCreate2(ids, sin); + return new Element(id, mRS, ein, sin); } } diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index 302a5f4..2414062 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -146,8 +146,7 @@ public class FileA3D extends BaseObj { IndexEntry[] mFileEntries; FileA3D(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } private void initEntries() { diff --git a/graphics/java/android/renderscript/Font.java b/graphics/java/android/renderscript/Font.java index 41f8827..d79909e 100644 --- a/graphics/java/android/renderscript/Font.java +++ b/graphics/java/android/renderscript/Font.java @@ -31,8 +31,7 @@ import android.util.TypedValue; public class Font extends BaseObj { Font(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } static public Font create(RenderScript rs, Resources res, String fileName, int size) diff --git a/graphics/java/android/renderscript/Light.java b/graphics/java/android/renderscript/Light.java index aab656f..6212cae 100644 --- a/graphics/java/android/renderscript/Light.java +++ b/graphics/java/android/renderscript/Light.java @@ -25,8 +25,7 @@ import android.util.Log; **/ public class Light extends BaseObj { Light(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public void setColor(float r, float g, float b) { diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index bf02319..b74c1f8 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -32,8 +32,7 @@ public class Mesh extends BaseObj { Primitive[] mPrimitives; Mesh(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public int getVertexAllocationCount() { diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java index b16dac1..1628a97 100644 --- a/graphics/java/android/renderscript/Program.java +++ b/graphics/java/android/renderscript/Program.java @@ -38,8 +38,7 @@ public class Program extends BaseObj { String mShader; Program(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public void bindConstants(Allocation a, int slot) { diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/graphics/java/android/renderscript/ProgramRaster.java index 6fc9fff..08065cf 100644 --- a/graphics/java/android/renderscript/ProgramRaster.java +++ b/graphics/java/android/renderscript/ProgramRaster.java @@ -45,8 +45,7 @@ public class ProgramRaster extends BaseObj { CullMode mCullMode; ProgramRaster(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); mLineWidth = 1.0f; mPointSmooth = false; diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java index a92cbb6..cce4064 100644 --- a/graphics/java/android/renderscript/ProgramStore.java +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -76,8 +76,7 @@ public class ProgramStore extends BaseObj { ProgramStore(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java index e90b4fc..61ecc8d 100644 --- a/graphics/java/android/renderscript/RenderScriptGL.java +++ b/graphics/java/android/renderscript/RenderScriptGL.java @@ -102,8 +102,7 @@ public class RenderScriptGL extends RenderScript { public class File extends BaseObj { File(int id) { - super(RenderScriptGL.this); - mID = id; + super(id, RenderScriptGL.this); } } diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java index da83d04..60c6cf4 100644 --- a/graphics/java/android/renderscript/Sampler.java +++ b/graphics/java/android/renderscript/Sampler.java @@ -47,8 +47,7 @@ public class Sampler extends BaseObj { } Sampler(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } Sampler mSampler_CLAMP_NEAREST; diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index d9aec59..19c444c 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -56,8 +56,7 @@ public class Script extends BaseObj { Script(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); } public void bindAllocation(Allocation va, int slot) { diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index 8e45f2b..21053c9 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -97,8 +97,7 @@ public class Type extends BaseObj { Type(int id, RenderScript rs) { - super(rs); - mID = id; + super(id, rs); mNativeCache = 0; } @@ -125,7 +124,7 @@ public class Type extends BaseObj { int elementID = dataBuffer[5]; if(elementID != 0) { - mElement = new Element(mRS, elementID); + mElement = new Element(elementID, mRS); mElement.updateFromNative(); } calcElementCount(); diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh index ddae7eb..fd9ac16 100644 --- a/libs/rs/scriptc/rs_types.rsh +++ b/libs/rs/scriptc/rs_types.rsh @@ -67,10 +67,7 @@ typedef struct { float m[4]; } rs_matrix2x2; -typedef struct { - float w, x, y, z; -} rs_quaternion; - +typedef float4 rs_quaternion; #define RS_PACKED __attribute__((packed, aligned(4))) |