Loading rs/java/android/renderscript/Allocation.java +113 −17 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class Allocation extends BaseObj { boolean mReadAllowed = true; boolean mWriteAllowed = true; boolean mAutoPadding = false; int mSelectedX; int mSelectedY; int mSelectedZ; Loading Loading @@ -269,6 +270,17 @@ public class Allocation extends BaseObj { return mUsage; } /** * @hide * Enable/Disable AutoPadding for Vec3 elements. * * @param useAutoPadding True: enable AutoPadding; flase: disable AutoPadding * */ public void setAutoPadding(boolean useAutoPadding) { mAutoPadding = useAutoPadding; } /** * Get the size of the Allocation in bytes. * Loading Loading @@ -851,7 +863,7 @@ public class Allocation extends BaseObj { component_number, data, data_length); } private void data1DChecks(int off, int count, int len, int dataSize) { private void data1DChecks(int off, int count, int len, int dataSize, boolean usePadding) { mRS.validate(); if(off < 0) { throw new RSIllegalArgumentException("Offset must be >= 0."); Loading @@ -863,10 +875,16 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Overflow, Available count " + mCurrentCount + ", got " + count + " at offset " + off + "."); } if(usePadding) { if(len < dataSize / 4 * 3) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } else { if(len < dataSize) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } } /** * Generate a mipmap chain. This is only valid if the Type of the Allocation Loading @@ -886,8 +904,14 @@ public class Allocation extends BaseObj { Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); final int dataSize = mType.mElement.getBytesSize() * count; data1DChecks(off, count, arrayLen * dt.mSize, dataSize); mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt); // AutoPadding for Vec3 Element boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1064,8 +1088,24 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); mRS.validate(); validate2DRange(xoff, yoff, w, h); final int dataSize = mType.mElement.getBytesSize() * w * h; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1226,8 +1266,24 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked"); mRS.validate(); validate3DRange(xoff, yoff, zoff, w, h, d); final int dataSize = mType.mElement.getBytesSize() * w * h * d; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading @@ -1242,7 +1298,7 @@ public class Allocation extends BaseObj { * @param w Width of the region to update * @param h Height of the region to update * @param d Depth of the region to update * @param data to be placed into the allocation * @param array to be placed into the allocation */ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom"); Loading Loading @@ -1296,7 +1352,11 @@ public class Allocation extends BaseObj { private void copyTo(Object array, Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); mRS.validate(); mRS.nAllocationRead(getID(mRS), array, dt); boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1465,8 +1525,14 @@ public class Allocation extends BaseObj { Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeToUnchecked"); final int dataSize = mType.mElement.getBytesSize() * count; data1DChecks(off, count, arrayLen * dt.mSize, dataSize); mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt); // AutoPadding for Vec3 Element boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1620,8 +1686,23 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeToUnchecked"); mRS.validate(); validate2DRange(xoff, yoff, w, h); final int dataSize = mType.mElement.getBytesSize() * w * h; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationRead2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1649,7 +1730,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, byte[] data) { validateIsInt8(); Loading @@ -1665,7 +1746,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, short[] data) { validateIsInt16(); Loading @@ -1681,7 +1762,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, int[] data) { validateIsInt32(); Loading @@ -1697,7 +1778,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, float[] data) { validateIsFloat32(); Loading @@ -1715,8 +1796,23 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeToUnchecked"); mRS.validate(); validate3DRange(xoff, yoff, zoff, w, h, d); final int dataSize = mType.mElement.getBytesSize() * w * h * d; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationRead3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading rs/java/android/renderscript/RenderScript.java +32 −21 Original line number Diff line number Diff line Loading @@ -485,10 +485,12 @@ public class RenderScript { } native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationElementData(long con,long id, int xoff, int yoff, int zoff, int mip, int compIdx, byte[] d, int sizeBytes); Loading Loading @@ -518,11 +520,13 @@ public class RenderScript { } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, int dt); int w, int h, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, Element.DataType dt) { int w, int h, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, Bitmap b); Loading Loading @@ -550,25 +554,28 @@ public class RenderScript { } native void rsnAllocationData3D(long con, long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, int dt); int w, int h, int depth, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData3D(long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationRead(long con, long id, Object d, int dt); synchronized void nAllocationRead(long id, Object d, Element.DataType dt) { native void rsnAllocationRead(long con, long id, Object d, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead(long id, Object d, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead(mContext, id, d, dt.mID); rsnAllocationRead(mContext, id, d, dt.mID, mSize, usePadding); } native void rsnAllocationRead1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff, Loading @@ -581,19 +588,23 @@ public class RenderScript { } native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, int dt); int w, int h, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead2D(long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, Element.DataType dt) { int w, int h, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationRead3D(long con, long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, int dt); int w, int h, int depth, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead3D(long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); rsnAllocationRead3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID, mSize, usePadding); } native long rsnAllocationGetType(long con, long id); Loading rs/jni/android_renderscript_RenderScript.cpp +184 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
rs/java/android/renderscript/Allocation.java +113 −17 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class Allocation extends BaseObj { boolean mReadAllowed = true; boolean mWriteAllowed = true; boolean mAutoPadding = false; int mSelectedX; int mSelectedY; int mSelectedZ; Loading Loading @@ -269,6 +270,17 @@ public class Allocation extends BaseObj { return mUsage; } /** * @hide * Enable/Disable AutoPadding for Vec3 elements. * * @param useAutoPadding True: enable AutoPadding; flase: disable AutoPadding * */ public void setAutoPadding(boolean useAutoPadding) { mAutoPadding = useAutoPadding; } /** * Get the size of the Allocation in bytes. * Loading Loading @@ -851,7 +863,7 @@ public class Allocation extends BaseObj { component_number, data, data_length); } private void data1DChecks(int off, int count, int len, int dataSize) { private void data1DChecks(int off, int count, int len, int dataSize, boolean usePadding) { mRS.validate(); if(off < 0) { throw new RSIllegalArgumentException("Offset must be >= 0."); Loading @@ -863,10 +875,16 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Overflow, Available count " + mCurrentCount + ", got " + count + " at offset " + off + "."); } if(usePadding) { if(len < dataSize / 4 * 3) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } else { if(len < dataSize) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } } /** * Generate a mipmap chain. This is only valid if the Type of the Allocation Loading @@ -886,8 +904,14 @@ public class Allocation extends BaseObj { Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); final int dataSize = mType.mElement.getBytesSize() * count; data1DChecks(off, count, arrayLen * dt.mSize, dataSize); mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt); // AutoPadding for Vec3 Element boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1064,8 +1088,24 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); mRS.validate(); validate2DRange(xoff, yoff, w, h); final int dataSize = mType.mElement.getBytesSize() * w * h; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1226,8 +1266,24 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked"); mRS.validate(); validate3DRange(xoff, yoff, zoff, w, h, d); final int dataSize = mType.mElement.getBytesSize() * w * h * d; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading @@ -1242,7 +1298,7 @@ public class Allocation extends BaseObj { * @param w Width of the region to update * @param h Height of the region to update * @param d Depth of the region to update * @param data to be placed into the allocation * @param array to be placed into the allocation */ public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom"); Loading Loading @@ -1296,7 +1352,11 @@ public class Allocation extends BaseObj { private void copyTo(Object array, Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); mRS.validate(); mRS.nAllocationRead(getID(mRS), array, dt); boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1465,8 +1525,14 @@ public class Allocation extends BaseObj { Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeToUnchecked"); final int dataSize = mType.mElement.getBytesSize() * count; data1DChecks(off, count, arrayLen * dt.mSize, dataSize); mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt); // AutoPadding for Vec3 Element boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1620,8 +1686,23 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeToUnchecked"); mRS.validate(); validate2DRange(xoff, yoff, w, h); final int dataSize = mType.mElement.getBytesSize() * w * h; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationRead2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading Loading @@ -1649,7 +1730,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, byte[] data) { validateIsInt8(); Loading @@ -1665,7 +1746,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, short[] data) { validateIsInt16(); Loading @@ -1681,7 +1762,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, int[] data) { validateIsInt32(); Loading @@ -1697,7 +1778,7 @@ public class Allocation extends BaseObj { * @param yoff Y offset of the region to copy in this Allocation * @param w Width of the region to copy * @param h Height of the region to copy * @param array Dest Array to be copied into * @param data Dest Array to be copied into */ public void copy2DRangeTo(int xoff, int yoff, int w, int h, float[] data) { validateIsFloat32(); Loading @@ -1715,8 +1796,23 @@ public class Allocation extends BaseObj { Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeToUnchecked"); mRS.validate(); validate3DRange(xoff, yoff, zoff, w, h, d); final int dataSize = mType.mElement.getBytesSize() * w * h * d; // AutoPadding for Vec3 Element boolean usePadding = false; int sizeBytes = arrayLen * dt.mSize; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { if (dataSize / 4 * 3 > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } usePadding = true; sizeBytes = dataSize; } else { if (dataSize > sizeBytes) { throw new RSIllegalArgumentException("Array too small for allocation type."); } } mRS.nAllocationRead3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, array, arrayLen * dt.mSize, dt); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } Loading
rs/java/android/renderscript/RenderScript.java +32 −21 Original line number Diff line number Diff line Loading @@ -485,10 +485,12 @@ public class RenderScript { } native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationElementData(long con,long id, int xoff, int yoff, int zoff, int mip, int compIdx, byte[] d, int sizeBytes); Loading Loading @@ -518,11 +520,13 @@ public class RenderScript { } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, int dt); int w, int h, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, Element.DataType dt) { int w, int h, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, Bitmap b); Loading Loading @@ -550,25 +554,28 @@ public class RenderScript { } native void rsnAllocationData3D(long con, long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, int dt); int w, int h, int depth, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationData3D(long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationRead(long con, long id, Object d, int dt); synchronized void nAllocationRead(long id, Object d, Element.DataType dt) { native void rsnAllocationRead(long con, long id, Object d, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead(long id, Object d, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead(mContext, id, d, dt.mID); rsnAllocationRead(mContext, id, d, dt.mID, mSize, usePadding); } native void rsnAllocationRead1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff, Loading @@ -581,19 +588,23 @@ public class RenderScript { } native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, int dt); int w, int h, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead2D(long id, int xoff, int yoff, int mip, int face, int w, int h, Object d, int sizeBytes, Element.DataType dt) { int w, int h, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationRead3D(long con, long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, int dt); int w, int h, int depth, Object d, int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead3D(long id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); rsnAllocationRead3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); rsnAllocationRead3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID, mSize, usePadding); } native long rsnAllocationGetType(long con, long id); Loading
rs/jni/android_renderscript_RenderScript.cpp +184 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes