summaryrefslogtreecommitdiffstats
path: root/libs/rs/java/Fountain
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-06-10 15:04:38 -0700
committerJason Sams <rjsams@android.com>2009-06-10 15:04:38 -0700
commit3eaa338e11a3b0d6b87d705e5bb95625e82347bd (patch)
treef0e91b1fbf362b86b54d84325581f7544536a38c /libs/rs/java/Fountain
parentda423d8479a2cefb456a03d7dc550e74e473acf4 (diff)
downloadframeworks_base-3eaa338e11a3b0d6b87d705e5bb95625e82347bd.zip
frameworks_base-3eaa338e11a3b0d6b87d705e5bb95625e82347bd.tar.gz
frameworks_base-3eaa338e11a3b0d6b87d705e5bb95625e82347bd.tar.bz2
Add named objects and implement support for ProgramFragmentStore and ProgramFragment to be used by name in scripts.
Diffstat (limited to 'libs/rs/java/Fountain')
-rw-r--r--libs/rs/java/Fountain/res/raw/fountain.c6
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/FountainView.java3
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java28
3 files changed, 32 insertions, 5 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c
index 5055c39..afb2fb3 100644
--- a/libs/rs/java/Fountain/res/raw/fountain.c
+++ b/libs/rs/java/Fountain/res/raw/fountain.c
@@ -3,8 +3,8 @@
#pragma version(1)
#pragma stateVertex(orthoWindow)
#pragma stateRaster(flat)
-#pragma stateFragment(color)
-#pragma stateStore(parent)
+#pragma stateFragment(PgmFragBackground)
+#pragma stateFragmentStore(MyBlend)
int main(void* con, int ft, int launchID) {
@@ -35,7 +35,7 @@ int main(void* con, int ft, int launchID) {
}
}
- contextBindProgramFragment(con, loadI32(con, 0, 7));
+ //contextBindProgramFragment(con, loadI32(con, 0, 7));
drawRect(con, 0, 256, 0, 512);
contextBindProgramFragment(con, loadI32(con, 0, 6));
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
index 3381525..0a6f7c5 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
@@ -82,6 +82,7 @@ public class FountainView extends RSSurfaceView {
mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE);
mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
mPFS = mRS.programFragmentStoreCreate();
+ mPFS.setName("MyBlend");
mRS.contextBindProgramFragmentStore(mPFS);
mRS.samplerBegin();
@@ -92,6 +93,7 @@ public class FountainView extends RSSurfaceView {
mRS.programFragmentBegin(null, null);
mPF = mRS.programFragmentCreate();
+ mPF.setName("PgmFragParts");
//mRS.contextBindProgramFragment(mPF);
mRS.programFragmentBegin(null, null);
@@ -100,6 +102,7 @@ public class FountainView extends RSSurfaceView {
mRS.contextBindProgramFragment(mPF2);
mPF2.bindTexture(mTexture, 0);
mPF2.bindSampler(mSampler, 0);
+ mPF2.setName("PgmFragBackground");
mParams[0] = 0;
mParams[1] = partCount;
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
index 796fe35..fcfb82d 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
@@ -68,6 +68,8 @@ public class RenderScript {
native private void nContextBindProgramFragmentStore(int pfs);
native private void nContextBindProgramFragment(int pf);
+ native private void nAssignName(int obj, byte[] name);
+
native private void nElementBegin();
native private void nElementAddPredefined(int predef);
native private void nElementAdd(int kind, int type, int norm, int bits);
@@ -135,6 +137,7 @@ public class RenderScript {
native private void nProgramFragmentStoreBlendFunc(int src, int dst);
native private void nProgramFragmentStoreDither(boolean enable);
native private int nProgramFragmentStoreCreate();
+ native private void nProgramFragmentStoreDestroy(int pgm);
native private void nProgramFragmentBegin(int in, int out);
native private void nProgramFragmentBindTexture(int vpf, int slot, int a);
@@ -143,6 +146,7 @@ public class RenderScript {
native private void nProgramFragmentSetEnvMode(int slot, int env);
native private void nProgramFragmentSetTexEnable(int slot, boolean enable);
native private int nProgramFragmentCreate();
+ native private void nProgramFragmentDestroy(int pgm);
private int mDev;
@@ -166,6 +170,26 @@ public class RenderScript {
}
int mID;
+ String mName;
+
+ public void setName(String s) throws IllegalStateException, IllegalArgumentException
+ {
+ if(s.length() < 1) {
+ throw new IllegalArgumentException("setName does not accept a zero length string.");
+ }
+ if(mName != null) {
+ throw new IllegalArgumentException("setName object already has a name.");
+ }
+
+ try {
+ byte[] bytes = s.getBytes("UTF-8");
+ nAssignName(mID, bytes);
+ mName = s;
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
protected void finalize() throws Throwable
{
if (mID != 0) {
@@ -661,7 +685,7 @@ public class RenderScript {
}
public void destroy() {
- nScriptDestroy(mID);
+ nProgramFragmentStoreDestroy(mID);
mID = 0;
}
}
@@ -712,7 +736,7 @@ public class RenderScript {
}
public void destroy() {
- nScriptDestroy(mID);
+ nProgramFragmentDestroy(mID);
mID = 0;
}