diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-12-16 10:43:38 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2011-12-16 10:44:03 -0800 |
commit | f92189d2aea9856c11c26ebe392cd53dd969c0b8 (patch) | |
tree | ebb4c328b79cf666557e91b6618150da02a3b3fa /tests/RenderScriptTests/SceneGraph/src | |
parent | 8d57f404fa2bfbc1cc4427c754bca5a3bee0fc47 (diff) | |
download | frameworks_base-f92189d2aea9856c11c26ebe392cd53dd969c0b8.zip frameworks_base-f92189d2aea9856c11c26ebe392cd53dd969c0b8.tar.gz frameworks_base-f92189d2aea9856c11c26ebe392cd53dd969c0b8.tar.bz2 |
Refactor some common code and make detecting sdcard paths more robust.
Change-Id: I6555f6b82e94f8eee0400eddaaffc0442d5e1c41
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src')
4 files changed, 29 insertions, 20 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java index 037741d..a3bf023 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java @@ -65,9 +65,7 @@ public class ColladaScene { mRS = rs; mRes = res; - if (modelName.indexOf("sdcard/") != -1) { - mLoadFromSD = true; - } + mLoadFromSD = SceneManager.isSDCardPath(modelName); new ColladaLoaderTask().execute(modelName); } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java index 0026872..8c6b5fc 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java @@ -81,16 +81,6 @@ class FullscreenBlur { Allocation.USAGE_GRAPHICS_RENDER_TARGET);
}
- private static Renderable getRenderableQuad(String name, RenderState state, SceneManager sceneManager) {
- Renderable quad = new Renderable();
- quad.setTransform(new MatrixTransform());
- quad.setMesh(sceneManager.getScreenAlignedQuad());
- quad.setName(name);
- quad.setRenderState(state);
- quad.setCullType(1);
- return quad;
- }
-
static void addBlurPasses(Scene scene, RenderScriptGL rs, SceneManager sceneManager) {
ArrayList<RenderableBase> allDraw = scene.getRenderables();
int numDraw = allDraw.size();
@@ -131,7 +121,7 @@ class FullscreenBlur { selectColorPass.setShouldClearDepth(false);
selectColorPass.setCamera(scene.getCameras().get(1));
// Make blur shape
- Renderable quad = getRenderableQuad("ScreenAlignedQuadS", selectCol, sceneManager);
+ Renderable quad = sceneManager.getRenderableQuad("ScreenAlignedQuadS", selectCol);
quad.updateTextures(rs, sRenderTargetBlur0Color, 0);
selectColorPass.appendRenderable(quad);
scene.appendRenderPass(selectColorPass);
@@ -143,7 +133,7 @@ class FullscreenBlur { horizontalBlurPass.setShouldClearDepth(false);
horizontalBlurPass.setCamera(scene.getCameras().get(1));
// Make blur shape
- quad = getRenderableQuad("ScreenAlignedQuadH", hBlur, sceneManager);
+ quad = sceneManager.getRenderableQuad("ScreenAlignedQuadH", hBlur);
quad.updateTextures(rs, sRenderTargetBlur2Color, 0);
horizontalBlurPass.appendRenderable(quad);
scene.appendRenderPass(horizontalBlurPass);
@@ -155,7 +145,7 @@ class FullscreenBlur { verticalBlurPass.setShouldClearDepth(false);
verticalBlurPass.setCamera(scene.getCameras().get(1));
// Make blur shape
- quad = getRenderableQuad("ScreenAlignedQuadV", vBlur, sceneManager);
+ quad = sceneManager.getRenderableQuad("ScreenAlignedQuadV", vBlur);
quad.updateTextures(rs, sRenderTargetBlur1Color, 0);
verticalBlurPass.appendRenderable(quad);
scene.appendRenderPass(verticalBlurPass);
@@ -173,7 +163,7 @@ class FullscreenBlur { compositePass.setClearDepth(1.0f);
compositePass.setShouldClearDepth(false);
compositePass.setCamera(scene.getCameras().get(1));
- Renderable quad = getRenderableQuad("ScreenAlignedQuad", drawTex, sceneManager);
+ Renderable quad = sceneManager.getRenderableQuad("ScreenAlignedQuad", drawTex);
quad.updateTextures(rs, sRenderTargetBlur2Color, 0);
compositePass.appendRenderable(quad);
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java index 3bb49f3..5759fcc 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java @@ -46,6 +46,19 @@ public class SceneManager extends SceneGraphBase { int mWidth; int mHeight; + public static boolean isSDCardPath(String path) { + int sdCardIndex = path.indexOf("sdcard/"); + // We are looking for /sdcard/ or sdcard/ + if (sdCardIndex == 0 || sdCardIndex == 1) { + return true; + } + sdCardIndex = path.indexOf("mnt/sdcard/"); + if (sdCardIndex == 0 || sdCardIndex == 1) { + return true; + } + return false; + } + public static class SceneLoadedCallback implements Runnable { Scene mLoadedScene; String mName; @@ -98,6 +111,16 @@ public class SceneManager extends SceneGraphBase { return mQuad; } + public Renderable getRenderableQuad(String name, RenderState state) { + Renderable quad = new Renderable(); + quad.setTransform(new MatrixTransform()); + quad.setMesh(getScreenAlignedQuad()); + quad.setName(name); + quad.setRenderState(state); + quad.setCullType(1); + return quad; + } + public void initRS(RenderScriptGL rs, Resources res, int w, int h) { mRS = rs; mRes = res; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java index e08622d..8242986 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java @@ -49,9 +49,7 @@ public class Texture2D extends SceneGraphBase { } public void setFileDir(String dir) { - if (dir.indexOf("sdcard/") != -1) { - mLoadFromSD = true; - } + mLoadFromSD = SceneManager.isSDCardPath(dir); mFileDir = dir; } |