summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests/SceneGraph/src
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-12-14 17:10:04 -0800
committerAlex Sakhartchouk <alexst@google.com>2011-12-14 17:10:04 -0800
commit18f6419bfe5f2ee11a43713770d17888fd61ed69 (patch)
tree8c964cc84b9b392b118f13673fbc3512ba7278dc /tests/RenderScriptTests/SceneGraph/src
parent85d02dc75ca206927589cd7ff8a6cc7ef1792555 (diff)
downloadframeworks_base-18f6419bfe5f2ee11a43713770d17888fd61ed69.zip
frameworks_base-18f6419bfe5f2ee11a43713770d17888fd61ed69.tar.gz
frameworks_base-18f6419bfe5f2ee11a43713770d17888fd61ed69.tar.bz2
Adding default scene to assets.
Change-Id: Iec48cb53cd5c2902aa64dd02d23724f607f9114c
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src')
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java1
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java66
2 files changed, 35 insertions, 32 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java
index cb1ad8b..a308f43 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java
@@ -206,6 +206,7 @@ public class Scene extends SceneGraphBase {
public void initRS(RenderScriptGL rs, Resources res, SceneManager sceneManager) {
mRS = rs;
+ mRes = res;
long start = System.currentTimeMillis();
mTransformRSData = mRootTransforms.getRSData(rs);
long end = System.currentTimeMillis();
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
index cebfcf4..ed9b7bf 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
@@ -48,7 +48,8 @@ public class TestAppRS {
private static String TAG = "TestAppRS";
private final int STATE_LAST_FOCUS = 1;
private final boolean mLoadFromSD = true;
- private static String mSDCardPath = "sdcard/scenegraph/";
+ private static String mSDFilePath = "sdcard/scenegraph/";
+ private static String mFilePath = "";
int mWidth;
int mHeight;
@@ -100,7 +101,7 @@ public class TestAppRS {
mTouchHandler = new TouchHandler();
mSceneManager = new SceneManager();
- // Initializes all the RS specific scenegraph elements
+ // Initializes all the RS specific scenegraph elements
mSceneManager.initRS(mRS, mRes, mWidth, mHeight);
// Shows the loading screen with some text
@@ -112,7 +113,7 @@ public class TestAppRS {
initRS();
// Load a scene to render
- mSceneManager.loadModel(mSDCardPath + modelName, mLoadedCallback);
+ mSceneManager.loadModel(mFilePath + modelName, mLoadedCallback);
}
// When a new model file is selected from the UI, this function gets called to init everything
@@ -140,7 +141,7 @@ public class TestAppRS {
ScriptField_FShaderParams_s mFsConst;
private ProgramVertex mPV_Paint;
ScriptField_VShaderParams_s mVsConst;
-
+
private Allocation mDefaultCube;
private Allocation mAllocPV;
private Allocation mEnvCube;
@@ -186,55 +187,54 @@ public class TestAppRS {
Allocation tempEnv;
Allocation tempDiff;
- InputStream openStream(String name) {
+ Allocation loadCubemap(String name) {
InputStream is = null;
try {
if (!mLoadFromSD) {
is = mRes.getAssets().open(name);
} else {
- File f = new File(mSDCardPath + name);
+ File f = new File(mSDFilePath + name);
is = new BufferedInputStream(new FileInputStream(f));
}
} catch (IOException e) {
- Log.e("PAINTSHADERS", " Message: " + e.getMessage());
+ Log.e("ImageLoaderTask", " Message: " + e.getMessage());
+ return null;
+ }
+
+ Bitmap b = BitmapFactory.decodeStream(is);
+ try {
+ is.close();
+ } catch (IOException e) {
+ Log.e("ImageLoaderTask", " Message: " + e.getMessage());
}
- return is;
+
+ return Allocation.createCubemapFromBitmap(mRS,
+ b,
+ MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
}
protected Boolean doInBackground(String... names) {
long start = System.currentTimeMillis();
- InputStream is = openStream("cube_env.png");
- if (is == null) {
- return new Boolean(false);
- }
- Bitmap b = BitmapFactory.decodeStream(is);
- tempEnv = Allocation.createCubemapFromBitmap(mRS,
- b,
- MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
-
- is = openStream("cube_spec.png");
- if (is == null) {
- return new Boolean(false);
- }
+ tempEnv = loadCubemap("cube_env.png");
+ tempDiff = loadCubemap("cube_spec.png");
- b = BitmapFactory.decodeStream(is);
- tempDiff = Allocation.createCubemapFromBitmap(mRS,
- b,
- MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
long end = System.currentTimeMillis();
Log.v("TIMER", "Image load time: " + (end - start));
return new Boolean(true);
}
protected void onPostExecute(Boolean result) {
- mEnvCube = tempEnv;
- mDiffCube = tempDiff;
+ if (tempEnv != null) {
+ mEnvCube = tempEnv;
+ mPF_Paint.bindTexture(mEnvCube, 1);
+ }
- mPF_Paint.bindTexture(mEnvCube, 1);
- mPF_Aluminum.bindTexture(mDiffCube, 1);
+ if (tempDiff != null) {
+ mDiffCube = tempDiff;
+ mPF_Aluminum.bindTexture(mDiffCube, 1);
+ }
}
}
@@ -433,13 +433,15 @@ public class TestAppRS {
FullscreenBlur.createRenderTargets(mRS, mWidth, mHeight);
initPaintShaders();
- new ImageLoaderTask().execute();
Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.defaultcube);
mDefaultCube = Allocation.createCubemapFromBitmap(mRS, b);
mPF_Paint.bindTexture(mDefaultCube, 1);
mPF_Aluminum.bindTexture(mDefaultCube, 1);
+ // Reflection maps from SD card
+ new ImageLoaderTask().execute();
+
ScriptC_render renderLoop = mSceneManager.getRenderLoop();
renderLoop.bind_vConst(mVsConst);
renderLoop.bind_fConst(mFsConst);