summaryrefslogtreecommitdiffstats
path: root/rs/java
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2015-04-03 18:18:01 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-03 18:18:01 +0000
commitedea751f6416869ff08268d9aeec2f6b6e65f7f0 (patch)
treef00151385666a2d93cc076590b46cfffb67de19e /rs/java
parentda656fd8c37982554edf9ad78113d3340443676d (diff)
parent1327fa9eb155eb57fe24a8aa90a18f57d706e86b (diff)
downloadframeworks_base-edea751f6416869ff08268d9aeec2f6b6e65f7f0.zip
frameworks_base-edea751f6416869ff08268d9aeec2f6b6e65f7f0.tar.gz
frameworks_base-edea751f6416869ff08268d9aeec2f6b6e65f7f0.tar.bz2
am 1327fa9e: am 511eb660: am 6aed9ec1: Merge "[RenderScript] update exception reporting for copyTo() after autoPadding added."
* commit '1327fa9eb155eb57fe24a8aa90a18f57d706e86b': [RenderScript] update exception reporting for copyTo() after autoPadding added.
Diffstat (limited to 'rs/java')
-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 2b2e611..2203850 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);
}