diff options
| author | Miao Wang <miaowang@google.com> | 2015-04-03 17:38:13 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-03 17:38:14 +0000 |
| commit | 6aed9ec1b85ff1a8a39c4ec091a017f79413ead0 (patch) | |
| tree | e4fd495ece3892506dcb8da20a6f7087e51a103c /rs/java/android | |
| parent | 3d8b7f4d50c2f7c64ec4e5874fd95cf837ddc12e (diff) | |
| parent | d9b6328509f7c4fe63ca0a46b8c19bc956f62d8a (diff) | |
Merge "[RenderScript] update exception reporting for copyTo() after autoPadding added."
Diffstat (limited to 'rs/java/android')
| -rw-r--r-- | rs/java/android/renderscript/Allocation.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index 523c8fb7b189..28547ccdd13f 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -1340,15 +1340,22 @@ public class Allocation extends BaseObj { private void copyTo(Object array, Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); - if (dt.mSize * arrayLen < mSize) { - throw new RSIllegalArgumentException( - "Size of output array cannot be smaller than size of allocation."); - } mRS.validate(); boolean usePadding = false; if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) { usePadding = true; } + if (usePadding) { + if (dt.mSize * arrayLen < mSize / 4 * 3) { + throw new RSIllegalArgumentException( + "Size of output array cannot be smaller than size of allocation."); + } + } else { + if (dt.mSize * arrayLen < mSize) { + throw new RSIllegalArgumentException( + "Size of output array cannot be smaller than size of allocation."); + } + } mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding); Trace.traceEnd(RenderScript.TRACE_TAG); } |
