Loading api/current.txt +35 −0 Original line number Original line Diff line number Diff line Loading @@ -20001,6 +20001,35 @@ package android.renderscript { method public void reset(); method public void reset(); method public void reset(int); method public void reset(int); method public void skip(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 { public class Float2 { Loading Loading @@ -20245,6 +20274,12 @@ package android.renderscript { method protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element); 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); method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); 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); method protected void invoke(int, android.renderscript.FieldPacker); method protected void invoke(int, android.renderscript.FieldPacker); method public void setTimeZone(java.lang.String); method public void setTimeZone(java.lang.String); graphics/java/android/renderscript/Allocation.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -277,14 +277,14 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Invalid usage combination."); throw new RSIllegalArgumentException("Invalid usage combination."); } } } } if (t != null) { // don't need to account for USAGE_SHARED Allocations // don't need to account for USAGE_SHARED Allocations if ((usage & USAGE_SHARED) == 0) { if ((usage & USAGE_SHARED) == 0) { int numBytes = t.getCount() * t.getElement().getBytesSize(); int numBytes = t.getCount() * t.getElement().getBytesSize(); rs.addAllocSizeForGC(numBytes); rs.addAllocSizeForGC(numBytes); mGCSize = numBytes; mGCSize = numBytes; } } } mType = t; mType = t; mUsage = usage; mUsage = usage; Loading Loading @@ -355,6 +355,12 @@ public class Allocation extends BaseObj { mType.updateFromNative(); mType.updateFromNative(); updateCacheInfo(mType); 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; } } } /** /** Loading graphics/java/android/renderscript/FieldPacker.java +247 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.renderscript; package android.renderscript; import android.util.Log; import java.util.BitSet; /** /** * Utility class for packing arguments and structures from Android system objects to * Utility class for packing arguments and structures from Android system objects to Loading @@ -27,12 +29,14 @@ public class FieldPacker { mPos = 0; mPos = 0; mLen = len; mLen = len; mData = new byte[len]; mData = new byte[len]; mAlignment = new BitSet(); } } public FieldPacker(byte[] data) { public FieldPacker(byte[] data) { mPos = 0; mPos = 0; mLen = data.length; mLen = data.length; mData = data; mData = data; mAlignment = new BitSet(); } } public void align(int v) { public void align(int v) { Loading @@ -41,10 +45,29 @@ public class FieldPacker { } } while ((mPos & (v - 1)) != 0) { while ((mPos & (v - 1)) != 0) { mAlignment.flip(mPos); mData[mPos++] = 0; 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() { public void reset() { mPos = 0; mPos = 0; } } Loading @@ -67,12 +90,26 @@ public class FieldPacker { mData[mPos++] = v; mData[mPos++] = v; } } public byte subI8() { subalign(1); return mData[--mPos]; } public void addI16(short v) { public void addI16(short v) { align(2); align(2); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v >> 8); 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) { public void addI32(int v) { align(4); align(4); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); Loading @@ -81,6 +118,17 @@ public class FieldPacker { mData[mPos++] = (byte)((v >> 24) & 0xff); 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) { public void addI64(long v) { align(8); align(8); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); Loading @@ -93,6 +141,29 @@ public class FieldPacker { mData[mPos++] = (byte)((v >> 56) & 0xff); 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) { public void addU8(short v) { if ((v < 0) || (v > 0xff)) { if ((v < 0) || (v > 0xff)) { android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )"); android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )"); Loading Loading @@ -143,10 +214,18 @@ public class FieldPacker { addI32(Float.floatToRawIntBits(v)); addI32(Float.floatToRawIntBits(v)); } } public float subF32() { return Float.intBitsToFloat(subI32()); } public void addF64(double v) { public void addF64(double v) { addI64(Double.doubleToRawLongBits(v)); addI64(Double.doubleToRawLongBits(v)); } } public double subF64() { return Double.longBitsToDouble(subI64()); } public void addObj(BaseObj obj) { public void addObj(BaseObj obj) { if (obj != null) { if (obj != null) { addI32(obj.getID(null)); addI32(obj.getID(null)); Loading Loading @@ -315,28 +394,195 @@ public class FieldPacker { addU64(v.w); 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) { public void addMatrix(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addMatrix(Matrix3f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addMatrix(Matrix2f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addBoolean(boolean v) { addI8((byte)(v ? 1 : 0)); addI8((byte)(v ? 1 : 0)); } } public boolean subBoolean() { byte v = subI8(); if (v == 1) { return true; } return false; } public final byte[] getData() { public final byte[] getData() { return mData; return mData; } } Loading @@ -344,6 +590,7 @@ public class FieldPacker { private final byte mData[]; private final byte mData[]; private int mPos; private int mPos; private int mLen; private int mLen; private BitSet mAlignment; } } Loading graphics/java/android/renderscript/RenderScript.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -582,31 +582,59 @@ public class RenderScript { validate(); validate(); rsnScriptInvokeV(mContext, id, slot, params); rsnScriptInvokeV(mContext, id, slot, params); } } native void rsnScriptSetVarI(int con, int id, int slot, int val); native void rsnScriptSetVarI(int con, int id, int slot, int val); synchronized void nScriptSetVarI(int id, int slot, int val) { synchronized void nScriptSetVarI(int id, int slot, int val) { validate(); validate(); rsnScriptSetVarI(mContext, id, slot, val); 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); native void rsnScriptSetVarJ(int con, int id, int slot, long val); synchronized void nScriptSetVarJ(int id, int slot, long val) { synchronized void nScriptSetVarJ(int id, int slot, long val) { validate(); validate(); rsnScriptSetVarJ(mContext, id, slot, val); 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); native void rsnScriptSetVarF(int con, int id, int slot, float val); synchronized void nScriptSetVarF(int id, int slot, float val) { synchronized void nScriptSetVarF(int id, int slot, float val) { validate(); validate(); rsnScriptSetVarF(mContext, id, slot, val); 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); native void rsnScriptSetVarD(int con, int id, int slot, double val); synchronized void nScriptSetVarD(int id, int slot, double val) { synchronized void nScriptSetVarD(int id, int slot, double val) { validate(); validate(); rsnScriptSetVarD(mContext, id, slot, val); 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); native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); synchronized void nScriptSetVarV(int id, int slot, byte[] val) { synchronized void nScriptSetVarV(int id, int slot, byte[] val) { validate(); validate(); rsnScriptSetVarV(mContext, id, slot, val); 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, native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val, int e, int[] dims); int e, int[] dims); synchronized void nScriptSetVarVE(int id, int slot, byte[] val, synchronized void nScriptSetVarVE(int id, int slot, byte[] val, Loading graphics/java/android/renderscript/Script.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -220,6 +220,9 @@ public class Script extends BaseObj { public void setVar(int index, float v) { public void setVar(int index, float v) { mRS.nScriptSetVarF(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -230,6 +233,9 @@ public class Script extends BaseObj { public void setVar(int index, double v) { public void setVar(int index, double v) { mRS.nScriptSetVarD(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -240,6 +246,10 @@ public class Script extends BaseObj { public void setVar(int index, int v) { public void setVar(int index, int v) { mRS.nScriptSetVarI(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -250,6 +260,10 @@ public class Script extends BaseObj { public void setVar(int index, long v) { public void setVar(int index, long v) { mRS.nScriptSetVarJ(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -260,6 +274,9 @@ public class Script extends BaseObj { public void setVar(int index, boolean v) { public void setVar(int index, boolean v) { mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0); 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. * Only intended for use by generated reflected code. Loading Loading @@ -293,6 +310,10 @@ public class Script extends BaseObj { mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims); 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) { public void setTimeZone(String timeZone) { mRS.validate(); mRS.validate(); try { try { Loading Loading
api/current.txt +35 −0 Original line number Original line Diff line number Diff line Loading @@ -20001,6 +20001,35 @@ package android.renderscript { method public void reset(); method public void reset(); method public void reset(int); method public void reset(int); method public void skip(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 { public class Float2 { Loading Loading @@ -20245,6 +20274,12 @@ package android.renderscript { method protected android.renderscript.Script.KernelID createKernelID(int, int, android.renderscript.Element, android.renderscript.Element); 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); method protected void forEach(int, android.renderscript.Allocation, android.renderscript.Allocation, android.renderscript.FieldPacker, android.renderscript.Script.LaunchOptions); 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); method protected void invoke(int, android.renderscript.FieldPacker); method protected void invoke(int, android.renderscript.FieldPacker); method public void setTimeZone(java.lang.String); method public void setTimeZone(java.lang.String);
graphics/java/android/renderscript/Allocation.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -277,14 +277,14 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Invalid usage combination."); throw new RSIllegalArgumentException("Invalid usage combination."); } } } } if (t != null) { // don't need to account for USAGE_SHARED Allocations // don't need to account for USAGE_SHARED Allocations if ((usage & USAGE_SHARED) == 0) { if ((usage & USAGE_SHARED) == 0) { int numBytes = t.getCount() * t.getElement().getBytesSize(); int numBytes = t.getCount() * t.getElement().getBytesSize(); rs.addAllocSizeForGC(numBytes); rs.addAllocSizeForGC(numBytes); mGCSize = numBytes; mGCSize = numBytes; } } } mType = t; mType = t; mUsage = usage; mUsage = usage; Loading Loading @@ -355,6 +355,12 @@ public class Allocation extends BaseObj { mType.updateFromNative(); mType.updateFromNative(); updateCacheInfo(mType); 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; } } } /** /** Loading
graphics/java/android/renderscript/FieldPacker.java +247 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.renderscript; package android.renderscript; import android.util.Log; import java.util.BitSet; /** /** * Utility class for packing arguments and structures from Android system objects to * Utility class for packing arguments and structures from Android system objects to Loading @@ -27,12 +29,14 @@ public class FieldPacker { mPos = 0; mPos = 0; mLen = len; mLen = len; mData = new byte[len]; mData = new byte[len]; mAlignment = new BitSet(); } } public FieldPacker(byte[] data) { public FieldPacker(byte[] data) { mPos = 0; mPos = 0; mLen = data.length; mLen = data.length; mData = data; mData = data; mAlignment = new BitSet(); } } public void align(int v) { public void align(int v) { Loading @@ -41,10 +45,29 @@ public class FieldPacker { } } while ((mPos & (v - 1)) != 0) { while ((mPos & (v - 1)) != 0) { mAlignment.flip(mPos); mData[mPos++] = 0; 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() { public void reset() { mPos = 0; mPos = 0; } } Loading @@ -67,12 +90,26 @@ public class FieldPacker { mData[mPos++] = v; mData[mPos++] = v; } } public byte subI8() { subalign(1); return mData[--mPos]; } public void addI16(short v) { public void addI16(short v) { align(2); align(2); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v >> 8); 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) { public void addI32(int v) { align(4); align(4); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); Loading @@ -81,6 +118,17 @@ public class FieldPacker { mData[mPos++] = (byte)((v >> 24) & 0xff); 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) { public void addI64(long v) { align(8); align(8); mData[mPos++] = (byte)(v & 0xff); mData[mPos++] = (byte)(v & 0xff); Loading @@ -93,6 +141,29 @@ public class FieldPacker { mData[mPos++] = (byte)((v >> 56) & 0xff); 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) { public void addU8(short v) { if ((v < 0) || (v > 0xff)) { if ((v < 0) || (v > 0xff)) { android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )"); android.util.Log.e("rs", "FieldPacker.addU8( " + v + " )"); Loading Loading @@ -143,10 +214,18 @@ public class FieldPacker { addI32(Float.floatToRawIntBits(v)); addI32(Float.floatToRawIntBits(v)); } } public float subF32() { return Float.intBitsToFloat(subI32()); } public void addF64(double v) { public void addF64(double v) { addI64(Double.doubleToRawLongBits(v)); addI64(Double.doubleToRawLongBits(v)); } } public double subF64() { return Double.longBitsToDouble(subI64()); } public void addObj(BaseObj obj) { public void addObj(BaseObj obj) { if (obj != null) { if (obj != null) { addI32(obj.getID(null)); addI32(obj.getID(null)); Loading Loading @@ -315,28 +394,195 @@ public class FieldPacker { addU64(v.w); 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) { public void addMatrix(Matrix4f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addMatrix(Matrix3f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addMatrix(Matrix2f v) { for (int i=0; i < v.mMat.length; i++) { for (int i=0; i < v.mMat.length; i++) { addF32(v.mMat[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) { public void addBoolean(boolean v) { addI8((byte)(v ? 1 : 0)); addI8((byte)(v ? 1 : 0)); } } public boolean subBoolean() { byte v = subI8(); if (v == 1) { return true; } return false; } public final byte[] getData() { public final byte[] getData() { return mData; return mData; } } Loading @@ -344,6 +590,7 @@ public class FieldPacker { private final byte mData[]; private final byte mData[]; private int mPos; private int mPos; private int mLen; private int mLen; private BitSet mAlignment; } } Loading
graphics/java/android/renderscript/RenderScript.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -582,31 +582,59 @@ public class RenderScript { validate(); validate(); rsnScriptInvokeV(mContext, id, slot, params); rsnScriptInvokeV(mContext, id, slot, params); } } native void rsnScriptSetVarI(int con, int id, int slot, int val); native void rsnScriptSetVarI(int con, int id, int slot, int val); synchronized void nScriptSetVarI(int id, int slot, int val) { synchronized void nScriptSetVarI(int id, int slot, int val) { validate(); validate(); rsnScriptSetVarI(mContext, id, slot, val); 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); native void rsnScriptSetVarJ(int con, int id, int slot, long val); synchronized void nScriptSetVarJ(int id, int slot, long val) { synchronized void nScriptSetVarJ(int id, int slot, long val) { validate(); validate(); rsnScriptSetVarJ(mContext, id, slot, val); 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); native void rsnScriptSetVarF(int con, int id, int slot, float val); synchronized void nScriptSetVarF(int id, int slot, float val) { synchronized void nScriptSetVarF(int id, int slot, float val) { validate(); validate(); rsnScriptSetVarF(mContext, id, slot, val); 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); native void rsnScriptSetVarD(int con, int id, int slot, double val); synchronized void nScriptSetVarD(int id, int slot, double val) { synchronized void nScriptSetVarD(int id, int slot, double val) { validate(); validate(); rsnScriptSetVarD(mContext, id, slot, val); 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); native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); synchronized void nScriptSetVarV(int id, int slot, byte[] val) { synchronized void nScriptSetVarV(int id, int slot, byte[] val) { validate(); validate(); rsnScriptSetVarV(mContext, id, slot, val); 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, native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val, int e, int[] dims); int e, int[] dims); synchronized void nScriptSetVarVE(int id, int slot, byte[] val, synchronized void nScriptSetVarVE(int id, int slot, byte[] val, Loading
graphics/java/android/renderscript/Script.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -220,6 +220,9 @@ public class Script extends BaseObj { public void setVar(int index, float v) { public void setVar(int index, float v) { mRS.nScriptSetVarF(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -230,6 +233,9 @@ public class Script extends BaseObj { public void setVar(int index, double v) { public void setVar(int index, double v) { mRS.nScriptSetVarD(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -240,6 +246,10 @@ public class Script extends BaseObj { public void setVar(int index, int v) { public void setVar(int index, int v) { mRS.nScriptSetVarI(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -250,6 +260,10 @@ public class Script extends BaseObj { public void setVar(int index, long v) { public void setVar(int index, long v) { mRS.nScriptSetVarJ(getID(mRS), index, 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. * Only intended for use by generated reflected code. Loading @@ -260,6 +274,9 @@ public class Script extends BaseObj { public void setVar(int index, boolean v) { public void setVar(int index, boolean v) { mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0); 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. * Only intended for use by generated reflected code. Loading Loading @@ -293,6 +310,10 @@ public class Script extends BaseObj { mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims); 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) { public void setTimeZone(String timeZone) { mRS.validate(); mRS.validate(); try { try { Loading