diff options
author | Jason Sams <rjsams@android.com> | 2009-05-27 17:46:57 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-05-27 17:46:57 -0700 |
commit | 0ae234c991f46a4fd6c9abb44edba7af89569718 (patch) | |
tree | 82414f8e60c759d0898b9f4d58ab058bc81abde5 | |
parent | df98851d2fccc00d7bc9adfdf1088d34e007ae1a (diff) | |
download | frameworks_base-0ae234c991f46a4fd6c9abb44edba7af89569718.zip frameworks_base-0ae234c991f46a4fd6c9abb44edba7af89569718.tar.gz frameworks_base-0ae234c991f46a4fd6c9abb44edba7af89569718.tar.bz2 |
Add background bitmap to fountain test app for renderscript.
-rwxr-xr-x | libs/rs/java/Fountain/res/drawable/gadgets_clock_mp3.png | bin | 0 -> 104862 bytes | |||
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 29 | ||||
-rw-r--r-- | libs/rs/jni/RenderScript_jni.cpp | 4 |
3 files changed, 32 insertions, 1 deletions
diff --git a/libs/rs/java/Fountain/res/drawable/gadgets_clock_mp3.png b/libs/rs/java/Fountain/res/drawable/gadgets_clock_mp3.png Binary files differnew file mode 100755 index 0000000..e91bfb4 --- /dev/null +++ b/libs/rs/java/Fountain/res/drawable/gadgets_clock_mp3.png 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 eb848a5..c244d07 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -21,6 +21,10 @@ import java.util.ArrayList; import java.util.concurrent.Semaphore; import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Message; import android.util.AttributeSet; @@ -46,6 +50,10 @@ public class FountainView extends RSSurfaceView { private RenderScript.Script mScript; private RenderScript.ProgramFragmentStore mPFS; private RenderScript.ProgramFragment mPF; + private RenderScript.ProgramFragment mPF2; + private RenderScript.Allocation mTexture; + + private Bitmap mBackground; int mParams[] = new int[10]; @@ -58,6 +66,17 @@ public class FountainView extends RSSurfaceView { mPartAlloc = mRS.allocationCreatePredefSized(RenderScript.ElementPredefined.USER_I32, partCount * 3 * 3); mVertAlloc = mRS.allocationCreatePredefSized(RenderScript.ElementPredefined.USER_I32, partCount * 5 + 1); + { + Resources res = getResources(); + Drawable d = res.getDrawable(R.drawable.gadgets_clock_mp3); + BitmapDrawable bd = (BitmapDrawable)d; + Bitmap b = bd.getBitmap(); + mTexture = mRS.allocationCreateFromBitmap(b, + RenderScript.ElementPredefined.RGB_565, + true); + mTexture.uploadToTexture(0); + } + mRS.programFragmentStoreBegin(null, null); mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE); mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS); @@ -66,7 +85,13 @@ public class FountainView extends RSSurfaceView { mRS.programFragmentBegin(null, null); mPF = mRS.programFragmentCreate(); - mRS.contextBindProgramFragment(mPF); + //mRS.contextBindProgramFragment(mPF); + + mRS.programFragmentBegin(null, null); + mRS.programFragmentSetTexEnable(0, true); + mPF2 = mRS.programFragmentCreate(); + mRS.contextBindProgramFragment(mPF2); + mPF2.bindTexture(mTexture, 0); mParams[0] = 0; mParams[1] = partCount; @@ -74,6 +99,8 @@ public class FountainView extends RSSurfaceView { mParams[3] = 0; mParams[4] = 0; mParams[5] = mPartAlloc.mID; + mParams[6] = mPF.mID; + mParams[7] = mPF2.mID; mIntAlloc.data(mParams); int t2[] = new int[partCount * 4*3]; diff --git a/libs/rs/jni/RenderScript_jni.cpp b/libs/rs/jni/RenderScript_jni.cpp index 2a199c3..e1f14b5 100644 --- a/libs/rs/jni/RenderScript_jni.cpp +++ b/libs/rs/jni/RenderScript_jni.cpp @@ -78,6 +78,10 @@ static const char* TEST_SCRIPT = "" " }\n" " }\n" "\n" + " contextBindProgramFragment(con, loadI32(con, 0, 7));\n" + " drawRect(con, 0, 256, 0, 512);\n" + " contextBindProgramFragment(con, loadI32(con, 0, 6));\n" + "\n" " if (touch) {\n" " newPart = loadI32(con, 2, 0);\n" " for (ct2=0; ct2<rate; ct2++) {\n" |