Loading graphics/java/android/renderscript/Allocation.java +35 −25 Original line number Diff line number Diff line Loading @@ -84,24 +84,38 @@ public class Allocation extends BaseObj { mRS.nAllocationUploadToBufferObject(getID()); } public void data(int[] d) { public void copyFrom(BaseObj[] d) { mRS.validate(); if (d.length != mType.getCount()) { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mType.getCount() + ", array length = " + d.length); } int i[] = new int[d.length]; for (int ct=0; ct < d.length; ct++) { i[ct] = d[ct].getID(); } subData1D(0, mType.getCount(), i); } public void copyFrom(int[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(short[] d) { public void copyFrom(short[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(byte[] d) { public void copyFrom(byte[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(float[] d) { public void copyFrom(float[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void updateFromBitmap(Bitmap b) { public void copyFrom(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || Loading Loading @@ -153,8 +167,8 @@ public class Allocation extends BaseObj { if(count < 1) { throw new RSIllegalArgumentException("Count must be >= 1."); } if((off + count) > mType.getElementCount()) { throw new RSIllegalArgumentException("Overflow, Available count " + mType.getElementCount() + if((off + count) > mType.getCount()) { throw new RSIllegalArgumentException("Overflow, Available count " + mType.getCount() + ", got " + count + " at offset " + off + "."); } if((len) < dataSize) { Loading Loading @@ -205,7 +219,7 @@ public class Allocation extends BaseObj { } public synchronized void resize(int dimX) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) { throw new RSInvalidStateException("Resize only support for 1D allocations at this time."); } mRS.nAllocationResize1D(getID(), dimX); Loading Loading @@ -340,7 +354,7 @@ public class Allocation extends BaseObj { rs.validate(); Type.Builder b = new Type.Builder(rs, e); b.add(Dimension.X, count); b.setX(count); Type t = b.create(); int id = rs.nAllocationCreateTyped(t.getID()); Loading Loading @@ -370,11 +384,9 @@ public class Allocation extends BaseObj { static private Type typeFromBitmap(RenderScript rs, Bitmap b, boolean mip) { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.add(Dimension.X, b.getWidth()); tb.add(Dimension.Y, b.getHeight()); if (mip) { tb.add(Dimension.LOD, 1); } tb.setX(b.getWidth()); tb.setY(b.getHeight()); tb.setMipmaps(mip); return tb.create(); } Loading Loading @@ -414,12 +426,10 @@ public class Allocation extends BaseObj { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.add(Dimension.X, width); tb.add(Dimension.Y, width); tb.add(Dimension.FACE, 1); if (genMips) { tb.add(Dimension.LOD, 1); } tb.setX(width); tb.setY(width); tb.setFaces(true); tb.setMipmaps(genMips); Type t = tb.create(); int id = rs.nAllocationCubeCreateFromBitmap(dstFmt.getID(), genMips, b); Loading Loading @@ -477,7 +487,7 @@ public class Allocation extends BaseObj { try { allocArray = str.getBytes("UTF-8"); Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length); alloc.data(allocArray); alloc.copyFrom(allocArray); return alloc; } catch (Exception e) { Loading graphics/java/android/renderscript/BaseObj.java +7 −1 Original line number Diff line number Diff line Loading @@ -48,13 +48,19 @@ class BaseObj { * * @return int */ public int getID() { int getID() { if (mDestroyed) { throw new RSInvalidStateException("using a destroyed object."); } return mID; } void checkValid() { if (mID == 0) { throw new RSIllegalArgumentException("Invalid object."); } } private int mID; private boolean mDestroyed; private String mName; Loading graphics/java/android/renderscript/Element.java +6 −9 Original line number Diff line number Diff line Loading @@ -477,10 +477,6 @@ public class Element extends BaseObj { } public void destroy() { super.destroy(); } /** * Create a custom Element of the specified DataType. The DataKind will be * set to USER and the vector size to 1 indicating non-vector. Loading @@ -489,7 +485,7 @@ public class Element extends BaseObj { * @param dt The DataType for the new element. * @return Element */ public static Element createUser(RenderScript rs, DataType dt) { static Element createUser(RenderScript rs, DataType dt) { DataKind dk = DataKind.USER; boolean norm = false; int vecSize = 1; Loading @@ -510,7 +506,7 @@ public class Element extends BaseObj { */ public static Element createVector(RenderScript rs, DataType dt, int size) { if (size < 2 || size > 4) { throw new RSIllegalArgumentException("Vector size out of rance 2-4."); throw new RSIllegalArgumentException("Vector size out of range 2-4."); } DataKind dk = DataKind.USER; boolean norm = false; Loading Loading @@ -603,7 +599,7 @@ public class Element extends BaseObj { * @param name * @param arraySize */ public void add(Element element, String name, int arraySize) { public Builder add(Element element, String name, int arraySize) { if (arraySize < 1) { throw new RSIllegalArgumentException("Array size cannot be less than 1."); } Loading @@ -622,6 +618,7 @@ public class Element extends BaseObj { mElementNames[mCount] = name; mArraySizes[mCount] = arraySize; mCount++; return this; } /** Loading @@ -630,8 +627,8 @@ public class Element extends BaseObj { * @param element * @param name */ public void add(Element element, String name) { add(element, name, 1); public Builder add(Element element, String name) { return add(element, name, 1); } /** Loading graphics/java/android/renderscript/Mesh.java +3 −3 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ public class Mesh extends BaseObj { Type newType(Element e, int size) { Type.Builder tb = new Type.Builder(mRS, e); tb.add(Dimension.X, size); tb.setX(size); return tb.create(); } Loading Loading @@ -466,12 +466,12 @@ public class Mesh extends BaseObj { Mesh sm = smb.create(); sm.getVertexAllocation(0).data(mVtxData); sm.getVertexAllocation(0).copyFrom(mVtxData); if(uploadToBufferObject) { sm.getVertexAllocation(0).uploadToBufferObject(); } sm.getIndexAllocation(0).data(mIndexData); sm.getIndexAllocation(0).copyFrom(mIndexData); sm.getIndexAllocation(0).uploadToBufferObject(); return sm; Loading graphics/java/android/renderscript/Program.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class Program extends BaseObj { if ((slot < 0) || (slot >= mTextureCount)) { throw new IllegalArgumentException("Slot ID out of range."); } if (va != null && va.getType().getFaces() && if (va != null && va.getType().hasFaces() && mTextures[slot] != TextureType.TEXTURE_CUBE) { throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot"); } Loading Loading
graphics/java/android/renderscript/Allocation.java +35 −25 Original line number Diff line number Diff line Loading @@ -84,24 +84,38 @@ public class Allocation extends BaseObj { mRS.nAllocationUploadToBufferObject(getID()); } public void data(int[] d) { public void copyFrom(BaseObj[] d) { mRS.validate(); if (d.length != mType.getCount()) { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mType.getCount() + ", array length = " + d.length); } int i[] = new int[d.length]; for (int ct=0; ct < d.length; ct++) { i[ct] = d[ct].getID(); } subData1D(0, mType.getCount(), i); } public void copyFrom(int[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(short[] d) { public void copyFrom(short[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(byte[] d) { public void copyFrom(byte[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void data(float[] d) { public void copyFrom(float[] d) { mRS.validate(); subData1D(0, mType.getElementCount(), d); subData1D(0, mType.getCount(), d); } public void updateFromBitmap(Bitmap b) { public void copyFrom(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || Loading Loading @@ -153,8 +167,8 @@ public class Allocation extends BaseObj { if(count < 1) { throw new RSIllegalArgumentException("Count must be >= 1."); } if((off + count) > mType.getElementCount()) { throw new RSIllegalArgumentException("Overflow, Available count " + mType.getElementCount() + if((off + count) > mType.getCount()) { throw new RSIllegalArgumentException("Overflow, Available count " + mType.getCount() + ", got " + count + " at offset " + off + "."); } if((len) < dataSize) { Loading Loading @@ -205,7 +219,7 @@ public class Allocation extends BaseObj { } public synchronized void resize(int dimX) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) { throw new RSInvalidStateException("Resize only support for 1D allocations at this time."); } mRS.nAllocationResize1D(getID(), dimX); Loading Loading @@ -340,7 +354,7 @@ public class Allocation extends BaseObj { rs.validate(); Type.Builder b = new Type.Builder(rs, e); b.add(Dimension.X, count); b.setX(count); Type t = b.create(); int id = rs.nAllocationCreateTyped(t.getID()); Loading Loading @@ -370,11 +384,9 @@ public class Allocation extends BaseObj { static private Type typeFromBitmap(RenderScript rs, Bitmap b, boolean mip) { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.add(Dimension.X, b.getWidth()); tb.add(Dimension.Y, b.getHeight()); if (mip) { tb.add(Dimension.LOD, 1); } tb.setX(b.getWidth()); tb.setY(b.getHeight()); tb.setMipmaps(mip); return tb.create(); } Loading Loading @@ -414,12 +426,10 @@ public class Allocation extends BaseObj { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.add(Dimension.X, width); tb.add(Dimension.Y, width); tb.add(Dimension.FACE, 1); if (genMips) { tb.add(Dimension.LOD, 1); } tb.setX(width); tb.setY(width); tb.setFaces(true); tb.setMipmaps(genMips); Type t = tb.create(); int id = rs.nAllocationCubeCreateFromBitmap(dstFmt.getID(), genMips, b); Loading Loading @@ -477,7 +487,7 @@ public class Allocation extends BaseObj { try { allocArray = str.getBytes("UTF-8"); Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length); alloc.data(allocArray); alloc.copyFrom(allocArray); return alloc; } catch (Exception e) { Loading
graphics/java/android/renderscript/BaseObj.java +7 −1 Original line number Diff line number Diff line Loading @@ -48,13 +48,19 @@ class BaseObj { * * @return int */ public int getID() { int getID() { if (mDestroyed) { throw new RSInvalidStateException("using a destroyed object."); } return mID; } void checkValid() { if (mID == 0) { throw new RSIllegalArgumentException("Invalid object."); } } private int mID; private boolean mDestroyed; private String mName; Loading
graphics/java/android/renderscript/Element.java +6 −9 Original line number Diff line number Diff line Loading @@ -477,10 +477,6 @@ public class Element extends BaseObj { } public void destroy() { super.destroy(); } /** * Create a custom Element of the specified DataType. The DataKind will be * set to USER and the vector size to 1 indicating non-vector. Loading @@ -489,7 +485,7 @@ public class Element extends BaseObj { * @param dt The DataType for the new element. * @return Element */ public static Element createUser(RenderScript rs, DataType dt) { static Element createUser(RenderScript rs, DataType dt) { DataKind dk = DataKind.USER; boolean norm = false; int vecSize = 1; Loading @@ -510,7 +506,7 @@ public class Element extends BaseObj { */ public static Element createVector(RenderScript rs, DataType dt, int size) { if (size < 2 || size > 4) { throw new RSIllegalArgumentException("Vector size out of rance 2-4."); throw new RSIllegalArgumentException("Vector size out of range 2-4."); } DataKind dk = DataKind.USER; boolean norm = false; Loading Loading @@ -603,7 +599,7 @@ public class Element extends BaseObj { * @param name * @param arraySize */ public void add(Element element, String name, int arraySize) { public Builder add(Element element, String name, int arraySize) { if (arraySize < 1) { throw new RSIllegalArgumentException("Array size cannot be less than 1."); } Loading @@ -622,6 +618,7 @@ public class Element extends BaseObj { mElementNames[mCount] = name; mArraySizes[mCount] = arraySize; mCount++; return this; } /** Loading @@ -630,8 +627,8 @@ public class Element extends BaseObj { * @param element * @param name */ public void add(Element element, String name) { add(element, name, 1); public Builder add(Element element, String name) { return add(element, name, 1); } /** Loading
graphics/java/android/renderscript/Mesh.java +3 −3 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ public class Mesh extends BaseObj { Type newType(Element e, int size) { Type.Builder tb = new Type.Builder(mRS, e); tb.add(Dimension.X, size); tb.setX(size); return tb.create(); } Loading Loading @@ -466,12 +466,12 @@ public class Mesh extends BaseObj { Mesh sm = smb.create(); sm.getVertexAllocation(0).data(mVtxData); sm.getVertexAllocation(0).copyFrom(mVtxData); if(uploadToBufferObject) { sm.getVertexAllocation(0).uploadToBufferObject(); } sm.getIndexAllocation(0).data(mIndexData); sm.getIndexAllocation(0).copyFrom(mIndexData); sm.getIndexAllocation(0).uploadToBufferObject(); return sm; Loading
graphics/java/android/renderscript/Program.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class Program extends BaseObj { if ((slot < 0) || (slot >= mTextureCount)) { throw new IllegalArgumentException("Slot ID out of range."); } if (va != null && va.getType().getFaces() && if (va != null && va.getType().hasFaces() && mTextures[slot] != TextureType.TEXTURE_CUBE) { throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot"); } Loading