am 6aed9ec1: Merge "[RenderScript] update exception reporting for copyTo() after autoPadding added."
* commit '6aed9ec1b85ff1a8a39c4ec091a017f79413ead0': [RenderScript] update exception reporting for copyTo() after autoPadding added.
This commit is contained in:
@@ -1340,15 +1340,22 @@ public class Allocation extends BaseObj {
|
|||||||
|
|
||||||
private void copyTo(Object array, Element.DataType dt, int arrayLen) {
|
private void copyTo(Object array, Element.DataType dt, int arrayLen) {
|
||||||
Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
|
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.validate();
|
||||||
boolean usePadding = false;
|
boolean usePadding = false;
|
||||||
if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) {
|
if (mAutoPadding && (mType.getElement().getVectorSize() == 3)) {
|
||||||
usePadding = true;
|
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);
|
mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding);
|
||||||
Trace.traceEnd(RenderScript.TRACE_TAG);
|
Trace.traceEnd(RenderScript.TRACE_TAG);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user