diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 14 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Type.java | 59 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 34 |
3 files changed, 47 insertions, 60 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 97ce7dc..8f1f273 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -178,17 +178,9 @@ public class RenderScript { rsnElementGetSubElements(mContext, id, IDs, names); } - native void rsnTypeBegin(int con, int elementID); - synchronized void nTypeBegin(int elementID) { - rsnTypeBegin(mContext, elementID); - } - native void rsnTypeAdd(int con, int dim, int val); - synchronized void nTypeAdd(int dim, int val) { - rsnTypeAdd(mContext, dim, val); - } - native int rsnTypeCreate(int con); - synchronized int nTypeCreate() { - return rsnTypeCreate(mContext); + native int rsnTypeCreate(int con, int eid, int[] dims, int[] vals); + synchronized int nTypeCreate(int eid, int[] dims, int[] vals) { + return rsnTypeCreate(mContext, eid, dims, vals); } native void rsnTypeGetNativeData(int con, int id, int[] typeData); synchronized void nTypeGetNativeData(int id, int[] typeData) { diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index 0b3db69..caa8b13 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -132,7 +132,8 @@ public class Type extends BaseObj { public static class Builder { RenderScript mRS; - Entry[] mEntries; + Dimension[] mDimensions; + int[] mDimensionValues; int mEntryCount; Element mElement; @@ -147,7 +148,8 @@ public class Type extends BaseObj { } mRS = rs; - mEntries = new Entry[4]; + mDimensions = new Dimension[4]; + mDimensionValues = new int[4]; mElement = e; } @@ -155,46 +157,45 @@ public class Type extends BaseObj { if(value < 1) { throw new IllegalArgumentException("Values of less than 1 for Dimensions are not valid."); } - if(mEntries.length >= mEntryCount) { - Entry[] en = new Entry[mEntryCount + 8]; - System.arraycopy(mEntries, 0, en, 0, mEntries.length); - mEntries = en; + if(mDimensions.length >= mEntryCount) { + Dimension[] dn = new Dimension[mEntryCount + 8]; + System.arraycopy(mDimensions, 0, dn, 0, mEntryCount); + mDimensions = dn; + + int[] in = new int[mEntryCount + 8]; + System.arraycopy(mDimensionValues, 0, in, 0, mEntryCount); + mDimensionValues = in; } - mEntries[mEntryCount] = new Entry(); - mEntries[mEntryCount].mDim = d; - mEntries[mEntryCount].mValue = value; + mDimensions[mEntryCount] = d; + mDimensionValues[mEntryCount] = value; mEntryCount++; } - static synchronized Type internalCreate(RenderScript rs, Builder b) { - rs.nTypeBegin(b.mElement.mID); - for (int ct=0; ct < b.mEntryCount; ct++) { - Entry en = b.mEntries[ct]; - rs.nTypeAdd(en.mDim.mID, en.mValue); + public Type create() { + int dims[] = new int[mEntryCount]; + for (int ct=0; ct < mEntryCount; ct++) { + dims[ct] = mDimensions[ct].mID; } - int id = rs.nTypeCreate(); - return new Type(id, rs); - } - public Type create() { - Type t = internalCreate(mRS, this); + int id = mRS.nTypeCreate(mElement.getID(), dims, mDimensionValues); + Type t = new Type(id, mRS); t.mElement = mElement; for(int ct=0; ct < mEntryCount; ct++) { - if(mEntries[ct].mDim == Dimension.X) { - t.mDimX = mEntries[ct].mValue; + if(mDimensions[ct] == Dimension.X) { + t.mDimX = mDimensionValues[ct]; } - if(mEntries[ct].mDim == Dimension.Y) { - t.mDimY = mEntries[ct].mValue; + if(mDimensions[ct] == Dimension.Y) { + t.mDimY = mDimensionValues[ct]; } - if(mEntries[ct].mDim == Dimension.Z) { - t.mDimZ = mEntries[ct].mValue; + if(mDimensions[ct] == Dimension.Z) { + t.mDimZ = mDimensionValues[ct]; } - if(mEntries[ct].mDim == Dimension.LOD) { - t.mDimLOD = mEntries[ct].mValue != 0; + if(mDimensions[ct] == Dimension.LOD) { + t.mDimLOD = mDimensionValues[ct] != 0; } - if(mEntries[ct].mDim == Dimension.FACE) { - t.mDimFaces = mEntries[ct].mValue != 0; + if(mDimensions[ct] == Dimension.FACE) { + t.mDimFaces = mDimensionValues[ct] != 0; } } t.calcElementCount(); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index ce2a40c..d9ff62d 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -112,7 +112,7 @@ static void nObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj) { LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj); - rsObjDestroy(con, (void *)obj); + rsObjDestroy(con, (uint32_t)obj); } @@ -336,25 +336,21 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, jint // ----------------------------------- -static void -nTypeBegin(JNIEnv *_env, jobject _this, RsContext con, jint eID) +static int +nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid, jintArray _dims, jintArray _dimValues) { - LOG_API("nTypeBegin, con(%p) e(%p)", con, (RsElement)eID); - rsTypeBegin(con, (RsElement)eID); -} + int count = _env->GetArrayLength(_dims); + LOG_API("nTypeCreate, con(%p)", con); -static void -nTypeAdd(JNIEnv *_env, jobject _this, RsContext con, jint dim, jint val) -{ - LOG_API("nTypeAdd, con(%p) dim(%i), val(%i)", con, dim, val); - rsTypeAdd(con, (RsDimension)dim, val); -} + jint *dimPtr = _env->GetIntArrayElements(_dims, NULL); + jint *dimValPtr = _env->GetIntArrayElements(_dimValues, NULL); -static jint -nTypeCreate(JNIEnv *_env, jobject _this, RsContext con) -{ - LOG_API("nTypeCreate, con(%p)", con); - return (jint)rsTypeCreate(con); + jint id = (jint)rsaTypeCreate(con, (RsElement)eid, count, + (RsDimension *)dimPtr, (uint32_t *)dimValPtr); + + _env->ReleaseIntArrayElements(_dims, dimPtr, JNI_ABORT); + _env->ReleaseIntArrayElements(_dimValues, dimValPtr, JNI_ABORT); + return (jint)id; } static void @@ -1261,9 +1257,7 @@ static JNINativeMethod methods[] = { {"rsnElementGetNativeData", "(II[I)V", (void*)nElementGetNativeData }, {"rsnElementGetSubElements", "(II[I[Ljava/lang/String;)V", (void*)nElementGetSubElements }, -{"rsnTypeBegin", "(II)V", (void*)nTypeBegin }, -{"rsnTypeAdd", "(III)V", (void*)nTypeAdd }, -{"rsnTypeCreate", "(I)I", (void*)nTypeCreate }, +{"rsnTypeCreate", "(II[I[I)I", (void*)nTypeCreate }, {"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData }, {"rsnAllocationCreateTyped", "(II)I", (void*)nAllocationCreateTyped }, |