diff options
author | Miao Wang <miaowang@google.com> | 2015-01-22 01:26:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-01-22 01:26:24 +0000 |
commit | 118245d939656903ab570fb80dd651b1158dadf1 (patch) | |
tree | ceda053cbff9f07ad4f19000dc4adac74e86fd9b /rs/java/android | |
parent | f6ab9afc46638fbe1122dee6c9c491198f0da961 (diff) | |
parent | a710b839a23633bb049a6f91ccd7e17261e406a4 (diff) | |
download | frameworks_base-118245d939656903ab570fb80dd651b1158dadf1.zip frameworks_base-118245d939656903ab570fb80dd651b1158dadf1.tar.gz frameworks_base-118245d939656903ab570fb80dd651b1158dadf1.tar.bz2 |
Merge "[Renderscript] Add check for Allocation.copyTo(Array) and Fix the input allocation type check for Histogram Intrinsic." into lmp-mr1-dev automerge: dbfcf3f
automerge: a710b83
* commit 'a710b839a23633bb049a6f91ccd7e17261e406a4':
[Renderscript] Add check for Allocation.copyTo(Array) and Fix the input allocation type check for Histogram Intrinsic.
Diffstat (limited to 'rs/java/android')
-rw-r--r-- | rs/java/android/renderscript/Allocation.java | 4 | ||||
-rw-r--r-- | rs/java/android/renderscript/ScriptIntrinsicHistogram.java | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index 3cda6de..4e89566 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -1262,6 +1262,10 @@ 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(); mRS.nAllocationRead(getID(mRS), array, dt); Trace.traceEnd(RenderScript.TRACE_TAG); diff --git a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java index 95b610a..4ecac99 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java +++ b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java @@ -91,9 +91,9 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { throw new RSIllegalArgumentException( "Input vector size must be >= output vector size."); } - if (ain.getType().getElement().isCompatible(Element.U8(mRS)) && - ain.getType().getElement().isCompatible(Element.U8_4(mRS))) { - throw new RSIllegalArgumentException("Output type must be U32 or I32."); + if (!ain.getType().getElement().isCompatible(Element.U8(mRS)) && + !ain.getType().getElement().isCompatible(Element.U8_4(mRS))) { + throw new RSIllegalArgumentException("Input type must be U8 or U8_4."); } forEach(0, ain, null, null, opt); @@ -187,9 +187,9 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { if (mOut.getType().getElement().getVectorSize() != 1) { throw new RSIllegalArgumentException("Output vector size must be one."); } - if (ain.getType().getElement().isCompatible(Element.U8(mRS)) && - ain.getType().getElement().isCompatible(Element.U8_4(mRS))) { - throw new RSIllegalArgumentException("Output type must be U32 or I32."); + if (!ain.getType().getElement().isCompatible(Element.U8(mRS)) && + !ain.getType().getElement().isCompatible(Element.U8_4(mRS))) { + throw new RSIllegalArgumentException("Input type must be U8 or U8_4."); } forEach(1, ain, null, null, opt); |