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

Commit 881c6d57 authored by Tim Murray's avatar Tim Murray Committed by Android (Google) Code Review
Browse files

Merge "Add clipping for intrinsics."

parents 3778e50d 6f842ac8
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -22585,7 +22585,7 @@ package android.renderscript {
  }
  public class BaseObj {
    method public synchronized void destroy();
    method public void destroy();
    method public java.lang.String getName();
    method public void setName(java.lang.String);
  }
@@ -23177,6 +23177,7 @@ package android.renderscript {
  public final class ScriptIntrinsic3DLUT extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsic3DLUT create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setLUT(android.renderscript.Allocation);
  }
@@ -23184,20 +23185,35 @@ package android.renderscript {
  public class ScriptIntrinsicBlend extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicBlend create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachAdd(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachClear(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachDst(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachDstAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachDstIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachDstOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachDstOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachMultiply(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSrc(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSrcAtop(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSrcIn(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSrcOut(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSrcOver(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachSubtract(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEachXor(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.KernelID getKernelIDAdd();
    method public android.renderscript.Script.KernelID getKernelIDClear();
    method public android.renderscript.Script.KernelID getKernelIDDst();
@@ -23218,6 +23234,7 @@ package android.renderscript {
  public final class ScriptIntrinsicBlur extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicBlur create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.FieldID getFieldID_Input();
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setInput(android.renderscript.Allocation);
@@ -23228,6 +23245,7 @@ package android.renderscript {
    method public static deprecated android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript, android.renderscript.Element);
    method public static android.renderscript.ScriptIntrinsicColorMatrix create(android.renderscript.RenderScript);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setAdd(android.renderscript.Float4);
    method public void setAdd(float, float, float, float);
@@ -23241,6 +23259,7 @@ package android.renderscript {
  public final class ScriptIntrinsicConvolve3x3 extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicConvolve3x3 create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.FieldID getFieldID_Input();
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setCoefficients(float[]);
@@ -23250,6 +23269,7 @@ package android.renderscript {
  public final class ScriptIntrinsicConvolve5x5 extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicConvolve5x5 create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.FieldID getFieldID_Input();
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setCoefficients(float[]);
@@ -23259,7 +23279,9 @@ package android.renderscript {
  public final class ScriptIntrinsicHistogram extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicHistogram create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public void forEach_Dot(android.renderscript.Allocation);
    method public void forEach_Dot(android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.FieldID getFieldID_Input();
    method public android.renderscript.Script.KernelID getKernelID_Separate();
    method public void setDotCoefficients(float, float, float, float);
@@ -23269,6 +23291,7 @@ package android.renderscript {
  public final class ScriptIntrinsicLUT extends android.renderscript.ScriptIntrinsic {
    method public static android.renderscript.ScriptIntrinsicLUT create(android.renderscript.RenderScript, android.renderscript.Element);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation);
    method public void forEach(android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.Script.LaunchOptions);
    method public android.renderscript.Script.KernelID getKernelID();
    method public void setAlpha(int, int);
    method public void setBlue(int, int);
+14 −1
Original line number Diff line number Diff line
@@ -84,9 +84,22 @@ public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic {
     * @param aout Output allocation
     */
    public void forEach(Allocation ain, Allocation aout) {
        forEach(0, ain, aout, null);
        forEach(ain, aout, null);
    }

    /**
     * Invoke the kernel and apply the lookup to each cell of ain
     * and copy to aout.
     *
     * @param ain Input allocation
     * @param aout Output allocation
     * @param opt Launch options for kernel
     */
    public void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        forEach(0, ain, aout, null, opt);
    }


    /**
     * Get a KernelID for this intrinsic kernel.
     *
+185 −16
Original line number Diff line number Diff line
@@ -40,14 +40,14 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {

    }

    private void blend(int id, Allocation ain, Allocation aout) {
    private void blend(int id, Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        if (!ain.getElement().isCompatible(Element.U8_4(mRS))) {
            throw new RSIllegalArgumentException("Input is not of expected format.");
        }
        if (!aout.getElement().isCompatible(Element.U8_4(mRS))) {
            throw new RSIllegalArgumentException("Output is not of expected format.");
        }
        forEach(id, ain, aout, null);
        forEach(id, ain, aout, null, opt);
    }

    /**
@@ -57,7 +57,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachClear(Allocation ain, Allocation aout) {
        blend(0, ain, aout);
        forEachClear(ain, aout, null);
    }

    /**
     * Sets dst = {0, 0, 0, 0}
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachClear(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(0, ain, aout, opt);
    }

    /**
@@ -77,7 +88,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSrc(Allocation ain, Allocation aout) {
        blend(1, ain, aout);
        forEachSrc(ain, aout, null);
    }

    /**
     * Sets dst = src
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSrc(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        forEachDst(ain, aout, null);
    }

    /**
@@ -101,6 +123,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
        // NOP
    }

    /**
     * Sets dst = dst
     *
     * This is a NOP.
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachDst(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        // N, optOP
    }

    /**
     * Get a KernelID for the Dst kernel.
     *
@@ -117,7 +152,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSrcOver(Allocation ain, Allocation aout) {
        blend(3, ain, aout);
        forEachSrcOver(ain, aout, null);
    }

    /**
     * Sets dst = src + dst * (1.0 - src.a)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSrcOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(3, ain, aout, opt);
    }

    /**
@@ -136,7 +182,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachDstOver(Allocation ain, Allocation aout) {
        blend(4, ain, aout);
        forEachDstOver(ain, aout, null);
    }

    /**
     * Sets dst = dst + src * (1.0 - dst.a)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachDstOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(4, ain, aout, opt);
    }

    /**
@@ -155,7 +212,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSrcIn(Allocation ain, Allocation aout) {
        blend(5, ain, aout);
        forEachSrcIn(ain, aout, null);
    }

    /**
     * Sets dst = src * dst.a
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSrcIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(5, ain, aout, opt);
    }

    /**
@@ -174,7 +242,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachDstIn(Allocation ain, Allocation aout) {
        blend(6, ain, aout);
        forEachDstIn(ain, aout, null);
    }

    /**
     * Sets dst = dst * src.a
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachDstIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(6, ain, aout, opt);
    }

    /**
@@ -193,7 +272,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSrcOut(Allocation ain, Allocation aout) {
        blend(7, ain, aout);
        forEachSrcOut(ain, aout, null);
    }

    /**
     * Sets dst = src * (1.0 - dst.a)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSrcOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(7, ain, aout, opt);
    }

    /**
@@ -212,7 +302,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachDstOut(Allocation ain, Allocation aout) {
        blend(8, ain, aout);
        forEachDstOut(ain, aout, null);
    }

    /**
     * Sets dst = dst * (1.0 - src.a)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachDstOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(8, ain, aout, opt);
    }

    /**
@@ -232,7 +333,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSrcAtop(Allocation ain, Allocation aout) {
        blend(9, ain, aout);
        forEachSrcAtop(ain, aout, null);
    }

    /**
     * dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb
     * dst.a = dst.a
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSrcAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(9, ain, aout, opt);
    }

    /**
@@ -252,7 +365,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachDstAtop(Allocation ain, Allocation aout) {
        blend(10, ain, aout);
        forEachDstAtop(ain, aout, null);
    }

    /**
     * dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb
     * dst.a = src.a
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachDstAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(10, ain, aout, opt);
    }

    /**
@@ -271,7 +396,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachXor(Allocation ain, Allocation aout) {
        blend(11, ain, aout);
        forEachXor(ain, aout, null);
    }

    /**
     * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a}
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachXor(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(11, ain, aout, opt);
    }

    /**
@@ -300,7 +436,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachMultiply(Allocation ain, Allocation aout) {
        blend(14, ain, aout);
        forEachMultiply(ain, aout, null);
    }

    /**
     * Sets dst = src * dst
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachMultiply(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(14, ain, aout, opt);
    }

    /**
@@ -396,7 +543,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachAdd(Allocation ain, Allocation aout) {
        blend(34, ain, aout);
        forEachAdd(ain, aout, null);
    }

    /**
     * Sets dst = min(src + dst, 1.0)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachAdd(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(34, ain, aout, opt);
    }

    /**
@@ -415,7 +573,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic {
     * @param aout The destination buffer
     */
    public void forEachSubtract(Allocation ain, Allocation aout) {
        blend(35, ain, aout);
        forEachSubtract(ain, aout, null);
    }

    /**
     * Sets dst = max(dst - src, 0.0)
     *
     * @param ain The source buffer
     * @param aout The destination buffer
     * @param opt LaunchOptions for clipping
     */
    public void forEachSubtract(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        blend(35, ain, aout, opt);
    }

    /**
+14 −1
Original line number Diff line number Diff line
@@ -84,9 +84,22 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic {
     *             type.
     */
    public void forEach(Allocation aout) {
        forEach(0, null, aout, null);
        forEach(aout, null);
    }

    /**
     * Apply the filter to the input and save to the specified
     * allocation.
     *
     * @param aout Output allocation. Must match creation element
     *             type.
     * @param opt LaunchOptions for clipping
     */
    public void forEach(Allocation aout, Script.LaunchOptions opt) {
        forEach(0, null, aout, null, opt);
    }


    /**
     * Get a KernelID for this intrinsic kernel.
     *
+21 −2
Original line number Diff line number Diff line
@@ -206,7 +206,6 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
        setMatrix();
    }


    /**
     * Invoke the kernel and apply the matrix to each cell of input
     * {@link Allocation} and copy to the output {@link Allocation}.
@@ -223,6 +222,26 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
     * @param aout Output allocation
     */
    public void forEach(Allocation ain, Allocation aout) {
        forEach(ain, aout, null);
    }

    /**
     * Invoke the kernel and apply the matrix to each cell of input
     * {@link Allocation} and copy to the output {@link Allocation}.
     *
     * If the vector size of the input is less than four, the
     * remaining components are treated as zero for the matrix
     * multiply.
     *
     * If the output vector size is less than four, the unused
     * vector components are discarded.
     *
     *
     * @param ain Input allocation
     * @param aout Output allocation
     * @param opt LaunchOptions for clipping
     */
    public void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt) {
        if (!ain.getElement().isCompatible(Element.U8(mRS)) &&
            !ain.getElement().isCompatible(Element.U8_2(mRS)) &&
            !ain.getElement().isCompatible(Element.U8_3(mRS)) &&
@@ -247,7 +266,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
            throw new RSIllegalArgumentException("Unsuported element type.");
        }

        forEach(0, ain, aout, null);
        forEach(0, ain, aout, null, opt);
    }

    /**
Loading