diff options
author | Alex Sakhartchouk <alexst@google.com> | 2012-01-26 15:51:19 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2012-01-26 15:51:19 -0800 |
commit | d4cb9c587c23e3c24d928b0ac1a4de5679846f93 (patch) | |
tree | 54c7f39dbed49526d2ec4ab36f2d5c591cf467d7 /tests/RenderScriptTests/SceneGraph/src | |
parent | 782e74c84ad5d3e6b95225e320c23ef5793d4a9c (diff) | |
download | frameworks_base-d4cb9c587c23e3c24d928b0ac1a4de5679846f93.zip frameworks_base-d4cb9c587c23e3c24d928b0ac1a4de5679846f93.tar.gz frameworks_base-d4cb9c587c23e3c24d928b0ac1a4de5679846f93.tar.bz2 |
Separating scenegraph from the app that uses it.
Change-Id: I326d3e9804ae2433e8963105442c4a0b8f8f9a6f
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src')
25 files changed, 51 insertions, 59 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java index a3bf023..301075e 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java @@ -48,14 +48,8 @@ public class ColladaScene { private final int STATE_LAST_FOCUS = 1; boolean mLoadFromSD = false; - TestAppRS mRenderer; SceneLoadedCallback mCallback; - public ColladaScene(String name, TestAppRS renderer) { - modelName = name; - mRenderer = renderer; - } - public ColladaScene(String name, SceneLoadedCallback cb) { modelName = name; mCallback = cb; @@ -104,9 +98,6 @@ public class ColladaScene { protected void onPostExecute(Boolean result) { mActiveScene = sceneSource.getScene(); - if (mRenderer != null) { - mRenderer.prepareToRender(mActiveScene); - } if (mCallback != null) { mCallback.mLoadedScene = mActiveScene; mCallback.run(); diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java index 0c6312f..52523b5 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java @@ -68,7 +68,7 @@ public class FragmentShader extends Shader { return this; } - FragmentShader create() { + public FragmentShader create() { if (mShader.mPerShaderConstants != null) { mBuilder.addConstant(mShader.mPerShaderConstants); } @@ -90,6 +90,10 @@ public class FragmentShader extends Shader { FragmentShader() { } + public ProgramFragment getProgram() { + return mProgram; + } + public void updateTextures(RenderScriptGL rs, Resources res) { int shaderTextureStart = mTextureTypes.size(); for (int i = 0; i < mShaderTextureNames.size(); i ++) { diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java index cf4a846..8b2b8db 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java @@ -151,7 +151,7 @@ public class Renderable extends RenderableBase { mRsFieldItem.pf_textures[slot] = a; } - void setVisible(RenderScriptGL rs, boolean vis) { + public void setVisible(RenderScriptGL rs, boolean vis) { getRsField(rs, null); mRsFieldItem.cullType = vis ? 0 : 2; mRsField.set(mRsFieldItem, 0, true); diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java index 2a88b6b..8ddeda7 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java @@ -149,8 +149,8 @@ public class SceneManager extends SceneGraphBase { } public static class SceneLoadedCallback implements Runnable { - Scene mLoadedScene; - String mName; + public Scene mLoadedScene; + public String mName; public void run() { } } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java index 4351f66..2ceed32 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java @@ -59,7 +59,7 @@ public class VertexShader extends Shader { return this; } - VertexShader create() { + public VertexShader create() { if (mShader.mPerShaderConstants != null) { mBuilder.addConstant(mShader.mPerShaderConstants); } @@ -74,6 +74,10 @@ public class VertexShader extends Shader { VertexShader() { } + public ProgramVertex getProgram() { + return mProgram; + } + public ScriptField_VertexShader_s getRSData(RenderScriptGL rs, Resources res) { if (mField != null) { return mField; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs index 980eb9f..50554a0 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs @@ -17,7 +17,7 @@ #pragma rs java_package_name(com.android.scenegraph) //#define DEBUG_CAMERA -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" void root(const rs_allocation *v_in, rs_allocation *v_out, const float *usrData) { diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs index bca6240..024e026 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs @@ -16,7 +16,7 @@ #pragma rs java_package_name(com.android.scenegraph) -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" static void getTransformedSphere(SgRenderable *obj) { obj->worldBoundingSphere = obj->boundingSphere; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs index d2f70e6..cd46c14 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs @@ -18,8 +18,7 @@ // The sole purpose of this script is to have various structs exposed // so that java reflected classes are generated -#include "transform_def.rsh" -#include "testApp.rsh" +#include "scenegraph_objects.rsh" SgTransform *exportPtr; SgRenderState *sExport; SgRenderable *drExport; @@ -29,11 +28,3 @@ SgLight *exportPtrLight; SgShaderParam *spExport; SgVertexShader *pvExport; SgFragmentShader *pfExport; - -FBlurOffsets *blurExport; -VertexShaderInputs *iExport; -VShaderParams *vConst; -FShaderParams *fConst; -FShaderLightParams *fConts2; -VSParams *vConst2; -VObjectParams *vConst3; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs index 4cd412d..f5816ed 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs @@ -16,7 +16,7 @@ #pragma rs java_package_name(com.android.scenegraph) -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" //#define DEBUG_PARAMS diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs index ae489af..e11979f 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs @@ -17,7 +17,7 @@ #pragma rs java_package_name(com.android.scenegraph) //#define DEBUG_LIGHT -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" void root(const rs_allocation *v_in, rs_allocation *v_out) { diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs index 92ac6bb..0d524a6 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs @@ -16,7 +16,7 @@ #pragma rs java_package_name(com.android.scenegraph) -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" //#define DEBUG_PARAMS diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh index 01e6ae5..16a877d 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh @@ -16,7 +16,7 @@ #pragma rs java_package_name(com.android.scenegraph) -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" //#define DEBUG_PARAMS diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs index afe5fa6..0d6c795 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs @@ -17,7 +17,7 @@ #pragma rs java_package_name(com.android.scenegraph) #include "rs_graphics.rsh" -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" rs_script gTransformScript; rs_script gCameraScript; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform_def.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph_objects.rsh index e3df60e..e3df60e 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform_def.rsh +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph_objects.rsh diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs index 6bc5317..ce5e999 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs @@ -18,7 +18,7 @@ //#define DEBUG_TRANSFORMS -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" rs_script gTransformScript; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs index 0890b01..88955a8 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs @@ -16,7 +16,7 @@ #pragma rs java_package_name(com.android.scenegraph) -#include "transform_def.rsh" +#include "scenegraph_objects.rsh" //#define DEBUG_PARAMS diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FileSelector.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FileSelector.java index 691b433..420e133 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FileSelector.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FileSelector.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import java.io.File; import java.io.FileFilter; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FullscreenBlur.java index 17ee621..2e764e9 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FullscreenBlur.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FullscreenBlur.java @@ -15,14 +15,11 @@ */
-package com.android.scenegraph;
+package com.android.testapp;
import java.util.ArrayList;
-import com.android.scenegraph.Float4Param;
-import com.android.scenegraph.SceneManager;
-import com.android.scenegraph.Texture2D;
-import com.android.scenegraph.TextureParam;
+import com.android.scenegraph.*;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -164,7 +161,7 @@ class FullscreenBlur { fb.setObjectConst(constants);
}
FragmentShader prog = fb.create();
- prog.mProgram.bindSampler(Sampler.CLAMP_LINEAR(rs), 0);
+ prog.getProgram().bindSampler(Sampler.CLAMP_LINEAR(rs), 0);
return prog;
}
@@ -176,7 +173,7 @@ class FullscreenBlur { mPV_Blur = vb.create();
mPF_Texture = getShader(res, rs, R.raw.texture, null);
- mPF_Texture.mProgram.bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(rs), 0);
+ mPF_Texture.getProgram().bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(rs), 0);
mPF_BlurH = getShader(res, rs, R.raw.blur_h, blurConst.getAllocation().getType());
mPF_BlurV = getShader(res, rs, R.raw.blur_v, blurConst.getAllocation().getType());
mPF_SelectColor = getShader(res, rs, R.raw.select_color, null);
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestApp.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestApp.java index ccdd2aa..8b032f7 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestApp.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestApp.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import android.renderscript.RSSurfaceView; import android.renderscript.RenderScript; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppLoadingScreen.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppLoadingScreen.java index 60bdbb9..b818833 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppLoadingScreen.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppLoadingScreen.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import java.util.ArrayList; import java.util.HashMap; @@ -33,8 +33,6 @@ import android.renderscript.Program.TextureType; import android.renderscript.ProgramStore.DepthFunc; import android.util.Log; -import com.android.scenegraph.SceneManager.SceneLoadedCallback; - // This is where the scenegraph and the rendered objects are initialized and used public class TestAppLoadingScreen { @@ -45,7 +43,7 @@ public class TestAppLoadingScreen { private Resources mRes; private RenderScriptGL mRS; - private ScriptC_scenegraph mScript; + private ScriptC_test_app mScript; public TestAppLoadingScreen(RenderScriptGL rs, Resources res) { mRS = rs; @@ -106,7 +104,7 @@ public class TestAppLoadingScreen { // Could also be used to do some custom renderscript work before handing things over // to the scenegraph void renderLoading() { - mScript = new ScriptC_scenegraph(mRS, mRes, R.raw.scenegraph); + mScript = new ScriptC_test_app(mRS, mRes, R.raw.test_app); mRS.bindRootScript(mScript); } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java index 087b776..8840d12 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java @@ -14,17 +14,15 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Vector; -import com.android.scenegraph.SceneManager; +import com.android.scenegraph.*; import com.android.scenegraph.SceneManager.SceneLoadedCallback; -import com.android.scenegraph.VertexShader; -import com.android.scenegraph.VertexShader.Builder; import android.content.res.Resources; import android.graphics.Bitmap; @@ -157,9 +155,9 @@ public class TestAppRS { fb.addShaderTexture(TextureType.TEXTURE_CUBE, "reflection"); } FragmentShader pf = fb.create(); - pf.mProgram.bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS), 0); + pf.getProgram().bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS), 0); if (addCubemap) { - pf.mProgram.bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(mRS), 1); + pf.getProgram().bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(mRS), 1); } return pf; } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppView.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java index cefa3e6..687f35b 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppView.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import java.io.Writer; import java.util.ArrayList; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TouchHandler.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java index eacc3d0..4d30341 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TouchHandler.java +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.scenegraph; +package com.android.testapp; import java.io.File; import java.io.IOException; @@ -39,7 +39,7 @@ import android.renderscript.Program.TextureType; import android.renderscript.ProgramStore.DepthFunc; import android.util.Log; -import com.android.scenegraph.SceneManager.SceneLoadedCallback; +import com.android.scenegraph.*; public class TouchHandler { diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rs index 421105b..cb4e3d0 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rs @@ -14,10 +14,19 @@ #pragma version(1) -#pragma rs java_package_name(com.android.scenegraph) +#pragma rs java_package_name(com.android.testapp) #include "rs_graphics.rsh" -#include "transform_def.rsh" +#include "test_app.rsh" + +// Making sure these get reflected +FBlurOffsets *blurExport; +VertexShaderInputs *iExport; +VShaderParams *vConst; +FShaderParams *fConst; +FShaderLightParams *fConts2; +VSParams *vConst2; +VObjectParams *vConst3; rs_program_vertex gPVBackground; rs_program_fragment gPFBackground; diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/testApp.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rsh index 2b16652..2885ac5 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/testApp.rsh +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rsh @@ -14,7 +14,7 @@ #pragma version(1) -#pragma rs java_package_name(com.android.scenegraph) +#pragma rs java_package_name(com.android.testapp) // Helpers typedef struct VShaderParams_s { |