summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/Allocation.java60
-rw-r--r--graphics/java/android/renderscript/Element.java122
-rw-r--r--graphics/java/android/renderscript/RenderScript.java13
-rw-r--r--graphics/java/android/renderscript/SimpleMesh.java145
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp61
5 files changed, 322 insertions, 79 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 81848b9..3001c743 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -47,28 +47,62 @@ public class Allocation extends BaseObj {
mRS.nAllocationUploadToTexture(mID, baseMipLevel);
}
+ public void uploadToBufferObject() {
+ mRS.nAllocationUploadToBufferObject(mID);
+ }
+
public void data(int[] d) {
- mRS.nAllocationData(mID, d);
+ int size = 0;
+ if(mType != null && mType.mElement != null) {
+ size = mType.mElement.mSize;
+ for(int ct=0; ct < mType.mValues.length; ct++) {
+ if(mType.mValues[ct] != 0) {
+ 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 data(float[] d) {
- mRS.nAllocationData(mID, d);
+ int size = 0;
+ if(mType != null && mType.mElement != null) {
+ size = mType.mElement.mSize;
+ for(int ct=0; ct < mType.mValues.length; ct++) {
+ if(mType.mValues[ct] != 0) {
+ 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) {
- mRS.nAllocationSubData1D(mID, off, count, d);
+ mRS.nAllocationSubData1D(mID, off, count, d, count * 4);
}
public void subData1D(int off, int count, float[] d) {
- mRS.nAllocationSubData1D(mID, off, count, d);
+ mRS.nAllocationSubData1D(mID, off, count, d, d.length * 4);
}
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
- mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d);
+ mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
}
public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
- mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d);
+ mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
}
public void readData(int[] d) {
@@ -221,20 +255,6 @@ public class Allocation extends BaseObj {
Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
return createFromBitmapBoxed(rs, b, dstFmt, genMips);
}
-/*
- public static Allocation createFromObject(RenderScript rs, Object o) {
- Class c = o.getClass();
- Type t;
- if(c.isArray()) {
- t = Type.createFromClass(rs, c, Array.getLength(o));
- } else {
- t = Type.createFromClass(rs, c, 1);
- }
- Allocation alloc = createTyped(rs, t);
- t.destroy();
- return alloc;
- }
-*/
}
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index aeec739..0ca112c 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -25,30 +25,31 @@ import java.lang.reflect.Field;
public class Element extends BaseObj {
final int mPredefinedID;
final boolean mIsPredefined;
-
- public static final Element USER_U8 = new Element(0);
- public static final Element USER_I8 = new Element(1);
- public static final Element USER_U16 = new Element(2);
- public static final Element USER_I16 = new Element(3);
- public static final Element USER_U32 = new Element(4);
- public static final Element USER_I32 = new Element(5);
- public static final Element USER_FLOAT = new Element(6);
-
- public static final Element A_8 = new Element(7);
- public static final Element RGB_565 = new Element(8);
- public static final Element RGB_888 = new Element(11);
- public static final Element RGBA_5551 = new Element(9);
- public static final Element RGBA_4444 = new Element(10);
- public static final Element RGBA_8888 = new Element(12);
-
- public static final Element INDEX_16 = new Element(13);
- public static final Element INDEX_32 = new Element(14);
- public static final Element XY_F32 = new Element(15);
- public static final Element XYZ_F32 = new Element(16);
- public static final Element ST_XY_F32 = new Element(17);
- public static final Element ST_XYZ_F32 = new Element(18);
- public static final Element NORM_XYZ_F32 = new Element(19);
- public static final Element NORM_ST_XYZ_F32 = new Element(20);
+ final int mSize;
+
+ public static final Element USER_U8 = new Element(0, 1);
+ public static final Element USER_I8 = new Element(1, 1);
+ public static final Element USER_U16 = new Element(2, 2);
+ public static final Element USER_I16 = new Element(3, 2);
+ public static final Element USER_U32 = new Element(4, 4);
+ public static final Element USER_I32 = new Element(5, 4);
+ public static final Element USER_FLOAT = new Element(6, 4);
+
+ public static final Element A_8 = new Element(7, 1);
+ public static final Element RGB_565 = new Element(8, 2);
+ public static final Element RGB_888 = new Element(11, 2);
+ public static final Element RGBA_5551 = new Element(9, 2);
+ public static final Element RGBA_4444 = new Element(10, 2);
+ public static final Element RGBA_8888 = new Element(12, 4);
+
+ public static final Element INDEX_16 = new Element(13, 2);
+ public static final Element INDEX_32 = new Element(14, 2);
+ public static final Element XY_F32 = new Element(15, 8);
+ public static final Element XYZ_F32 = new Element(16, 12);
+ public static final Element ST_XY_F32 = new Element(17, 16);
+ public static final Element ST_XYZ_F32 = new Element(18, 20);
+ public static final Element NORM_XYZ_F32 = new Element(19, 24);
+ public static final Element NORM_ST_XYZ_F32 = new Element(20, 32);
void initPredef(RenderScript rs) {
mID = rs.nElementGetPredefined(mPredefinedID);
@@ -121,18 +122,20 @@ public class Element extends BaseObj {
}
- Element(int predef) {
+ Element(int predef, int size) {
super(null);
mID = 0;
mPredefinedID = predef;
mIsPredefined = true;
+ mSize = size;
}
- Element(int id, RenderScript rs) {
+ Element(int id, RenderScript rs, int size) {
super(rs);
mID = id;
mPredefinedID = 0;
mIsPredefined = false;
+ mSize = size;
}
public void destroy() throws IllegalStateException {
@@ -168,6 +171,7 @@ public class Element extends BaseObj {
RenderScript mRS;
Entry[] mEntries;
int mEntryCount;
+ int mSizeBits;
private class Entry {
Element mElement;
@@ -182,6 +186,7 @@ public class Element extends BaseObj {
mRS = rs;
mEntryCount = 0;
mEntries = new Entry[8];
+ mSizeBits = 0;
}
void addEntry(Entry e) {
@@ -201,6 +206,7 @@ public class Element extends BaseObj {
Entry en = new Entry();
en.mElement = e;
addEntry(en);
+ mSizeBits += e.mSize * 8;
return this;
}
@@ -211,6 +217,7 @@ public class Element extends BaseObj {
en.mIsNormalized = isNormalized;
en.mBits = bits;
en.mName = name;
+ mSizeBits += bits;
addEntry(en);
return this;
}
@@ -236,6 +243,12 @@ public class Element extends BaseObj {
return this;
}
+ public Builder addFloatXY(String prefix) {
+ add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
+ add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
+ return this;
+ }
+
public Builder addFloatXYZ() {
add(DataType.FLOAT, DataKind.X, false, 32, null);
add(DataType.FLOAT, DataKind.Y, false, 32, null);
@@ -243,17 +256,49 @@ public class Element extends BaseObj {
return this;
}
+ public Builder addFloatXYZ(String prefix) {
+ add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
+ add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
+ add(DataType.FLOAT, DataKind.Z, false, 32, prefix + "Z");
+ return this;
+ }
+
public Builder addFloatST() {
add(DataType.FLOAT, DataKind.S, false, 32, null);
add(DataType.FLOAT, DataKind.T, false, 32, null);
return this;
}
+ public Builder addFloatST(String prefix) {
+ add(DataType.FLOAT, DataKind.S, false, 32, prefix + "S");
+ add(DataType.FLOAT, DataKind.T, false, 32, prefix + "T");
+ return this;
+ }
+
+ public Builder addFloatNorm() {
+ add(DataType.FLOAT, DataKind.NX, false, 32, null);
+ add(DataType.FLOAT, DataKind.NY, false, 32, null);
+ add(DataType.FLOAT, DataKind.NZ, false, 32, null);
+ return this;
+ }
+
+ public Builder addFloatNorm(String prefix) {
+ add(DataType.FLOAT, DataKind.NX, false, 32, prefix + "NX");
+ add(DataType.FLOAT, DataKind.NY, false, 32, prefix + "NY");
+ add(DataType.FLOAT, DataKind.NZ, false, 32, prefix + "NZ");
+ return this;
+ }
+
public Builder addFloatPointSize() {
add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, null);
return this;
}
+ public Builder addFloatPointSize(String name) {
+ add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, name);
+ return this;
+ }
+
public Builder addFloatRGB() {
add(DataType.FLOAT, DataKind.RED, false, 32, null);
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
@@ -261,6 +306,13 @@ public class Element extends BaseObj {
return this;
}
+ public Builder addFloatRGB(String prefix) {
+ add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
+ add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
+ add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
+ return this;
+ }
+
public Builder addFloatRGBA() {
add(DataType.FLOAT, DataKind.RED, false, 32, null);
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
@@ -269,6 +321,14 @@ public class Element extends BaseObj {
return this;
}
+ public Builder addFloatRGBA(String prefix) {
+ add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
+ add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
+ add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
+ add(DataType.FLOAT, DataKind.ALPHA, false, 32, prefix + "A");
+ return this;
+ }
+
public Builder addUNorm8RGBA() {
add(DataType.UNSIGNED, DataKind.RED, true, 8, null);
add(DataType.UNSIGNED, DataKind.GREEN, true, 8, null);
@@ -277,6 +337,14 @@ public class Element extends BaseObj {
return this;
}
+ public Builder addUNorm8RGBA(String prefix) {
+ add(DataType.UNSIGNED, DataKind.RED, true, 8, prefix + "R");
+ add(DataType.UNSIGNED, DataKind.GREEN, true, 8, prefix + "G");
+ add(DataType.UNSIGNED, DataKind.BLUE, true, 8, prefix + "B");
+ add(DataType.UNSIGNED, DataKind.ALPHA, true, 8, prefix + "A");
+ return this;
+ }
+
static synchronized Element internalCreate(RenderScript rs, Builder b) {
rs.nElementBegin();
for (int ct=0; ct < b.mEntryCount; ct++) {
@@ -292,7 +360,7 @@ public class Element extends BaseObj {
}
}
int id = rs.nElementCreate();
- return new Element(id, rs);
+ return new Element(id, rs, (b.mSizeBits + 7) >> 3);
}
public Element create() {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 84890038..ee7b702 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -97,12 +97,13 @@ public class RenderScript {
native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
- native void nAllocationData(int id, int[] d);
- native void nAllocationData(int id, float[] d);
- native void nAllocationSubData1D(int id, int off, int count, int[] d);
- native void nAllocationSubData1D(int id, int off, int count, float[] d);
- native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d);
- native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d);
+ 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, 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, float[] d, int sizeBytes);
native void nAllocationRead(int id, int[] d);
native void nAllocationRead(int id, float[] d);
native void nAllocationDataFromObject(int id, Type t, Object o);
diff --git a/graphics/java/android/renderscript/SimpleMesh.java b/graphics/java/android/renderscript/SimpleMesh.java
index d80551e..e66fb8a 100644
--- a/graphics/java/android/renderscript/SimpleMesh.java
+++ b/graphics/java/android/renderscript/SimpleMesh.java
@@ -167,5 +167,150 @@ public class SimpleMesh extends BaseObj {
}
}
+ public static class TriangleMeshBuilder {
+ float mVtxData[];
+ int mVtxCount;
+ int mIndexData[];
+ int mIndexCount;
+ RenderScript mRS;
+ Element mElement;
+
+ int mVtxSize;
+ boolean mNorm;
+ boolean mTex;
+
+ public TriangleMeshBuilder(RenderScript rs, int vtxSize, boolean norm, boolean tex) {
+ mRS = rs;
+ mVtxCount = 0;
+ mIndexCount = 0;
+ mVtxData = new float[128];
+ mIndexData = new int[128];
+ mVtxSize = vtxSize;
+ mNorm = norm;
+ mTex = tex;
+
+ if(vtxSize < 2 || vtxSize > 3) {
+ throw new IllegalArgumentException("Vertex size out of range.");
+ }
+ }
+
+ private void makeSpace(int count) {
+ if((mVtxCount + count) >= mVtxData.length) {
+ float t[] = new float[mVtxData.length * 2];
+ System.arraycopy(mVtxData, 0, t, 0, mVtxData.length);
+ mVtxData = t;
+ }
+ }
+
+ public void add_XY(float x, float y) {
+ if((mVtxSize != 2) || mNorm || mTex) {
+ throw new IllegalStateException("add mistmatch with declaired components.");
+ }
+ makeSpace(2);
+ mVtxData[mVtxCount++] = x;
+ mVtxData[mVtxCount++] = y;
+ }
+
+ public void add_XYZ(float x, float y, float z) {
+ if((mVtxSize != 3) || mNorm || mTex) {
+ throw new IllegalStateException("add mistmatch with declaired components.");
+ }
+ makeSpace(3);
+ mVtxData[mVtxCount++] = x;
+ mVtxData[mVtxCount++] = y;
+ mVtxData[mVtxCount++] = z;
+ }
+
+ public void add_XY_ST(float x, float y, float s, float t) {
+ if((mVtxSize != 2) || mNorm || !mTex) {
+ throw new IllegalStateException("add mistmatch with declaired components.");
+ }
+ makeSpace(4);
+ mVtxData[mVtxCount++] = x;
+ mVtxData[mVtxCount++] = y;
+ mVtxData[mVtxCount++] = s;
+ mVtxData[mVtxCount++] = t;
+ }
+
+ public void add_XYZ_ST(float x, float y, float z, float s, float t) {
+ if((mVtxSize != 3) || mNorm || !mTex) {
+ throw new IllegalStateException("add mistmatch with declaired components.");
+ }
+ makeSpace(5);
+ mVtxData[mVtxCount++] = x;
+ mVtxData[mVtxCount++] = y;
+ mVtxData[mVtxCount++] = z;
+ mVtxData[mVtxCount++] = s;
+ mVtxData[mVtxCount++] = t;
+ }
+
+ public void add_XYZ_ST_NORM(float x, float y, float z, float s, float t, float nx, float ny, float nz) {
+ if((mVtxSize != 3) || !mNorm || !mTex) {
+ throw new IllegalStateException("add mistmatch with declaired components.");
+ }
+ makeSpace(8);
+ mVtxData[mVtxCount++] = x;
+ mVtxData[mVtxCount++] = y;
+ mVtxData[mVtxCount++] = z;
+ mVtxData[mVtxCount++] = s;
+ mVtxData[mVtxCount++] = t;
+ mVtxData[mVtxCount++] = nx;
+ mVtxData[mVtxCount++] = ny;
+ mVtxData[mVtxCount++] = nz;
+ }
+
+ public void addTriangle(int idx1, int idx2, int idx3) {
+ if((mIndexCount + 3) >= mIndexData.length) {
+ int t[] = new int[mIndexData.length * 2];
+ System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
+ mIndexData = t;
+ }
+ mIndexData[mIndexCount++] = idx1;
+ mIndexData[mIndexCount++] = idx2;
+ mIndexData[mIndexCount++] = idx3;
+ }
+
+ public SimpleMesh create() {
+ Element.Builder b = new Element.Builder(mRS);
+ int floatCount = mVtxSize;
+ if(mVtxSize == 2) {
+ b.addFloatXY();
+ } else {
+ b.addFloatXYZ();
+ }
+ if(mTex) {
+ floatCount += 2;
+ b.addFloatST();
+ }
+ if(mNorm) {
+ floatCount += 3;
+ b.addFloatNorm();
+ }
+ mElement = b.create();
+
+ Builder smb = new Builder(mRS);
+ smb.addVertexType(mElement, mVtxCount / floatCount);
+ smb.setIndexType(Element.INDEX_16, mIndexCount);
+ smb.setPrimitive(Primitive.TRIANGLE);
+ SimpleMesh sm = smb.create();
+
+ Allocation vertexAlloc = sm.createVertexAllocation(0);
+ Allocation indexAlloc = sm.createIndexAllocation();
+ sm.bindVertexAllocation(vertexAlloc, 0);
+ sm.bindIndexAllocation(indexAlloc);
+
+ vertexAlloc.data(mVtxData);
+ 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.uploadToBufferObject();
+
+ return sm;
+ }
+ }
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 2393f74..2550181 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -70,7 +70,7 @@ static void
nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nAssignName, con(%p), obj(%p)", con, obj);
+ LOG_API("nAssignName, con(%p), obj(%p)", con, (void *)obj);
jint len = _env->GetArrayLength(str);
jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
@@ -345,6 +345,14 @@ nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip)
rsAllocationUploadToTexture(con, (RsAllocation)a, mip);
}
+static void
+nAllocationUploadToBufferObject(JNIEnv *_env, jobject _this, jint a)
+{
+ RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+ LOG_API("nAllocationUploadToBufferObject, con(%p), a(%p)", con, (RsAllocation)a);
+ rsAllocationUploadToBufferObject(con, (RsAllocation)a);
+}
+
static RsElementPredefined SkBitmapToPredefined(SkBitmap::Config cfg)
{
switch (cfg) {
@@ -413,68 +421,68 @@ nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jbool
static void
-nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data)
+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);
+ rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
}
static void
-nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data)
+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);
+ rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
}
static void
-nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data)
+nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
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);
jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr);
+ rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
}
static void
-nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data)
+nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
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);
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr);
+ rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
}
static void
-nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data)
+nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data, int sizeBytes)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jint *ptr = _env->GetIntArrayElements(data, NULL);
- rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr);
+ rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes);
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
}
static void
-nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data)
+nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data, int sizeBytes)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
jint len = _env->GetArrayLength(data);
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
- rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr);
+ rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes);
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
}
@@ -516,7 +524,7 @@ nAllocationDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type
const TypeFieldCache *tfc = &tc->fields[ct];
buf = tfc->ptr(_env, _o, tfc->field, buf);
}
- rsAllocationData(con, (RsAllocation)alloc, bufAlloc);
+ rsAllocationData(con, (RsAllocation)alloc, bufAlloc, tc->size);
const uint32_t * tmp = (const uint32_t *)bufAlloc;
free(bufAlloc);
}
@@ -748,7 +756,7 @@ static void
nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, script, r, g, b, a);
+ LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a);
rsScriptSetClearColor(con, (RsScript)script, r, g, b, a);
}
@@ -756,7 +764,7 @@ static void
nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, script, d);
+ LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d);
rsScriptSetClearDepth(con, (RsScript)script, d);
}
@@ -764,7 +772,7 @@ static void
nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, script, stencil);
+ LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil);
rsScriptSetClearStencil(con, (RsScript)script, stencil);
}
@@ -772,7 +780,7 @@ static void
nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, script, timeZone);
+ LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone);
jint length = _env->GetArrayLength(timeZone);
jbyte* timeZone_ptr;
@@ -1005,7 +1013,7 @@ static void
nProgramVertexBindAllocation(JNIEnv *_env, jobject _this, jint vpv, jint a)
{
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
- LOG_API("nProgramVertexBindAllocation, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramVertex)vpv, slot, (RsAllocation)a);
+ LOG_API("nProgramVertexBindAllocation, con(%p), vpf(%p), a(%p)", con, (RsProgramVertex)vpv, (RsAllocation)a);
rsProgramVertexBindAllocation(con, (RsProgramFragment)vpv, (RsAllocation)a);
}
@@ -1230,14 +1238,15 @@ static JNINativeMethod methods[] = {
{"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized },
{"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized },
{"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
-{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
+{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
{"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture },
-{"nAllocationData", "(I[I)V", (void*)nAllocationData_i },
-{"nAllocationData", "(I[F)V", (void*)nAllocationData_f },
-{"nAllocationSubData1D", "(III[I)V", (void*)nAllocationSubData1D_i },
-{"nAllocationSubData1D", "(III[F)V", (void*)nAllocationSubData1D_f },
-{"nAllocationSubData2D", "(IIIII[I)V", (void*)nAllocationSubData2D_i },
-{"nAllocationSubData2D", "(IIIII[F)V", (void*)nAllocationSubData2D_f },
+{"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[FI)V", (void*)nAllocationSubData1D_f },
+{"nAllocationSubData2D", "(IIIII[II)V", (void*)nAllocationSubData2D_i },
+{"nAllocationSubData2D", "(IIIII[FI)V", (void*)nAllocationSubData2D_f },
{"nAllocationRead", "(I[I)V", (void*)nAllocationRead_i },
{"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f },
{"nAllocationDataFromObject", "(ILandroid/renderscript/Type;Ljava/lang/Object;)V", (void*)nAllocationDataFromObject },