am cd263b5c: Merge change 26322 into eclair
Merge commit 'cd263b5c072703e80fe43e46baa831304441369b' into eclair-plus-aosp * commit 'cd263b5c072703e80fe43e46baa831304441369b': Implement more type checks on Allocations.
This commit is contained in:
@@ -48,50 +48,49 @@ public class Allocation extends BaseObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void data(int[] d) {
|
public void data(int[] d) {
|
||||||
int size;
|
subData1D(0, mType.getElementCount(), d);
|
||||||
if(mType != null && mType.mElement != null) {
|
}
|
||||||
size = mType.mElement.mSize;
|
public void data(short[] d) {
|
||||||
for(int ct=0; ct < mType.mValues.length; ct++) {
|
subData1D(0, mType.getElementCount(), d);
|
||||||
if(mType.mValues[ct] != 0) {
|
}
|
||||||
size *= mType.mValues[ct];
|
public void data(byte[] d) {
|
||||||
}
|
subData1D(0, mType.getElementCount(), d);
|
||||||
}
|
}
|
||||||
if((d.length * 4) < size) {
|
public void data(float[] d) {
|
||||||
throw new IllegalArgumentException("Array too small for allocation type.");
|
subData1D(0, mType.getElementCount(), d);
|
||||||
}
|
|
||||||
Log.e("rs", "Alloc data size=" + size);
|
|
||||||
mRS.nAllocationData(mID, d, size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mRS.nAllocationData(mID, d, d.length * 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void data(float[] d) {
|
private void data1DChecks(int off, int count, int len, int dataSize) {
|
||||||
int size;
|
if((off < 0) || (count < 1) || ((off + count) > mType.getElementCount())) {
|
||||||
if(mType != null && mType.mElement != null) {
|
throw new IllegalArgumentException("Offset or Count out of bounds.");
|
||||||
size = mType.mElement.mSize;
|
}
|
||||||
for(int ct=0; ct < mType.mValues.length; ct++) {
|
if((len) < dataSize) {
|
||||||
if(mType.mValues[ct] != 0) {
|
throw new IllegalArgumentException("Array too small for allocation type.");
|
||||||
size *= mType.mValues[ct];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if((d.length * 4) < size) {
|
|
||||||
throw new IllegalArgumentException("Array too small for allocation type.");
|
|
||||||
}
|
|
||||||
Log.e("rs", "Alloc data size=" + size);
|
|
||||||
mRS.nAllocationData(mID, d, size);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
mRS.nAllocationData(mID, d, d.length * 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData1D(int off, int count, int[] d) {
|
public void subData1D(int off, int count, int[] d) {
|
||||||
mRS.nAllocationSubData1D(mID, off, count, d, count * 4);
|
int dataSize = mType.mElement.getSizeBytes() * count;
|
||||||
|
data1DChecks(off, count, d.length * 4, dataSize);
|
||||||
|
mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
|
||||||
|
}
|
||||||
|
public void subData1D(int off, int count, short[] d) {
|
||||||
|
int dataSize = mType.mElement.getSizeBytes() * count;
|
||||||
|
data1DChecks(off, count, d.length * 2, dataSize);
|
||||||
|
mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
|
||||||
|
}
|
||||||
|
public void subData1D(int off, int count, byte[] d) {
|
||||||
|
int dataSize = mType.mElement.getSizeBytes() * count;
|
||||||
|
data1DChecks(off, count, d.length, dataSize);
|
||||||
|
mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
|
||||||
|
}
|
||||||
|
public void subData1D(int off, int count, float[] d) {
|
||||||
|
int dataSize = mType.mElement.getSizeBytes() * count;
|
||||||
|
data1DChecks(off, count, d.length * 4, dataSize);
|
||||||
|
mRS.nAllocationSubData1D(mID, off, count, d, dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData1D(int off, int count, float[] d) {
|
|
||||||
mRS.nAllocationSubData1D(mID, off, count, d, d.length * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
|
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
|
||||||
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
|
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
|
||||||
@@ -213,11 +212,15 @@ public class Allocation extends BaseObj {
|
|||||||
static public Allocation createSized(RenderScript rs, Element e, int count)
|
static public Allocation createSized(RenderScript rs, Element e, int count)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
int id = rs.nAllocationCreateSized(e.mID, count);
|
Type.Builder b = new Type.Builder(rs, e);
|
||||||
|
b.add(Dimension.X, count);
|
||||||
|
Type t = b.create();
|
||||||
|
|
||||||
|
int id = rs.nAllocationCreateTyped(t.mID);
|
||||||
if(id == 0) {
|
if(id == 0) {
|
||||||
throw new IllegalStateException("Bad element.");
|
throw new IllegalStateException("Bad element.");
|
||||||
}
|
}
|
||||||
return new Allocation(id, rs, null);
|
return new Allocation(id, rs, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
|
static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
|
||||||
|
|||||||
@@ -26,18 +26,40 @@ public class Element extends BaseObj {
|
|||||||
int mSize;
|
int mSize;
|
||||||
Entry[] mEntries;
|
Entry[] mEntries;
|
||||||
|
|
||||||
|
int getSizeBytes() {
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
int getComponentCount() {
|
||||||
|
return mEntries.length;
|
||||||
|
}
|
||||||
|
Element.DataType getComponentDataType(int num) {
|
||||||
|
return mEntries[num].mType;
|
||||||
|
}
|
||||||
|
Element.DataKind getComponentDataKind(int num) {
|
||||||
|
return mEntries[num].mKind;
|
||||||
|
}
|
||||||
|
boolean getComponentIsNormalized(int num) {
|
||||||
|
return mEntries[num].mIsNormalized;
|
||||||
|
}
|
||||||
|
int getComponentBits(int num) {
|
||||||
|
return mEntries[num].mBits;
|
||||||
|
}
|
||||||
|
String getComponentName(int num) {
|
||||||
|
return mEntries[num].mName;
|
||||||
|
}
|
||||||
|
|
||||||
static class Entry {
|
static class Entry {
|
||||||
Element mElement;
|
//Element mElement;
|
||||||
Element.DataType mType;
|
Element.DataType mType;
|
||||||
Element.DataKind mKind;
|
Element.DataKind mKind;
|
||||||
boolean mIsNormalized;
|
boolean mIsNormalized;
|
||||||
int mBits;
|
int mBits;
|
||||||
String mName;
|
String mName;
|
||||||
|
|
||||||
Entry(Element e, int bits) {
|
//Entry(Element e, int bits) {
|
||||||
mElement = e;
|
//mElement = e;
|
||||||
int mBits = bits;
|
//int mBits = bits;
|
||||||
}
|
//}
|
||||||
|
|
||||||
Entry(DataType dt, DataKind dk, boolean isNorm, int bits, String name) {
|
Entry(DataType dt, DataKind dk, boolean isNorm, int bits, String name) {
|
||||||
mType = dt;
|
mType = dt;
|
||||||
@@ -266,14 +288,11 @@ public class Element extends BaseObj {
|
|||||||
int bits = 0;
|
int bits = 0;
|
||||||
for (int ct=0; ct < e.mEntries.length; ct++) {
|
for (int ct=0; ct < e.mEntries.length; ct++) {
|
||||||
Entry en = e.mEntries[ct];
|
Entry en = e.mEntries[ct];
|
||||||
if(en.mElement != null) {
|
//if(en.mElement != null) {
|
||||||
//rs.nElementAdd(en.mElement.mID);
|
//rs.nElementAdd(en.mElement.mID);
|
||||||
} else {
|
//} else
|
||||||
int norm = 0;
|
{
|
||||||
if (en.mIsNormalized) {
|
rs.nElementAdd(en.mKind.mID, en.mType.mID, en.mIsNormalized, en.mBits, en.mName);
|
||||||
norm = 1;
|
|
||||||
}
|
|
||||||
rs.nElementAdd(en.mKind.mID, en.mType.mID, norm, en.mBits, en.mName);
|
|
||||||
bits += en.mBits;
|
bits += en.mBits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,11 +327,11 @@ public class Element extends BaseObj {
|
|||||||
mEntryCount++;
|
mEntryCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder add(Element e) throws IllegalArgumentException {
|
//public Builder add(Element e) throws IllegalArgumentException {
|
||||||
Entry en = new Entry(e, e.mSize * 8);
|
//Entry en = new Entry(e, e.mSize * 8);
|
||||||
addEntry(en);
|
//addEntry(en);
|
||||||
return this;
|
//return this;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public Builder add(Element.DataType dt, Element.DataKind dk, boolean isNormalized, int bits, String name) {
|
public Builder add(Element.DataType dt, Element.DataKind dk, boolean isNormalized, int bits, String name) {
|
||||||
Entry en = new Entry(dt, dk, isNormalized, bits, name);
|
Entry en = new Entry(dt, dk, isNormalized, bits, name);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class RenderScript {
|
|||||||
native int nFileOpen(byte[] name);
|
native int nFileOpen(byte[] name);
|
||||||
|
|
||||||
native void nElementBegin();
|
native void nElementBegin();
|
||||||
native void nElementAdd(int kind, int type, int norm, int bits, String s);
|
native void nElementAdd(int kind, int type, boolean norm, int bits, String s);
|
||||||
native int nElementCreate();
|
native int nElementCreate();
|
||||||
|
|
||||||
native void nTypeBegin(int elementID);
|
native void nTypeBegin(int elementID);
|
||||||
@@ -90,17 +90,19 @@ public class RenderScript {
|
|||||||
native void nTypeSetupFields(Type t, int[] types, int[] bits, Field[] IDs);
|
native void nTypeSetupFields(Type t, int[] types, int[] bits, Field[] IDs);
|
||||||
|
|
||||||
native int nAllocationCreateTyped(int type);
|
native int nAllocationCreateTyped(int type);
|
||||||
native int nAllocationCreateSized(int elem, int count);
|
//native int nAllocationCreateSized(int elem, int count);
|
||||||
native int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp);
|
native int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp);
|
||||||
native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
|
native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
|
||||||
native int nAllocationCreateFromAssetStream(int dstFmt, boolean genMips, int assetStream);
|
native int nAllocationCreateFromAssetStream(int dstFmt, boolean genMips, int assetStream);
|
||||||
|
|
||||||
native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
|
native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
|
||||||
native void nAllocationUploadToBufferObject(int alloc);
|
native void nAllocationUploadToBufferObject(int alloc);
|
||||||
native void nAllocationData(int id, int[] d, int sizeBytes);
|
|
||||||
native void nAllocationData(int id, float[] d, int sizeBytes);
|
|
||||||
native void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes);
|
native void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes);
|
||||||
|
native void nAllocationSubData1D(int id, int off, int count, short[] d, int sizeBytes);
|
||||||
|
native void nAllocationSubData1D(int id, int off, int count, byte[] d, int sizeBytes);
|
||||||
native void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes);
|
native void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes);
|
||||||
|
|
||||||
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes);
|
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes);
|
||||||
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes);
|
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes);
|
||||||
native void nAllocationRead(int id, int[] d);
|
native void nAllocationRead(int id, int[] d);
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ public class SimpleMesh extends BaseObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SimpleMesh create() {
|
public SimpleMesh create() {
|
||||||
Log.e("rs", "SimpleMesh create");
|
|
||||||
SimpleMesh sm = internalCreate(mRS, this);
|
SimpleMesh sm = internalCreate(mRS, this);
|
||||||
sm.mVertexTypes = new Type[mVertexTypeCount];
|
sm.mVertexTypes = new Type[mVertexTypeCount];
|
||||||
for(int ct=0; ct < mVertexTypeCount; ct++) {
|
for(int ct=0; ct < mVertexTypeCount; ct++) {
|
||||||
@@ -177,7 +176,7 @@ public class SimpleMesh extends BaseObj {
|
|||||||
public static class TriangleMeshBuilder {
|
public static class TriangleMeshBuilder {
|
||||||
float mVtxData[];
|
float mVtxData[];
|
||||||
int mVtxCount;
|
int mVtxCount;
|
||||||
int mIndexData[];
|
short mIndexData[];
|
||||||
int mIndexCount;
|
int mIndexCount;
|
||||||
RenderScript mRS;
|
RenderScript mRS;
|
||||||
Element mElement;
|
Element mElement;
|
||||||
@@ -191,7 +190,7 @@ public class SimpleMesh extends BaseObj {
|
|||||||
mVtxCount = 0;
|
mVtxCount = 0;
|
||||||
mIndexCount = 0;
|
mIndexCount = 0;
|
||||||
mVtxData = new float[128];
|
mVtxData = new float[128];
|
||||||
mIndexData = new int[128];
|
mIndexData = new short[128];
|
||||||
mVtxSize = vtxSize;
|
mVtxSize = vtxSize;
|
||||||
mNorm = norm;
|
mNorm = norm;
|
||||||
mTex = tex;
|
mTex = tex;
|
||||||
@@ -268,13 +267,13 @@ public class SimpleMesh extends BaseObj {
|
|||||||
|
|
||||||
public void addTriangle(int idx1, int idx2, int idx3) {
|
public void addTriangle(int idx1, int idx2, int idx3) {
|
||||||
if((mIndexCount + 3) >= mIndexData.length) {
|
if((mIndexCount + 3) >= mIndexData.length) {
|
||||||
int t[] = new int[mIndexData.length * 2];
|
short t[] = new short[mIndexData.length * 2];
|
||||||
System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
|
System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
|
||||||
mIndexData = t;
|
mIndexData = t;
|
||||||
}
|
}
|
||||||
mIndexData[mIndexCount++] = idx1;
|
mIndexData[mIndexCount++] = (short)idx1;
|
||||||
mIndexData[mIndexCount++] = idx2;
|
mIndexData[mIndexCount++] = (short)idx2;
|
||||||
mIndexData[mIndexCount++] = idx3;
|
mIndexData[mIndexCount++] = (short)idx3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleMesh create() {
|
public SimpleMesh create() {
|
||||||
@@ -309,10 +308,6 @@ public class SimpleMesh extends BaseObj {
|
|||||||
vertexAlloc.data(mVtxData);
|
vertexAlloc.data(mVtxData);
|
||||||
vertexAlloc.uploadToBufferObject();
|
vertexAlloc.uploadToBufferObject();
|
||||||
|
|
||||||
// This is safe because length is a pow2
|
|
||||||
for(int ct=0; ct < (mIndexCount+1); ct += 2) {
|
|
||||||
mIndexData[ct >> 1] = mIndexData[ct] | (mIndexData[ct+1] << 16);
|
|
||||||
}
|
|
||||||
indexAlloc.data(mIndexData);
|
indexAlloc.data(mIndexData);
|
||||||
indexAlloc.uploadToBufferObject();
|
indexAlloc.uploadToBufferObject();
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,74 @@ import java.lang.reflect.Field;
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
public class Type extends BaseObj {
|
public class Type extends BaseObj {
|
||||||
Dimension[] mDimensions;
|
int mDimX;
|
||||||
int[] mValues;
|
int mDimY;
|
||||||
|
int mDimZ;
|
||||||
|
boolean mDimLOD;
|
||||||
|
boolean mDimFaces;
|
||||||
|
int mElementCount;
|
||||||
Element mElement;
|
Element mElement;
|
||||||
|
|
||||||
private int mNativeCache;
|
private int mNativeCache;
|
||||||
Class mJavaClass;
|
Class mJavaClass;
|
||||||
|
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return mDimX;
|
||||||
|
}
|
||||||
|
public int getY() {
|
||||||
|
return mDimY;
|
||||||
|
}
|
||||||
|
public int getZ() {
|
||||||
|
return mDimZ;
|
||||||
|
}
|
||||||
|
public boolean getLOD() {
|
||||||
|
return mDimLOD;
|
||||||
|
}
|
||||||
|
public boolean getFaces() {
|
||||||
|
return mDimFaces;
|
||||||
|
}
|
||||||
|
public int getElementCount() {
|
||||||
|
return mElementCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void calcElementCount() {
|
||||||
|
boolean hasLod = getLOD();
|
||||||
|
int x = getX();
|
||||||
|
int y = getY();
|
||||||
|
int z = getZ();
|
||||||
|
int faces = 1;
|
||||||
|
if(getFaces()) {
|
||||||
|
faces = 6;
|
||||||
|
}
|
||||||
|
if(x == 0) {
|
||||||
|
x = 1;
|
||||||
|
}
|
||||||
|
if(y == 0) {
|
||||||
|
y = 1;
|
||||||
|
}
|
||||||
|
if(z == 0) {
|
||||||
|
z = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = x * y * z * faces;
|
||||||
|
if(hasLod && (x > 1) && (y > 1) && (z > 1)) {
|
||||||
|
if(x > 1) {
|
||||||
|
x >>= 1;
|
||||||
|
}
|
||||||
|
if(y > 1) {
|
||||||
|
y >>= 1;
|
||||||
|
}
|
||||||
|
if(z > 1) {
|
||||||
|
z >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
count += x * y * z * faces;
|
||||||
|
}
|
||||||
|
mElementCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Type(int id, RenderScript rs) {
|
Type(int id, RenderScript rs) {
|
||||||
super(rs);
|
super(rs);
|
||||||
mID = id;
|
mID = id;
|
||||||
@@ -131,12 +192,25 @@ public class Type extends BaseObj {
|
|||||||
public Type create() {
|
public Type create() {
|
||||||
Type t = internalCreate(mRS, this);
|
Type t = internalCreate(mRS, this);
|
||||||
t.mElement = mElement;
|
t.mElement = mElement;
|
||||||
t.mDimensions = new Dimension[mEntryCount];
|
|
||||||
t.mValues = new int[mEntryCount];
|
|
||||||
for(int ct=0; ct < mEntryCount; ct++) {
|
for(int ct=0; ct < mEntryCount; ct++) {
|
||||||
t.mDimensions[ct] = mEntries[ct].mDim;
|
if(mEntries[ct].mDim == Dimension.X) {
|
||||||
t.mValues[ct] = mEntries[ct].mValue;
|
t.mDimX = mEntries[ct].mValue;
|
||||||
|
}
|
||||||
|
if(mEntries[ct].mDim == Dimension.Y) {
|
||||||
|
t.mDimY = mEntries[ct].mValue;
|
||||||
|
}
|
||||||
|
if(mEntries[ct].mDim == Dimension.Z) {
|
||||||
|
t.mDimZ = mEntries[ct].mValue;
|
||||||
|
}
|
||||||
|
if(mEntries[ct].mDim == Dimension.LOD) {
|
||||||
|
t.mDimLOD = mEntries[ct].mValue != 0;
|
||||||
|
}
|
||||||
|
if(mEntries[ct].mDim == Dimension.FACE) {
|
||||||
|
t.mDimFaces = mEntries[ct].mValue != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
t.calcElementCount();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ nElementBegin(JNIEnv *_env, jobject _this)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nElementAdd(JNIEnv *_env, jobject _this, jint kind, jint type, jint norm, jint bits, jstring name)
|
nElementAdd(JNIEnv *_env, jobject _this, jint kind, jint type, jboolean norm, jint bits, jstring name)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
const char* n = NULL;
|
const char* n = NULL;
|
||||||
@@ -359,14 +359,6 @@ nAllocationCreateTyped(JNIEnv *_env, jobject _this, jint e)
|
|||||||
return (jint) rsAllocationCreateTyped(con, (RsElement)e);
|
return (jint) rsAllocationCreateTyped(con, (RsElement)e);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint
|
|
||||||
nAllocationCreateSized(JNIEnv *_env, jobject _this, jint e, jint count)
|
|
||||||
{
|
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
|
||||||
LOG_API("nAllocationCreateSized, con(%p), e(%p), count(%i)", con, (RsElement)e, count);
|
|
||||||
return (jint) rsAllocationCreateSized(con, (RsElement)e, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip)
|
nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip)
|
||||||
{
|
{
|
||||||
@@ -475,45 +467,45 @@ nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jbool
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data, int sizeBytes)
|
|
||||||
{
|
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
|
||||||
jint len = _env->GetArrayLength(data);
|
|
||||||
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
|
||||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
|
||||||
rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
|
|
||||||
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data, int sizeBytes)
|
|
||||||
{
|
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
|
||||||
jint len = _env->GetArrayLength(data);
|
|
||||||
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
|
||||||
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
|
||||||
rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
|
|
||||||
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
|
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
|
||||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
||||||
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nAllocationSubData1D_s(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jshortArray data, int sizeBytes)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
jint len = _env->GetArrayLength(data);
|
||||||
|
LOG_API("nAllocation1DSubData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
|
||||||
|
jshort *ptr = _env->GetShortArrayElements(data, NULL);
|
||||||
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
|
_env->ReleaseShortArrayElements(data, ptr, JNI_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nAllocationSubData1D_b(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jbyteArray data, int sizeBytes)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
jint len = _env->GetArrayLength(data);
|
||||||
|
LOG_API("nAllocation1DSubData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
|
||||||
|
jbyte *ptr = _env->GetByteArrayElements(data, NULL);
|
||||||
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
|
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes)
|
nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes);
|
||||||
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
||||||
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
||||||
@@ -1323,7 +1315,7 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nFileOpen", "([B)I", (void*)nFileOpen },
|
{"nFileOpen", "([B)I", (void*)nFileOpen },
|
||||||
|
|
||||||
{"nElementBegin", "()V", (void*)nElementBegin },
|
{"nElementBegin", "()V", (void*)nElementBegin },
|
||||||
{"nElementAdd", "(IIIILjava/lang/String;)V", (void*)nElementAdd },
|
{"nElementAdd", "(IIZILjava/lang/String;)V", (void*)nElementAdd },
|
||||||
{"nElementCreate", "()I", (void*)nElementCreate },
|
{"nElementCreate", "()I", (void*)nElementCreate },
|
||||||
|
|
||||||
{"nTypeBegin", "(I)V", (void*)nTypeBegin },
|
{"nTypeBegin", "(I)V", (void*)nTypeBegin },
|
||||||
@@ -1333,15 +1325,14 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nTypeSetupFields", "(Landroid/renderscript/Type;[I[I[Ljava/lang/reflect/Field;)V", (void*)nTypeSetupFields },
|
{"nTypeSetupFields", "(Landroid/renderscript/Type;[I[I[Ljava/lang/reflect/Field;)V", (void*)nTypeSetupFields },
|
||||||
|
|
||||||
{"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped },
|
{"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped },
|
||||||
{"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized },
|
|
||||||
{"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
|
{"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
|
||||||
{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
|
{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
|
||||||
{"nAllocationCreateFromAssetStream","(IZI)I", (void*)nAllocationCreateFromAssetStream },
|
{"nAllocationCreateFromAssetStream","(IZI)I", (void*)nAllocationCreateFromAssetStream },
|
||||||
{"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture },
|
{"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture },
|
||||||
{"nAllocationUploadToBufferObject","(I)V", (void*)nAllocationUploadToBufferObject },
|
{"nAllocationUploadToBufferObject","(I)V", (void*)nAllocationUploadToBufferObject },
|
||||||
{"nAllocationData", "(I[II)V", (void*)nAllocationData_i },
|
|
||||||
{"nAllocationData", "(I[FI)V", (void*)nAllocationData_f },
|
|
||||||
{"nAllocationSubData1D", "(III[II)V", (void*)nAllocationSubData1D_i },
|
{"nAllocationSubData1D", "(III[II)V", (void*)nAllocationSubData1D_i },
|
||||||
|
{"nAllocationSubData1D", "(III[SI)V", (void*)nAllocationSubData1D_s },
|
||||||
|
{"nAllocationSubData1D", "(III[BI)V", (void*)nAllocationSubData1D_b },
|
||||||
{"nAllocationSubData1D", "(III[FI)V", (void*)nAllocationSubData1D_f },
|
{"nAllocationSubData1D", "(III[FI)V", (void*)nAllocationSubData1D_f },
|
||||||
{"nAllocationSubData2D", "(IIIII[II)V", (void*)nAllocationSubData2D_i },
|
{"nAllocationSubData2D", "(IIIII[II)V", (void*)nAllocationSubData2D_i },
|
||||||
{"nAllocationSubData2D", "(IIIII[FI)V", (void*)nAllocationSubData2D_f },
|
{"nAllocationSubData2D", "(IIIII[FI)V", (void*)nAllocationSubData2D_f },
|
||||||
|
|||||||
Reference in New Issue
Block a user