Loading graphics/java/android/renderscript/FieldPacker.java +0 −21 Original line number Diff line number Diff line Loading @@ -248,27 +248,6 @@ public class FieldPacker { addU32(v.w); } // to be removed on cleanup public void addObj(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } // to be removed on cleanup public void addObj(Matrix3f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } // to be removed on cleanup public void addObj(Matrix2f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } public void addMatrix(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); Loading graphics/java/android/renderscript/Matrix2f.java +1 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ public class Matrix2f { } public void load(Matrix2f src) { System.arraycopy(mMat, 0, src, 0, 4); System.arraycopy(mMat, 0, src.getArray(), 0, 4); } public void loadRotate(float rot) { Loading graphics/java/android/renderscript/Matrix3f.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class Matrix3f { } public void load(Matrix3f src) { System.arraycopy(mMat, 0, src, 0, 9); System.arraycopy(mMat, 0, src.getArray(), 0, 9); } public void loadRotate(float rot, float x, float y, float z) { Loading graphics/java/android/renderscript/Matrix4f.java +27 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class Matrix4f { } public void load(Matrix4f src) { System.arraycopy(mMat, 0, src, 0, 16); System.arraycopy(mMat, 0, src.getArray(), 0, 16); } public void loadRotate(float rot, float x, float y, float z) { Loading Loading @@ -180,6 +180,32 @@ public class Matrix4f { loadFrustum(left, right, bottom, top, near, far); } public void loadProjectionNormalized(int w, int h) { // range -1,1 in the narrow axis at z = 0. Matrix4f m1 = new Matrix4f(); Matrix4f m2 = new Matrix4f(); if(w > h) { float aspect = ((float)w) / h; m1.loadFrustum(-aspect,aspect, -1,1, 1,100); } else { float aspect = ((float)h) / w; m1.loadFrustum(-1,1, -aspect,aspect, 1,100); } m2.loadRotate(180, 0, 1, 0); m1.loadMultiply(m1, m2); m2.loadScale(-2, 2, 1); m1.loadMultiply(m1, m2); m2.loadTranslate(0, 0, 2); m1.loadMultiply(m1, m2); load(m1); } public void multiply(Matrix4f rhs) { Matrix4f tmp = new Matrix4f(); tmp.loadMultiply(this, rhs); Loading graphics/java/android/renderscript/Mesh.java +62 −34 Original line number Diff line number Diff line Loading @@ -27,6 +27,20 @@ import android.util.Log; **/ public class Mesh extends BaseObj { public enum Primitive { POINT (0), LINE (1), LINE_STRIP (2), TRIANGLE (3), TRIANGLE_STRIP (4), TRIANGLE_FAN (5); int mID; Primitive(int id) { mID = id; } } Allocation[] mVertexBuffers; Allocation[] mIndexBuffers; Primitive[] mPrimitives; Loading @@ -51,7 +65,7 @@ public class Mesh extends BaseObj { } return mIndexBuffers.length; } public Allocation getIndexAllocation(int slot) { public Allocation getIndexSetAllocation(int slot) { return mIndexBuffers[slot]; } public Primitive getPrimitive(int slot) { Loading Loading @@ -115,64 +129,67 @@ public class Mesh extends BaseObj { mIndexTypes = new Vector(); } public int addVertexType(Type t) throws IllegalStateException { public int getCurrentVertexTypeIndex() { return mVertexTypeCount - 1; } public int getCurrentIndexSetIndex() { return mIndexTypes.size() - 1; } public Builder addVertexType(Type t) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].t = t; mVertexTypes[mVertexTypeCount].e = null; mVertexTypeCount++; return addedIndex; return this; } public int addVertexType(Element e, int size) throws IllegalStateException { public Builder addVertexType(Element e, int size) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].t = null; mVertexTypes[mVertexTypeCount].e = e; mVertexTypes[mVertexTypeCount].size = size; mVertexTypeCount++; return addedIndex; return this; } public int addIndexType(Type t, Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Type t, Primitive p) { Entry indexType = new Entry(); indexType.t = t; indexType.e = null; indexType.size = 0; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Primitive p) { Entry indexType = new Entry(); indexType.t = null; indexType.e = null; indexType.size = 0; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Element e, int size, Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Element e, int size, Primitive p) { Entry indexType = new Entry(); indexType.t = null; indexType.e = e; indexType.size = size; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } Type newType(Element e, int size) { Loading Loading @@ -247,34 +264,39 @@ public class Mesh extends BaseObj { mIndexTypes = new Vector(); } public int addVertexAllocation(Allocation a) throws IllegalStateException { public int getCurrentVertexTypeIndex() { return mVertexTypeCount - 1; } public int getCurrentIndexSetIndex() { return mIndexTypes.size() - 1; } public AllocationBuilder addVertexAllocation(Allocation a) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].a = a; mVertexTypeCount++; return addedIndex; return this; } public int addIndexAllocation(Allocation a, Primitive p) { int addedIndex = mIndexTypes.size(); public AllocationBuilder addIndexSetAllocation(Allocation a, Primitive p) { Entry indexType = new Entry(); indexType.a = a; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Primitive p) { int addedIndex = mIndexTypes.size(); public AllocationBuilder addIndexSetType(Primitive p) { Entry indexType = new Entry(); indexType.a = null; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } static synchronized Mesh internalCreate(RenderScript rs, AllocationBuilder b) { Loading Loading @@ -379,7 +401,7 @@ public class Mesh extends BaseObj { } } public void addVertex(float x, float y) { public TriangleMeshBuilder addVertex(float x, float y) { if (mVtxSize != 2) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -387,9 +409,10 @@ public class Mesh extends BaseObj { mVtxData[mVtxCount++] = x; mVtxData[mVtxCount++] = y; latch(); return this; } public void addVertex(float x, float y, float z) { public TriangleMeshBuilder addVertex(float x, float y, float z) { if (mVtxSize != 3) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -398,26 +421,29 @@ public class Mesh extends BaseObj { mVtxData[mVtxCount++] = y; mVtxData[mVtxCount++] = z; latch(); return this; } public void setTexture(float s, float t) { public TriangleMeshBuilder setTexture(float s, float t) { if ((mFlags & TEXTURE_0) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } mS0 = s; mT0 = t; return this; } public void setNormal(float x, float y, float z) { public TriangleMeshBuilder setNormal(float x, float y, float z) { if ((mFlags & NORMAL) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } mNX = x; mNY = y; mNZ = z; return this; } public void setColor(float r, float g, float b, float a) { public TriangleMeshBuilder setColor(float r, float g, float b, float a) { if ((mFlags & COLOR) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -425,9 +451,10 @@ public class Mesh extends BaseObj { mG = g; mB = b; mA = a; return this; } public void addTriangle(int idx1, int idx2, int idx3) { public TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3) { if((idx1 >= mVtxCount) || (idx1 < 0) || (idx2 >= mVtxCount) || (idx2 < 0) || (idx3 >= mVtxCount) || (idx3 < 0)) { Loading @@ -441,6 +468,7 @@ public class Mesh extends BaseObj { mIndexData[mIndexCount++] = (short)idx1; mIndexData[mIndexCount++] = (short)idx2; mIndexData[mIndexCount++] = (short)idx3; return this; } public Mesh create(boolean uploadToBufferObject) { Loading Loading @@ -470,7 +498,7 @@ public class Mesh extends BaseObj { Builder smb = new Builder(mRS, usage); smb.addVertexType(mElement, mVtxCount / floatCount); smb.addIndexType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE); smb.addIndexSetType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE); Mesh sm = smb.create(); Loading @@ -481,9 +509,9 @@ public class Mesh extends BaseObj { } } sm.getIndexAllocation(0).copyFrom(mIndexData); sm.getIndexSetAllocation(0).copyFrom(mIndexData); if (uploadToBufferObject) { sm.getIndexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } return sm; Loading Loading
graphics/java/android/renderscript/FieldPacker.java +0 −21 Original line number Diff line number Diff line Loading @@ -248,27 +248,6 @@ public class FieldPacker { addU32(v.w); } // to be removed on cleanup public void addObj(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } // to be removed on cleanup public void addObj(Matrix3f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } // to be removed on cleanup public void addObj(Matrix2f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); } } public void addMatrix(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[i]); Loading
graphics/java/android/renderscript/Matrix2f.java +1 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ public class Matrix2f { } public void load(Matrix2f src) { System.arraycopy(mMat, 0, src, 0, 4); System.arraycopy(mMat, 0, src.getArray(), 0, 4); } public void loadRotate(float rot) { Loading
graphics/java/android/renderscript/Matrix3f.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class Matrix3f { } public void load(Matrix3f src) { System.arraycopy(mMat, 0, src, 0, 9); System.arraycopy(mMat, 0, src.getArray(), 0, 9); } public void loadRotate(float rot, float x, float y, float z) { Loading
graphics/java/android/renderscript/Matrix4f.java +27 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class Matrix4f { } public void load(Matrix4f src) { System.arraycopy(mMat, 0, src, 0, 16); System.arraycopy(mMat, 0, src.getArray(), 0, 16); } public void loadRotate(float rot, float x, float y, float z) { Loading Loading @@ -180,6 +180,32 @@ public class Matrix4f { loadFrustum(left, right, bottom, top, near, far); } public void loadProjectionNormalized(int w, int h) { // range -1,1 in the narrow axis at z = 0. Matrix4f m1 = new Matrix4f(); Matrix4f m2 = new Matrix4f(); if(w > h) { float aspect = ((float)w) / h; m1.loadFrustum(-aspect,aspect, -1,1, 1,100); } else { float aspect = ((float)h) / w; m1.loadFrustum(-1,1, -aspect,aspect, 1,100); } m2.loadRotate(180, 0, 1, 0); m1.loadMultiply(m1, m2); m2.loadScale(-2, 2, 1); m1.loadMultiply(m1, m2); m2.loadTranslate(0, 0, 2); m1.loadMultiply(m1, m2); load(m1); } public void multiply(Matrix4f rhs) { Matrix4f tmp = new Matrix4f(); tmp.loadMultiply(this, rhs); Loading
graphics/java/android/renderscript/Mesh.java +62 −34 Original line number Diff line number Diff line Loading @@ -27,6 +27,20 @@ import android.util.Log; **/ public class Mesh extends BaseObj { public enum Primitive { POINT (0), LINE (1), LINE_STRIP (2), TRIANGLE (3), TRIANGLE_STRIP (4), TRIANGLE_FAN (5); int mID; Primitive(int id) { mID = id; } } Allocation[] mVertexBuffers; Allocation[] mIndexBuffers; Primitive[] mPrimitives; Loading @@ -51,7 +65,7 @@ public class Mesh extends BaseObj { } return mIndexBuffers.length; } public Allocation getIndexAllocation(int slot) { public Allocation getIndexSetAllocation(int slot) { return mIndexBuffers[slot]; } public Primitive getPrimitive(int slot) { Loading Loading @@ -115,64 +129,67 @@ public class Mesh extends BaseObj { mIndexTypes = new Vector(); } public int addVertexType(Type t) throws IllegalStateException { public int getCurrentVertexTypeIndex() { return mVertexTypeCount - 1; } public int getCurrentIndexSetIndex() { return mIndexTypes.size() - 1; } public Builder addVertexType(Type t) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].t = t; mVertexTypes[mVertexTypeCount].e = null; mVertexTypeCount++; return addedIndex; return this; } public int addVertexType(Element e, int size) throws IllegalStateException { public Builder addVertexType(Element e, int size) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].t = null; mVertexTypes[mVertexTypeCount].e = e; mVertexTypes[mVertexTypeCount].size = size; mVertexTypeCount++; return addedIndex; return this; } public int addIndexType(Type t, Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Type t, Primitive p) { Entry indexType = new Entry(); indexType.t = t; indexType.e = null; indexType.size = 0; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Primitive p) { Entry indexType = new Entry(); indexType.t = null; indexType.e = null; indexType.size = 0; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Element e, int size, Primitive p) { int addedIndex = mIndexTypes.size(); public Builder addIndexSetType(Element e, int size, Primitive p) { Entry indexType = new Entry(); indexType.t = null; indexType.e = e; indexType.size = size; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } Type newType(Element e, int size) { Loading Loading @@ -247,34 +264,39 @@ public class Mesh extends BaseObj { mIndexTypes = new Vector(); } public int addVertexAllocation(Allocation a) throws IllegalStateException { public int getCurrentVertexTypeIndex() { return mVertexTypeCount - 1; } public int getCurrentIndexSetIndex() { return mIndexTypes.size() - 1; } public AllocationBuilder addVertexAllocation(Allocation a) throws IllegalStateException { if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } int addedIndex = mVertexTypeCount; mVertexTypes[mVertexTypeCount] = new Entry(); mVertexTypes[mVertexTypeCount].a = a; mVertexTypeCount++; return addedIndex; return this; } public int addIndexAllocation(Allocation a, Primitive p) { int addedIndex = mIndexTypes.size(); public AllocationBuilder addIndexSetAllocation(Allocation a, Primitive p) { Entry indexType = new Entry(); indexType.a = a; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } public int addIndexType(Primitive p) { int addedIndex = mIndexTypes.size(); public AllocationBuilder addIndexSetType(Primitive p) { Entry indexType = new Entry(); indexType.a = null; indexType.prim = p; mIndexTypes.addElement(indexType); return addedIndex; return this; } static synchronized Mesh internalCreate(RenderScript rs, AllocationBuilder b) { Loading Loading @@ -379,7 +401,7 @@ public class Mesh extends BaseObj { } } public void addVertex(float x, float y) { public TriangleMeshBuilder addVertex(float x, float y) { if (mVtxSize != 2) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -387,9 +409,10 @@ public class Mesh extends BaseObj { mVtxData[mVtxCount++] = x; mVtxData[mVtxCount++] = y; latch(); return this; } public void addVertex(float x, float y, float z) { public TriangleMeshBuilder addVertex(float x, float y, float z) { if (mVtxSize != 3) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -398,26 +421,29 @@ public class Mesh extends BaseObj { mVtxData[mVtxCount++] = y; mVtxData[mVtxCount++] = z; latch(); return this; } public void setTexture(float s, float t) { public TriangleMeshBuilder setTexture(float s, float t) { if ((mFlags & TEXTURE_0) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } mS0 = s; mT0 = t; return this; } public void setNormal(float x, float y, float z) { public TriangleMeshBuilder setNormal(float x, float y, float z) { if ((mFlags & NORMAL) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } mNX = x; mNY = y; mNZ = z; return this; } public void setColor(float r, float g, float b, float a) { public TriangleMeshBuilder setColor(float r, float g, float b, float a) { if ((mFlags & COLOR) == 0) { throw new IllegalStateException("add mistmatch with declared components."); } Loading @@ -425,9 +451,10 @@ public class Mesh extends BaseObj { mG = g; mB = b; mA = a; return this; } public void addTriangle(int idx1, int idx2, int idx3) { public TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3) { if((idx1 >= mVtxCount) || (idx1 < 0) || (idx2 >= mVtxCount) || (idx2 < 0) || (idx3 >= mVtxCount) || (idx3 < 0)) { Loading @@ -441,6 +468,7 @@ public class Mesh extends BaseObj { mIndexData[mIndexCount++] = (short)idx1; mIndexData[mIndexCount++] = (short)idx2; mIndexData[mIndexCount++] = (short)idx3; return this; } public Mesh create(boolean uploadToBufferObject) { Loading Loading @@ -470,7 +498,7 @@ public class Mesh extends BaseObj { Builder smb = new Builder(mRS, usage); smb.addVertexType(mElement, mVtxCount / floatCount); smb.addIndexType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE); smb.addIndexSetType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE); Mesh sm = smb.create(); Loading @@ -481,9 +509,9 @@ public class Mesh extends BaseObj { } } sm.getIndexAllocation(0).copyFrom(mIndexData); sm.getIndexSetAllocation(0).copyFrom(mIndexData); if (uploadToBufferObject) { sm.getIndexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } return sm; Loading