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 /libs/rs/java/Fountain | |
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.
Diffstat (limited to 'libs/rs/java/Fountain')
-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 |
2 files changed, 28 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]; |