Loading graphics/java/android/renderscript/Allocation.java +78 −5 Original line number Diff line number Diff line Loading @@ -121,6 +121,58 @@ public class Allocation extends BaseObj { mType = t; } private void validateIsInt32() { if ((mType.mElement.mType == Element.DataType.SIGNED_32) || (mType.mElement.mType == Element.DataType.UNSIGNED_32)) { return; } throw new RSIllegalArgumentException( "32 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsInt16() { if ((mType.mElement.mType == Element.DataType.SIGNED_16) || (mType.mElement.mType == Element.DataType.UNSIGNED_16)) { return; } throw new RSIllegalArgumentException( "16 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsInt8() { if ((mType.mElement.mType == Element.DataType.SIGNED_8) || (mType.mElement.mType == Element.DataType.UNSIGNED_8)) { return; } throw new RSIllegalArgumentException( "8 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsFloat32() { if (mType.mElement.mType == Element.DataType.FLOAT_32) { return; } throw new RSIllegalArgumentException( "32 bit float source does not match allocation type " + mType.mElement.mType); } private void validateIsObject() { if ((mType.mElement.mType == Element.DataType.RS_ELEMENT) || (mType.mElement.mType == Element.DataType.RS_TYPE) || (mType.mElement.mType == Element.DataType.RS_ALLOCATION) || (mType.mElement.mType == Element.DataType.RS_SAMPLER) || (mType.mElement.mType == Element.DataType.RS_SCRIPT) || (mType.mElement.mType == Element.DataType.RS_MESH) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_FRAGMENT) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_VERTEX) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_RASTER) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_STORE)) { return; } throw new RSIllegalArgumentException( "Object source does not match allocation type " + mType.mElement.mType); } @Override void updateFromNative() { super.updateFromNative(); Loading Loading @@ -151,6 +203,7 @@ public class Allocation extends BaseObj { public void copyFrom(BaseObj[] d) { mRS.validate(); validateIsObject(); if (d.length != mType.getCount()) { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mType.getCount() + ", array length = " + d.length); Loading Loading @@ -258,7 +311,6 @@ public class Allocation extends BaseObj { mRS.nAllocationData1D(getID(), xoff, 0, count, data, data.length); } /** * This is only intended to be used by auto-generate code reflected from the * renderscript script files. Loading Loading @@ -317,27 +369,44 @@ public class Allocation extends BaseObj { mRS.nAllocationGenerateMipmaps(getID()); } public void copy1DRangeFrom(int off, int count, int[] d) { void copy1DRangeFromUnchecked(int off, int count, int[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, short[] d) { void copy1DRangeFromUnchecked(int off, int count, short[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 2, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, byte[] d) { void copy1DRangeFromUnchecked(int off, int count, byte[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, float[] d) { void copy1DRangeFromUnchecked(int off, int count, float[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, int[] d) { validateIsInt32(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, short[] d) { validateIsInt16(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, byte[] d) { validateIsInt8(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, float[] d) { validateIsFloat32(); copy1DRangeFromUnchecked(off, count, d); } private void validate2DRange(int xoff, int yoff, int w, int h) { if (xoff < 0 || yoff < 0) { throw new RSIllegalArgumentException("Offset cannot be negative."); Loading Loading @@ -411,21 +480,25 @@ public class Allocation extends BaseObj { } public void copyTo(byte[] d) { validateIsInt8(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(short[] d) { validateIsInt16(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(int[] d) { validateIsInt32(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(float[] d) { validateIsFloat32(); mRS.validate(); mRS.nAllocationRead(getID(), d); } Loading graphics/java/android/renderscript/Mesh.java +2 −2 Original line number Diff line number Diff line Loading @@ -733,14 +733,14 @@ public class Mesh extends BaseObj { Mesh sm = smb.create(); sm.getVertexAllocation(0).copyFrom(mVtxData); sm.getVertexAllocation(0).copy1DRangeFromUnchecked(0, mVtxCount / floatCount, mVtxData); if(uploadToBufferObject) { if (uploadToBufferObject) { sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } } sm.getIndexSetAllocation(0).copyFrom(mIndexData); sm.getIndexSetAllocation(0).copy1DRangeFromUnchecked(0, mIndexCount, mIndexData); if (uploadToBufferObject) { sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } Loading graphics/java/android/renderscript/ProgramFragmentFixedFunction.java +4 −3 Original line number Diff line number Diff line Loading @@ -280,9 +280,10 @@ public class ProgramFragmentFixedFunction extends ProgramFragment { pf.mTextureCount = MAX_TEXTURE; if (!mVaryingColorEnable) { Allocation constantData = Allocation.createTyped(mRS,constType); float[] data = new float[4]; data[0] = data[1] = data[2] = data[3] = 1.0f; constantData.copyFrom(data); FieldPacker fp = new FieldPacker(16); Float4 f4 = new Float4(1.f, 1.f, 1.f, 1.f); fp.addF32(f4); constantData.setFromFieldPacker(0, fp); pf.bindConstants(constantData, 0); } return pf; Loading graphics/java/android/renderscript/ProgramVertexFixedFunction.java +1 −1 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ public class ProgramVertexFixedFunction extends ProgramVertex { for(int i = 0; i < 16; i ++) { mIOBuffer.addF32(m.mMat[i]); } mAlloc.copyFrom(mIOBuffer.getData()); mAlloc.setFromFieldPacker(0, mIOBuffer); } /** Loading Loading
graphics/java/android/renderscript/Allocation.java +78 −5 Original line number Diff line number Diff line Loading @@ -121,6 +121,58 @@ public class Allocation extends BaseObj { mType = t; } private void validateIsInt32() { if ((mType.mElement.mType == Element.DataType.SIGNED_32) || (mType.mElement.mType == Element.DataType.UNSIGNED_32)) { return; } throw new RSIllegalArgumentException( "32 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsInt16() { if ((mType.mElement.mType == Element.DataType.SIGNED_16) || (mType.mElement.mType == Element.DataType.UNSIGNED_16)) { return; } throw new RSIllegalArgumentException( "16 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsInt8() { if ((mType.mElement.mType == Element.DataType.SIGNED_8) || (mType.mElement.mType == Element.DataType.UNSIGNED_8)) { return; } throw new RSIllegalArgumentException( "8 bit integer source does not match allocation type " + mType.mElement.mType); } private void validateIsFloat32() { if (mType.mElement.mType == Element.DataType.FLOAT_32) { return; } throw new RSIllegalArgumentException( "32 bit float source does not match allocation type " + mType.mElement.mType); } private void validateIsObject() { if ((mType.mElement.mType == Element.DataType.RS_ELEMENT) || (mType.mElement.mType == Element.DataType.RS_TYPE) || (mType.mElement.mType == Element.DataType.RS_ALLOCATION) || (mType.mElement.mType == Element.DataType.RS_SAMPLER) || (mType.mElement.mType == Element.DataType.RS_SCRIPT) || (mType.mElement.mType == Element.DataType.RS_MESH) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_FRAGMENT) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_VERTEX) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_RASTER) || (mType.mElement.mType == Element.DataType.RS_PROGRAM_STORE)) { return; } throw new RSIllegalArgumentException( "Object source does not match allocation type " + mType.mElement.mType); } @Override void updateFromNative() { super.updateFromNative(); Loading Loading @@ -151,6 +203,7 @@ public class Allocation extends BaseObj { public void copyFrom(BaseObj[] d) { mRS.validate(); validateIsObject(); if (d.length != mType.getCount()) { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mType.getCount() + ", array length = " + d.length); Loading Loading @@ -258,7 +311,6 @@ public class Allocation extends BaseObj { mRS.nAllocationData1D(getID(), xoff, 0, count, data, data.length); } /** * This is only intended to be used by auto-generate code reflected from the * renderscript script files. Loading Loading @@ -317,27 +369,44 @@ public class Allocation extends BaseObj { mRS.nAllocationGenerateMipmaps(getID()); } public void copy1DRangeFrom(int off, int count, int[] d) { void copy1DRangeFromUnchecked(int off, int count, int[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, short[] d) { void copy1DRangeFromUnchecked(int off, int count, short[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 2, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, byte[] d) { void copy1DRangeFromUnchecked(int off, int count, byte[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, float[] d) { void copy1DRangeFromUnchecked(int off, int count, float[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void copy1DRangeFrom(int off, int count, int[] d) { validateIsInt32(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, short[] d) { validateIsInt16(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, byte[] d) { validateIsInt8(); copy1DRangeFromUnchecked(off, count, d); } public void copy1DRangeFrom(int off, int count, float[] d) { validateIsFloat32(); copy1DRangeFromUnchecked(off, count, d); } private void validate2DRange(int xoff, int yoff, int w, int h) { if (xoff < 0 || yoff < 0) { throw new RSIllegalArgumentException("Offset cannot be negative."); Loading Loading @@ -411,21 +480,25 @@ public class Allocation extends BaseObj { } public void copyTo(byte[] d) { validateIsInt8(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(short[] d) { validateIsInt16(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(int[] d) { validateIsInt32(); mRS.validate(); mRS.nAllocationRead(getID(), d); } public void copyTo(float[] d) { validateIsFloat32(); mRS.validate(); mRS.nAllocationRead(getID(), d); } Loading
graphics/java/android/renderscript/Mesh.java +2 −2 Original line number Diff line number Diff line Loading @@ -733,14 +733,14 @@ public class Mesh extends BaseObj { Mesh sm = smb.create(); sm.getVertexAllocation(0).copyFrom(mVtxData); sm.getVertexAllocation(0).copy1DRangeFromUnchecked(0, mVtxCount / floatCount, mVtxData); if(uploadToBufferObject) { if (uploadToBufferObject) { sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } } sm.getIndexSetAllocation(0).copyFrom(mIndexData); sm.getIndexSetAllocation(0).copy1DRangeFromUnchecked(0, mIndexCount, mIndexData); if (uploadToBufferObject) { sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT); } Loading
graphics/java/android/renderscript/ProgramFragmentFixedFunction.java +4 −3 Original line number Diff line number Diff line Loading @@ -280,9 +280,10 @@ public class ProgramFragmentFixedFunction extends ProgramFragment { pf.mTextureCount = MAX_TEXTURE; if (!mVaryingColorEnable) { Allocation constantData = Allocation.createTyped(mRS,constType); float[] data = new float[4]; data[0] = data[1] = data[2] = data[3] = 1.0f; constantData.copyFrom(data); FieldPacker fp = new FieldPacker(16); Float4 f4 = new Float4(1.f, 1.f, 1.f, 1.f); fp.addF32(f4); constantData.setFromFieldPacker(0, fp); pf.bindConstants(constantData, 0); } return pf; Loading
graphics/java/android/renderscript/ProgramVertexFixedFunction.java +1 −1 Original line number Diff line number Diff line Loading @@ -229,7 +229,7 @@ public class ProgramVertexFixedFunction extends ProgramVertex { for(int i = 0; i < 16; i ++) { mIOBuffer.addF32(m.mMat[i]); } mAlloc.copyFrom(mIOBuffer.getData()); mAlloc.setFromFieldPacker(0, mIOBuffer); } /** Loading