diff options
author | Jason Sams <rjsams@android.com> | 2009-11-30 14:49:55 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-11-30 15:34:03 -0800 |
commit | 54c0ec14e016e4a1bf3ceab40ed6ca5447da4725 (patch) | |
tree | 343acd699d50a4090b451d05135aa7887a6a7984 /graphics | |
parent | 5154ae7665743b114c71f90dcc577dc50c63b398 (diff) | |
download | frameworks_base-54c0ec14e016e4a1bf3ceab40ed6ca5447da4725.zip frameworks_base-54c0ec14e016e4a1bf3ceab40ed6ca5447da4725.tar.gz frameworks_base-54c0ec14e016e4a1bf3ceab40ed6ca5447da4725.tar.bz2 |
Beging GL2 user shaders. Switch master to using GL2 by default.
Diffstat (limited to 'graphics')
4 files changed, 47 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index 392d93d..f8625e8 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -69,6 +69,7 @@ public class ProgramFragment extends BaseObj { Element mIn; Element mOut; boolean mPointSpriteEnable; + String mShader; private class Slot { Type mType; @@ -92,6 +93,10 @@ public class ProgramFragment extends BaseObj { } } + public void setShader(String s) { + mShader = s; + } + public void setType(int slot, Type t) throws IllegalArgumentException { if((slot < 0) || (slot >= MAX_SLOT)) { @@ -144,6 +149,10 @@ public class ProgramFragment extends BaseObj { } } + if (b.mShader != null) { + rs.nProgramFragmentSetShader(b.mShader); + } + int id = rs.nProgramFragmentCreate(); return new ProgramFragment(id, rs); } diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index ddb23ac..8a22138 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -45,6 +45,7 @@ public class ProgramVertex extends BaseObj { Light[] mLights; int mLightCount; boolean mTextureMatrixEnable; + String mShader; public Builder(RenderScript rs, Element in, Element out) { @@ -59,6 +60,10 @@ public class ProgramVertex extends BaseObj { mTextureMatrixEnable = enable; } + public void setShader(String s) { + mShader = s; + } + public void addLight(Light l) throws IllegalStateException { if(mLightCount >= MAX_LIGHT) { throw new IllegalArgumentException("Max light count exceeded."); @@ -79,10 +84,14 @@ public class ProgramVertex extends BaseObj { outID = b.mOut.mID; } rs.nProgramVertexBegin(inID, outID); - for(int ct=0; ct < b.mLightCount; ct++) { - rs.nProgramVertexAddLight(b.mLights[ct].mID); + if (b.mShader != null) { + rs.nProgramVertexSetShader(b.mShader); + } else { + for(int ct=0; ct < b.mLightCount; ct++) { + rs.nProgramVertexAddLight(b.mLights[ct].mID); + } + rs.nProgramVertexSetTextureMatrixEnable(b.mTextureMatrixEnable); } - rs.nProgramVertexSetTextureMatrixEnable(b.mTextureMatrixEnable); int id = rs.nProgramVertexCreate(); return new ProgramVertex(id, rs); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index c42f647..22bfa69 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -171,12 +171,14 @@ public class RenderScript { native void nProgramFragmentBindTexture(int vpf, int slot, int a); native void nProgramFragmentBindSampler(int vpf, int slot, int s); native void nProgramFragmentSetSlot(int slot, boolean enable, int env, int vt); + native void nProgramFragmentSetShader(String txt); native int nProgramFragmentCreate(); native void nProgramVertexBindAllocation(int pv, int mID); native void nProgramVertexBegin(int inID, int outID); native void nProgramVertexSetTextureMatrixEnable(boolean enable); native void nProgramVertexAddLight(int id); + native void nProgramVertexSetShader(String txt); native int nProgramVertexCreate(); native void nLightBegin(); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index af3bc74..ea5feb8 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -1053,9 +1053,20 @@ nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) return (jint)rsProgramFragmentStoreCreate(con); } + // --------------------------------------------------------------------------- static void +nProgramFragmentSetShader(JNIEnv *_env, jobject _this, jstring name) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + const char* n = _env->GetStringUTFChars(name, NULL); + LOG_API("nProgramFragmentSetShader, con(%p)", con); + rsProgramFragmentSetShader(con, n, _env->GetStringUTFLength(name)); + _env->ReleaseStringUTFChars(name, n); +} + +static void nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out, jboolean pointSpriteEnable) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); @@ -1098,6 +1109,17 @@ nProgramFragmentCreate(JNIEnv *_env, jobject _this, jint slot, jboolean enable) // --------------------------------------------------------------------------- static void +nProgramVertexSetShader(JNIEnv *_env, jobject _this, jstring name) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + const char* n = _env->GetStringUTFChars(name, NULL); + LOG_API("nProgramVertexSetShader, con(%p)", con); + rsProgramVertexSetShader(con, n, _env->GetStringUTFLength(name)); + _env->ReleaseStringUTFChars(name, n); +} + + +static void nProgramVertexBegin(JNIEnv *_env, jobject _this, jint in, jint out) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); @@ -1436,6 +1458,7 @@ static JNINativeMethod methods[] = { {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, {"nProgramFragmentBindSampler", "(III)V", (void*)nProgramFragmentBindSampler }, {"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot }, +{"nProgramFragmentSetShader", "(Ljava/lang/String;)V", (void*)nProgramFragmentSetShader }, {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, {"nProgramRasterCreate", "(IIZZZ)I", (void*)nProgramRasterCreate }, @@ -1446,6 +1469,7 @@ static JNINativeMethod methods[] = { {"nProgramVertexBegin", "(II)V", (void*)nProgramVertexBegin }, {"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable }, {"nProgramVertexAddLight", "(I)V", (void*)nProgramVertexAddLight }, +{"nProgramVertexSetShader", "(Ljava/lang/String;)V", (void*)nProgramVertexSetShader }, {"nProgramVertexCreate", "()I", (void*)nProgramVertexCreate }, {"nLightBegin", "()V", (void*)nLightBegin }, |