diff options
author | Jason Sams <rjsams@android.com> | 2009-07-29 21:05:11 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-07-29 21:05:11 -0700 |
commit | 0ea8c8a7c060873ef94e8aa8a637bc90852777d1 (patch) | |
tree | c26f8f527ac3f8443e83c76ddee33df10a8be923 /libs/rs/java/Film | |
parent | faf1520be77aa01903f9ad87990377f44e185224 (diff) | |
download | frameworks_base-0ea8c8a7c060873ef94e8aa8a637bc90852777d1.zip frameworks_base-0ea8c8a7c060873ef94e8aa8a637bc90852777d1.tar.gz frameworks_base-0ea8c8a7c060873ef94e8aa8a637bc90852777d1.tar.bz2 |
Simplify image loading. Use common internal format.
Diffstat (limited to 'libs/rs/java/Film')
-rw-r--r-- | libs/rs/java/Film/src/com/android/film/FilmRS.java | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java index 1de44a7..a639c55 100644 --- a/libs/rs/java/Film/src/com/android/film/FilmRS.java +++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java @@ -18,10 +18,6 @@ package com.android.film; import java.io.Writer; -import android.renderscript.RenderScript; -import android.renderscript.ProgramVertexAlloc; -import android.renderscript.Matrix; - import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; @@ -30,13 +26,17 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Message; +import android.renderscript.Matrix; +import android.renderscript.ProgramVertexAlloc; +import android.renderscript.RenderScript; +import android.renderscript.RenderScript.ElementPredefined; import android.util.AttributeSet; import android.util.Log; +import android.view.KeyEvent; +import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; -import android.view.KeyEvent; -import android.view.MotionEvent; public class FilmRS { private final int POS_TRANSLATE = 0; @@ -175,44 +175,47 @@ public class FilmRS { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inScaled = false; + RenderScript.ElementPredefined ie = + RenderScript.ElementPredefined.RGB_565; + b = BitmapFactory.decodeResource(mRes, R.drawable.p01, opts); - mImages[0] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[0] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p02, opts); - mImages[1] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[1] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p03, opts); - mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); - b = BitmapFactory.decodeResource(mRes, R.drawable.path1927, opts); - mImages[3] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true); + b = BitmapFactory.decodeResource(mRes, R.drawable.p04, opts); + mImages[3] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p05, opts); - mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p06, opts); - mImages[5] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[5] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p07, opts); - mImages[6] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[6] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p08, opts); - mImages[7] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[7] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p09, opts); - mImages[8] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[8] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p10, opts); - mImages[9] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[9] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p11, opts); - mImages[10] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[10] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p12, opts); - mImages[11] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[11] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); b = BitmapFactory.decodeResource(mRes, R.drawable.p13, opts); - mImages[12] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true); + mImages[12] = mRS.allocationCreateFromBitmapBoxed(b, ie, true); for(int ct=0; ct < mImages.length; ct++) { mImages[ct].uploadToTexture(1); @@ -289,31 +292,7 @@ public class FilmRS { mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex); mScriptStrip.bindAllocation(mAllocOffsetsTex, 5); - - - -/* - { - 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); - mPFS = mRS.programFragmentStoreCreate(); - mPFS.setName("MyBlend"); - mRS.contextBindProgramFragmentStore(mPFS); - */ - setFilmStripPosition(0, 0); - mRS.contextBindRootScript(mScriptStrip); } } |