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

Commit f151a541 authored by Tim Murray's avatar Tim Murray Committed by Android Git Automerger
Browse files

am d6b8a035: Merge "Add support for synchronous get()." into jb-mr2-dev

* commit 'd6b8a035':
  Add support for synchronous get().
parents 2d28d622 d6b8a035
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -20001,6 +20001,35 @@ package android.renderscript {
    method public void reset();
    method public void reset(int);
    method public void skip(int);
    method public boolean subBoolean();
    method public android.renderscript.Byte2 subByte2();
    method public android.renderscript.Byte3 subByte3();
    method public android.renderscript.Byte4 subByte4();
    method public android.renderscript.Double2 subDouble2();
    method public android.renderscript.Double3 subDouble3();
    method public android.renderscript.Double4 subDouble4();
    method public float subF32();
    method public double subF64();
    method public android.renderscript.Float2 subFloat2();
    method public android.renderscript.Float3 subFloat3();
    method public android.renderscript.Float4 subFloat4();
    method public short subI16();
    method public int subI32();
    method public long subI64();
    method public byte subI8();
    method public android.renderscript.Int2 subInt2();
    method public android.renderscript.Int3 subInt3();
    method public android.renderscript.Int4 subInt4();
    method public android.renderscript.Long2 subLong2();
    method public android.renderscript.Long3 subLong3();
    method public android.renderscript.Long4 subLong4();
    method public android.renderscript.Matrix2f subMatrix2f();
    method public android.renderscript.Matrix3f subMatrix3f();
    method public android.renderscript.Matrix4f subMatrix4f();
    method public android.renderscript.Short2 subShort2();
    method public android.renderscript.Short3 subShort3();
    method public android.renderscript.Short4 subShort4();
    method public void subalign(int);
  }
  public class Float2 {
@@ -20245,6 +20274,12 @@ package android.renderscript {
    method protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element);
    method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker);
    method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions);
    method public boolean getVarB(int);
    method public double getVarD(int);
    method public float getVarF(int);
    method public int getVarI(int);
    method public long getVarJ(int);
    method public void getVarV(int, android.renderscript.FieldPacker);
    method protected void invoke(int);
    method protected void invoke(int, android.renderscript.FieldPacker);
    method public void setTimeZone(java.lang.String);
+13 −7
Original line number Diff line number Diff line
@@ -277,14 +277,14 @@ public class Allocation extends BaseObj {
                throw new RSIllegalArgumentException("Invalid usage combination.");
            }
        }

        if (t != null) {
            // don't need to account for USAGE_SHARED Allocations
            if ((usage & USAGE_SHARED) == 0) {
                int numBytes = t.getCount() * t.getElement().getBytesSize();
                rs.addAllocSizeForGC(numBytes);
                mGCSize = numBytes;
            }

        }
        mType = t;
        mUsage = usage;

