summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2010-09-24 09:42:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-24 09:42:47 -0700
commit04b5dd4b04df45eea0b568ac8d7ad5c4903c5cf5 (patch)
tree66608bc318ced35d1f02b1d43d0d0bc8435c7c67 /graphics
parent5a049b0fffd98f5b6b61e43a01345c476d27c1f7 (diff)
parentb89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17 (diff)
downloadframeworks_base-04b5dd4b04df45eea0b568ac8d7ad5c4903c5cf5.zip
frameworks_base-04b5dd4b04df45eea0b568ac8d7ad5c4903c5cf5.tar.gz
frameworks_base-04b5dd4b04df45eea0b568ac8d7ad5c4903c5cf5.tar.bz2
Merge "Adding support for all allowed textures. Cleaning up unused code Adding error messages"
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/Program.java9
-rw-r--r--graphics/java/android/renderscript/ProgramFragment.java3
-rw-r--r--graphics/java/android/renderscript/ProgramVertex.java2
-rw-r--r--graphics/java/android/renderscript/RenderScript.java23
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp60
5 files changed, 36 insertions, 61 deletions
diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java
index c6ed72a..ffcdbbc 100644
--- a/graphics/java/android/renderscript/Program.java
+++ b/graphics/java/android/renderscript/Program.java
@@ -154,6 +154,13 @@ public class Program extends BaseObj {
mOutputs[mOutputCount++] = e;
}
+ void resetConstant() {
+ mConstantCount = 0;
+ for(int i = 0; i < MAX_CONSTANT; i ++) {
+ mConstants[i] = null;
+ }
+ }
+
public int addConstant(Type t) throws IllegalStateException {
// Should check for consistant and non-conflicting names...
if(mConstantCount >= MAX_CONSTANT) {
@@ -165,7 +172,7 @@ public class Program extends BaseObj {
public BaseProgramBuilder setTextureCount(int count) throws IllegalArgumentException {
// Should check for consistant and non-conflicting names...
- if(count >= MAX_CONSTANT) {
+ if(count >= MAX_TEXTURE) {
throw new IllegalArgumentException("Max texture count exceeded.");
}
mTextureCount = count;
diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java
index 00c5cf1..c1d6428 100644
--- a/graphics/java/android/renderscript/ProgramFragment.java
+++ b/graphics/java/android/renderscript/ProgramFragment.java
@@ -55,7 +55,7 @@ public class ProgramFragment extends Program {
tmp[idx++] = 3;
tmp[idx++] = mTextureCount;
- int id = mRS.nProgramFragmentCreate2(mShader, tmp);
+ int id = mRS.nProgramFragmentCreate(mShader, tmp);
ProgramFragment pf = new ProgramFragment(id, mRS);
initProgram(pf);
return pf;
@@ -199,6 +199,7 @@ public class ProgramFragment extends Program {
mNumTextures ++;
}
}
+ resetConstant();
buildShaderString();
Type constType = null;
if (!mVaryingColorEnable) {
diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java
index 119db69..63e2598 100644
--- a/graphics/java/android/renderscript/ProgramVertex.java
+++ b/graphics/java/android/renderscript/ProgramVertex.java
@@ -64,7 +64,7 @@ public class ProgramVertex extends Program {
tmp[idx++] = 3;
tmp[idx++] = mTextureCount;
- int id = mRS.nProgramVertexCreate2(mShader, tmp);
+ int id = mRS.nProgramVertexCreate(mShader, tmp);
ProgramVertex pv = new ProgramVertex(id, mRS);
initProgram(pv);
return pv;
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 159e070..2aa3e84 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -447,25 +447,14 @@ public class RenderScript {
synchronized void nProgramBindSampler(int vpf, int slot, int s) {
rsnProgramBindSampler(mContext, vpf, slot, s);
}
-
- native int rsnProgramFragmentCreate(int con, int[] params);
- synchronized int nProgramFragmentCreate(int[] params) {
- return rsnProgramFragmentCreate(mContext, params);
- }
- native int rsnProgramFragmentCreate2(int con, String shader, int[] params);
- synchronized int nProgramFragmentCreate2(String shader, int[] params) {
- return rsnProgramFragmentCreate2(mContext, shader, params);
+ native int rsnProgramFragmentCreate(int con, String shader, int[] params);
+ synchronized int nProgramFragmentCreate(String shader, int[] params) {
+ return rsnProgramFragmentCreate(mContext, shader, params);
}
-
- native int rsnProgramVertexCreate(int con, boolean texMat);
- synchronized int nProgramVertexCreate(boolean texMat) {
- return rsnProgramVertexCreate(mContext, texMat);
+ native int rsnProgramVertexCreate(int con, String shader, int[] params);
+ synchronized int nProgramVertexCreate(String shader, int[] params) {
+ return rsnProgramVertexCreate(mContext, shader, params);
}
- native int rsnProgramVertexCreate2(int con, String shader, int[] params);
- synchronized int nProgramVertexCreate2(String shader, int[] params) {
- return rsnProgramVertexCreate2(mContext, shader, params);
- }
-
native int rsnMeshCreate(int con, int vtxCount, int indexCount);
synchronized int nMeshCreate(int vtxCount, int indexCount) {
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index ee2080e..6aed11b 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -983,29 +983,16 @@ nProgramBindSampler(JNIEnv *_env, jobject _this, RsContext con, jint vpf, jint s
// ---------------------------------------------------------------------------
static jint
-nProgramFragmentCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray params)
-{
- jint *paramPtr = _env->GetIntArrayElements(params, NULL);
- jint paramLen = _env->GetArrayLength(params);
-
- LOG_API("nProgramFragmentCreate, con(%p), paramLen(%i)", con, paramLen);
-
- jint ret = (jint)rsProgramFragmentCreate(con, (uint32_t *)paramPtr, paramLen);
- _env->ReleaseIntArrayElements(params, paramPtr, JNI_ABORT);
- return ret;
-}
-
-static jint
-nProgramFragmentCreate2(JNIEnv *_env, jobject _this, RsContext con, jstring shader, jintArray params)
+nProgramFragmentCreate(JNIEnv *_env, jobject _this, RsContext con, jstring shader, jintArray params)
{
const char* shaderUTF = _env->GetStringUTFChars(shader, NULL);
jint shaderLen = _env->GetStringUTFLength(shader);
jint *paramPtr = _env->GetIntArrayElements(params, NULL);
jint paramLen = _env->GetArrayLength(params);
- LOG_API("nProgramFragmentCreate2, con(%p), shaderLen(%i), paramLen(%i)", con, shaderLen, paramLen);
+ LOG_API("nProgramFragmentCreate, con(%p), shaderLen(%i), paramLen(%i)", con, shaderLen, paramLen);
- jint ret = (jint)rsProgramFragmentCreate2(con, shaderUTF, shaderLen, (uint32_t *)paramPtr, paramLen);
+ jint ret = (jint)rsProgramFragmentCreate(con, shaderUTF, shaderLen, (uint32_t *)paramPtr, paramLen);
_env->ReleaseStringUTFChars(shader, shaderUTF);
_env->ReleaseIntArrayElements(params, paramPtr, JNI_ABORT);
return ret;
@@ -1015,23 +1002,16 @@ nProgramFragmentCreate2(JNIEnv *_env, jobject _this, RsContext con, jstring shad
// ---------------------------------------------------------------------------
static jint
-nProgramVertexCreate(JNIEnv *_env, jobject _this, RsContext con, jboolean texMat)
-{
- LOG_API("nProgramVertexCreate, con(%p), texMat(%i)", con, texMat);
- return (jint)rsProgramVertexCreate(con, texMat);
-}
-
-static jint
-nProgramVertexCreate2(JNIEnv *_env, jobject _this, RsContext con, jstring shader, jintArray params)
+nProgramVertexCreate(JNIEnv *_env, jobject _this, RsContext con, jstring shader, jintArray params)
{
const char* shaderUTF = _env->GetStringUTFChars(shader, NULL);
jint shaderLen = _env->GetStringUTFLength(shader);
jint *paramPtr = _env->GetIntArrayElements(params, NULL);
jint paramLen = _env->GetArrayLength(params);
- LOG_API("nProgramVertexCreate2, con(%p), shaderLen(%i), paramLen(%i)", con, shaderLen, paramLen);
+ LOG_API("nProgramVertexCreate, con(%p), shaderLen(%i), paramLen(%i)", con, shaderLen, paramLen);
- jint ret = (jint)rsProgramVertexCreate2(con, shaderUTF, shaderLen, (uint32_t *)paramPtr, paramLen);
+ jint ret = (jint)rsProgramVertexCreate(con, shaderUTF, shaderLen, (uint32_t *)paramPtr, paramLen);
_env->ReleaseStringUTFChars(shader, shaderUTF);
_env->ReleaseIntArrayElements(params, paramPtr, JNI_ABORT);
return ret;
@@ -1217,36 +1197,36 @@ static JNINativeMethod methods[] = {
// All methods below are thread protected in java.
-{"rsnContextCreate", "(II)I", (void*)nContextCreate },
-{"rsnContextCreateGL", "(IIZ)I", (void*)nContextCreateGL },
+{"rsnContextCreate", "(II)I", (void*)nContextCreate },
+{"rsnContextCreateGL", "(IIZ)I", (void*)nContextCreateGL },
{"rsnContextFinish", "(I)V", (void*)nContextFinish },
{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority },
{"rsnContextSetSurface", "(IIILandroid/view/Surface;)V", (void*)nContextSetSurface },
-{"rsnContextDestroy", "(I)V", (void*)nContextDestroy },
+{"rsnContextDestroy", "(I)V", (void*)nContextDestroy },
{"rsnContextDump", "(II)V", (void*)nContextDump },
{"rsnContextPause", "(I)V", (void*)nContextPause },
{"rsnContextResume", "(I)V", (void*)nContextResume },
{"rsnAssignName", "(II[B)V", (void*)nAssignName },
-{"rsnGetName", "(II)Ljava/lang/String;", (void*)nGetName },
+{"rsnGetName", "(II)Ljava/lang/String;", (void*)nGetName },
{"rsnObjDestroy", "(II)V", (void*)nObjDestroy },
{"rsnFileOpen", "(I[B)I", (void*)nFileOpen },
{"rsnFileA3DCreateFromAssetStream", "(II)I", (void*)nFileA3DCreateFromAssetStream },
{"rsnFileA3DGetNumIndexEntries", "(II)I", (void*)nFileA3DGetNumIndexEntries },
-{"rsnFileA3DGetIndexEntries", "(III[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries },
+{"rsnFileA3DGetIndexEntries", "(III[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries },
{"rsnFileA3DGetEntryByIndex", "(III)I", (void*)nFileA3DGetEntryByIndex },
-{"rsnFontCreateFromFile", "(ILjava/lang/String;II)I", (void*)nFontCreateFromFile },
+{"rsnFontCreateFromFile", "(ILjava/lang/String;II)I", (void*)nFontCreateFromFile },
{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate },
{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 },
{"rsnElementGetNativeData", "(II[I)V", (void*)nElementGetNativeData },
-{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;)V", (void*)nElementGetSubElements },
+{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;)V", (void*)nElementGetSubElements },
{"rsnTypeBegin", "(II)V", (void*)nTypeBegin },
{"rsnTypeAdd", "(III)V", (void*)nTypeAdd },
{"rsnTypeCreate", "(I)I", (void*)nTypeCreate },
-{"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData },
+{"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData },
{"rsnAllocationCreateTyped", "(II)I", (void*)nAllocationCreateTyped },
{"rsnAllocationCreateFromBitmap", "(IIZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
@@ -1307,18 +1287,16 @@ static JNINativeMethod methods[] = {
{"rsnProgramBindTexture", "(IIII)V", (void*)nProgramBindTexture },
{"rsnProgramBindSampler", "(IIII)V", (void*)nProgramBindSampler },
-{"rsnProgramFragmentCreate", "(I[I)I", (void*)nProgramFragmentCreate },
-{"rsnProgramFragmentCreate2", "(ILjava/lang/String;[I)I", (void*)nProgramFragmentCreate2 },
+{"rsnProgramFragmentCreate", "(ILjava/lang/String;[I)I", (void*)nProgramFragmentCreate },
-{"rsnProgramRasterCreate", "(IZZZ)I", (void*)nProgramRasterCreate },
+{"rsnProgramRasterCreate", "(IZZZ)I", (void*)nProgramRasterCreate },
{"rsnProgramRasterSetLineWidth", "(IIF)V", (void*)nProgramRasterSetLineWidth },
{"rsnProgramRasterSetCullMode", "(III)V", (void*)nProgramRasterSetCullMode },
-{"rsnProgramVertexCreate", "(IZ)I", (void*)nProgramVertexCreate },
-{"rsnProgramVertexCreate2", "(ILjava/lang/String;[I)I", (void*)nProgramVertexCreate2 },
+{"rsnProgramVertexCreate", "(ILjava/lang/String;[I)I", (void*)nProgramVertexCreate },
{"rsnContextBindRootScript", "(II)V", (void*)nContextBindRootScript },
-{"rsnContextBindProgramStore", "(II)V", (void*)nContextBindProgramStore },
+{"rsnContextBindProgramStore", "(II)V", (void*)nContextBindProgramStore },
{"rsnContextBindProgramFragment", "(II)V", (void*)nContextBindProgramFragment },
{"rsnContextBindProgramVertex", "(II)V", (void*)nContextBindProgramVertex },
{"rsnContextBindProgramRaster", "(II)V", (void*)nContextBindProgramRaster },
@@ -1333,7 +1311,7 @@ static JNINativeMethod methods[] = {
{"rsnMeshGetVertexBufferCount", "(II)I", (void*)nMeshGetVertexBufferCount },
{"rsnMeshGetIndexCount", "(II)I", (void*)nMeshGetIndexCount },
-{"rsnMeshGetVertices", "(II[II)V", (void*)nMeshGetVertices },
+{"rsnMeshGetVertices", "(II[II)V", (void*)nMeshGetVertices },
{"rsnMeshGetIndices", "(II[I[II)V", (void*)nMeshGetIndices },
};