Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbfcf3f8 authored by Miao Wang's avatar Miao Wang Committed by Android (Google) Code Review
Browse files

Merge "[Renderscript] Add check for Allocation.copyTo(Array) and Fix the input...

Merge "[Renderscript] Add check for Allocation.copyTo(Array) and Fix the input allocation type check for Histogram Intrinsic." into lmp-mr1-dev
parents c79a8ea0 b590b354
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
+6 −6
Original line number Diff line number Diff line
@@ -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);