@@ -355,6 +355,12 @@ public class Allocation extends BaseObj {
            mType.updateFromNative();
            updateCacheInfo(mType);
        }
        // don't need to account for USAGE_SHARED Allocations
        if ((mUsage & USAGE_SHARED) == 0) {
            int numBytes = mType.getCount() * mType.getElement().getBytesSize();
            mRS.addAllocSizeForGC(numBytes);
            mGCSize = numBytes;
        }
    }

    /**
+247 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.renderscript;

import android.util.Log;
import java.util.BitSet;

/**
 * Utility class for packing arguments and structures from Android system objects to
@@ -27,12 +29,14 @@ public class FieldPacker {
        mPos = 0;
        mLen = len;
        mData = new byte[len];
        mAlignment = new BitSet();
    }

    public FieldPacker(byte[] data) {
        mPos = 0;
        mLen = data.length;
        mData = data;
        mAlignment = new BitSet();
    }

    public void align(int v) {
@@ -41,10 +45,29 @@ public class FieldPacker {
        }

        while ((mPos & (v - 1)) != 0) {
            mAlignment.flip(mPos);
            mData[mPos++] = 0;
        }
    }

    public void subalign(int v) {
        if ((v & (v - 1)) != 0) {
            throw new RSIllegalArgumentException("argument must be a non-negative non-zero power of 2: " + v);
        }

        while ((mPos & (v - 1)) != 0) {
            mPos--;
        }

        if (mPos > 0) {
            while (mAlignment.get(mPos - 1) == true) {
                mPos--;
                mAlignment.flip(mPos);
            }
        }

    }

    public void reset() {
        mPos = 0;
    }
@@ -67,12 +90,26 @@ public class FieldPacker {
        mData[mPos++] = v;
    }

    public byte subI8() {
        subalign(1);
        return mData[--mPos];
    }

    public void addI16(short v) {
        align(2);
        mData[mPos++] = (byte)(v & 0xff);
        mData[mPos++] = (byte)(v >> 8);
    }

    public short subI16() {
        subalign(2);
        short v = 0;
        v = (short)((mData[--mPos] & 0xff) << 8);
        v = (short)(v | (short)(mData[--mPos] & 0xff));
        return v;
    }


    public void addI32(int v) {
        align(4);
        mData[mPos++] = (byte)(v & 0xff);
@@ -81,6 +118,17 @@ public class FieldPacker {
        mData[mPos++] = (byte)((v >> 24) & 0xff);
    }

    public int subI32() {
        subalign(4);
        int v = 0;
        v = ((mData[--mPos] & 0xff) << 24);
        v = v | ((mData[--mPos] & 0xff) << 16);
        v = v | ((mData[--mPos] & 0xff) << 8);
        v = v | ((mData[--mPos] & 0xff));
        return v;
    }


    public void addI64(long v) {
        align(8);
        mData[mPos++] = (byte)(v & 0xff);
@@ -93,6 +141,29 @@ public class FieldPacker {
        mData[mPos++] = (byte)((v >> 56) & 0xff);
    }

    public long subI64() {
        subalign(8);
        long v = 0;
        byte x = 0;
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 56l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 48l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 40l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 32l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 24l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 16l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff) << 8l);
        x = ((mData[--mPos]));
        v = (long)(v | (((long)x) & 0xff));
        return v;
    }

    public void addU8(short v) {
        if ((v < 0) || (v > 0xff)) {
            android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )");
@@ -143,10 +214,18 @@ public class FieldPacker {
        addI32(Float.floatToRawIntBits(v));
    }

    public float subF32() {
        return Float.intBitsToFloat(subI32());
    }

    public void addF64(double v) {
        addI64(Double.doubleToRawLongBits(v));
    }

    public double subF64() {
        return Double.longBitsToDouble(subI64());
    }

    public void addObj(BaseObj obj) {
        if (obj != null) {
            addI32(obj.getID(null));
@@ -315,28 +394,195 @@ public class FieldPacker {
        addU64(v.w);
    }


    public Float2 subFloat2() {
        Float2 v = new Float2();
        v.y = subF32();
        v.x = subF32();
        return v;
    }
    public Float3 subFloat3() {
        Float3 v = new Float3();
        v.z = subF32();
        v.y = subF32();
        v.x = subF32();
        return v;
    }
    public Float4 subFloat4() {
        Float4 v = new Float4();
        v.w = subF32();
        v.z = subF32();
        v.y = subF32();
        v.x = subF32();
        return v;
    }

    public Double2 subDouble2() {
        Double2 v = new Double2();
        v.y = subF64();
        v.x = subF64();
        return v;
    }
    public Double3 subDouble3() {
        Double3 v = new Double3();
        v.z = subF64();
        v.y = subF64();
        v.x = subF64();
        return v;
    }
    public Double4 subDouble4() {
        Double4 v = new Double4();
        v.w = subF64();
        v.z = subF64();
        v.y = subF64();
        v.x = subF64();
        return v;
    }

    public Byte2 subByte2() {
        Byte2 v = new Byte2();
        v.y = subI8();
        v.x = subI8();
        return v;
    }
    public Byte3 subByte3() {
        Byte3 v = new Byte3();
        v.z = subI8();
        v.y = subI8();
        v.x = subI8();
        return v;
    }
    public Byte4 subByte4() {
        Byte4 v = new Byte4();
        v.w = subI8();
        v.z = subI8();
        v.y = subI8();
        v.x = subI8();
        return v;
    }

    public Short2 subShort2() {
        Short2 v = new Short2();
        v.y = subI16();
        v.x = subI16();
        return v;
    }
    public Short3 subShort3() {
        Short3 v = new Short3();
        v.z = subI16();
        v.y = subI16();
        v.x = subI16();
        return v;
    }
    public Short4 subShort4() {
        Short4 v = new Short4();
        v.w = subI16();
        v.z = subI16();
        v.y = subI16();
        v.x = subI16();
        return v;
    }

    public Int2 subInt2() {
        Int2 v = new Int2();
        v.y = subI32();
        v.x = subI32();
        return v;
    }
    public Int3 subInt3() {
        Int3 v = new Int3();
        v.z = subI32();
        v.y = subI32();
        v.x = subI32();
        return v;
    }
    public Int4 subInt4() {
        Int4 v = new Int4();
        v.w = subI32();
        v.z = subI32();
        v.y = subI32();
        v.x = subI32();
        return v;
    }

    public Long2 subLong2() {
        Long2 v = new Long2();
        v.y = subI64();
        v.x = subI64();
        return v;
    }
    public Long3 subLong3() {
        Long3 v = new Long3();
        v.z = subI64();
        v.y = subI64();
        v.x = subI64();
        return v;
    }
    public Long4 subLong4() {
        Long4 v = new Long4();
        v.w = subI64();
        v.z = subI64();
        v.y = subI64();
        v.x = subI64();
        return v;
    }



    public void addMatrix(Matrix4f v) {
        for (int i=0; i < v.mMat.length; i++) {
            addF32(v.mMat[i]);
        }
    }

    public Matrix4f subMatrix4f() {
        Matrix4f v = new Matrix4f();
        for (int i = v.mMat.length - 1; i >= 0; i--) {
            v.mMat[i] = subF32();
        }
        return v;
    }

    public void addMatrix(Matrix3f v) {
        for (int i=0; i < v.mMat.length; i++) {
            addF32(v.mMat[i]);
        }
    }

    public Matrix3f subMatrix3f() {
        Matrix3f v = new Matrix3f();
        for (int i = v.mMat.length - 1; i >= 0; i--) {
            v.mMat[i] = subF32();
        }
        return v;
    }

    public void addMatrix(Matrix2f v) {
        for (int i=0; i < v.mMat.length; i++) {
            addF32(v.mMat[i]);
        }
    }

    public Matrix2f subMatrix2f() {
        Matrix2f v = new Matrix2f();
        for (int i = v.mMat.length - 1; i >= 0; i--) {
            v.mMat[i] = subF32();
        }
        return v;
    }

    public void addBoolean(boolean v) {
        addI8((byte)(v ? 1 : 0));
    }

    public boolean subBoolean() {
        byte v = subI8();
        if (v == 1) {
            return true;
        }
        return false;
    }

    public final byte[] getData() {
        return mData;
    }
@@ -344,6 +590,7 @@ public class FieldPacker {
    private final byte mData[];
    private int mPos;
    private int mLen;
    private BitSet mAlignment;

}

+28 −0
Original line number Diff line number Diff line
@@ -582,31 +582,59 @@ public class RenderScript {
        validate();
        rsnScriptInvokeV(mContext, id, slot, params);
    }

    native void rsnScriptSetVarI(int con, int id, int slot, int val);
    synchronized void nScriptSetVarI(int id, int slot, int val) {
        validate();
        rsnScriptSetVarI(mContext, id, slot, val);
    }
    native int rsnScriptGetVarI(int con, int id, int slot);
    synchronized int nScriptGetVarI(int id, int slot) {
        validate();
        return rsnScriptGetVarI(mContext, id, slot);
    }

    native void rsnScriptSetVarJ(int con, int id, int slot, long val);
    synchronized void nScriptSetVarJ(int id, int slot, long val) {
        validate();
        rsnScriptSetVarJ(mContext, id, slot, val);
    }
    native long rsnScriptGetVarJ(int con, int id, int slot);
    synchronized long nScriptGetVarJ(int id, int slot) {
        validate();
        return rsnScriptGetVarJ(mContext, id, slot);
    }

    native void rsnScriptSetVarF(int con, int id, int slot, float val);
    synchronized void nScriptSetVarF(int id, int slot, float val) {
        validate();
        rsnScriptSetVarF(mContext, id, slot, val);
    }
    native float rsnScriptGetVarF(int con, int id, int slot);
    synchronized float nScriptGetVarF(int id, int slot) {
        validate();
        return rsnScriptGetVarF(mContext, id, slot);
    }
    native void rsnScriptSetVarD(int con, int id, int slot, double val);
    synchronized void nScriptSetVarD(int id, int slot, double val) {
        validate();
        rsnScriptSetVarD(mContext, id, slot, val);
    }
    native double rsnScriptGetVarD(int con, int id, int slot);
    synchronized double nScriptGetVarD(int id, int slot) {
        validate();
        return rsnScriptGetVarD(mContext, id, slot);
    }
    native void rsnScriptSetVarV(int con, int id, int slot, byte[] val);
    synchronized void nScriptSetVarV(int id, int slot, byte[] val) {
        validate();
        rsnScriptSetVarV(mContext, id, slot, val);
    }
    native void rsnScriptGetVarV(int con, int id, int slot, byte[] val);
    synchronized void nScriptGetVarV(int id, int slot, byte[] val) {
        validate();
        rsnScriptGetVarV(mContext, id, slot, val);
    }
    native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val,
                                  int e, int[] dims);
    synchronized void nScriptSetVarVE(int id, int slot, byte[] val,
+21 −0
Original line number Diff line number Diff line
@@ -220,6 +220,9 @@ public class Script extends BaseObj {
    public void setVar(int index, float v) {
        mRS.nScriptSetVarF(getID(mRS), index, v);
    }
    public float getVarF(int index) {
        return mRS.nScriptGetVarF(getID(mRS), index);
    }

    /**
     * Only intended for use by generated reflected code.
@@ -230,6 +233,9 @@ public class Script extends BaseObj {
    public void setVar(int index, double v) {
        mRS.nScriptSetVarD(getID(mRS), index, v);
    }
    public double getVarD(int index) {
        return mRS.nScriptGetVarD(getID(mRS), index);
    }

    /**
     * Only intended for use by generated reflected code.
@@ -240,6 +246,10 @@ public class Script extends BaseObj {
    public void setVar(int index, int v) {
        mRS.nScriptSetVarI(getID(mRS), index, v);
    }
    public int getVarI(int index) {
        return mRS.nScriptGetVarI(getID(mRS), index);
    }


    /**
     * Only intended for use by generated reflected code.
@@ -250,6 +260,10 @@ public class Script extends BaseObj {
    public void setVar(int index, long v) {
        mRS.nScriptSetVarJ(getID(mRS), index, v);
    }
    public long getVarJ(int index) {
        return mRS.nScriptGetVarJ(getID(mRS), index);
    }


    /**
     * Only intended for use by generated reflected code.
@@ -260,6 +274,9 @@ public class Script extends BaseObj {
    public void setVar(int index, boolean v) {
        mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0);
    }
    public boolean getVarB(int index) {
        return mRS.nScriptGetVarI(getID(mRS), index) > 0 ? true : false;
    }

    /**
     * Only intended for use by generated reflected code.
@@ -293,6 +310,10 @@ public class Script extends BaseObj {
        mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims);
    }

    public void getVarV(int index, FieldPacker v) {
        mRS.nScriptGetVarV(getID(mRS), index, v.getData());
    }

    public void setTimeZone(String timeZone) {
        mRS.validate();
        try {
Loading