summaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-04-03 09:15:39 -0700
committerMiao Wang <miaowang@google.com>2015-04-03 09:15:39 -0700
commitd9b6328509f7c4fe63ca0a46b8c19bc956f62d8a (patch)
treed1a1e5c9fe8dad7920023f306531b2b966b9d85f /rs
parente4d4e22f26bfd36a553fb24232d2fd4ddf4fc907 (diff)
downloadframeworks_base-d9b6328509f7c4fe63ca0a46b8c19bc956f62d8a.zip
frameworks_base-d9b6328509f7c4fe63ca0a46b8c19bc956f62d8a.tar.gz
frameworks_base-d9b6328509f7c4fe63ca0a46b8c19bc956f62d8a.tar.bz2
[RenderScript] update exception reporting for copyTo() after
autoPadding added. - This CL fixes recent CTS failures about copyPadded after lmp-mr1-dev changes pushed to aosp. Change-Id: Ica1f4fd934cd83ca4357ea7e7c82dcc7f844b689
Diffstat (limited to 'rs')
-rw-r--r--rs/java/android/renderscript/Allocation.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java
index 523c8fb..28547cc 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);
}