diff options
author | Alex Sakhartchouk <alexst@google.com> | 2012-01-20 15:02:00 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2012-01-20 15:02:00 -0800 |
commit | 3c5ebd1e8df10f72dc7ca5f6203f72f320b4c485 (patch) | |
tree | b40de6536c752f2f1ba585d90af9b2d453ecfd6f /tests/RenderScriptTests/SceneGraph/src | |
parent | 3e60290d96ca28a97542aa13dc7b1d77a8243eaf (diff) | |
download | frameworks_base-3c5ebd1e8df10f72dc7ca5f6203f72f320b4c485.zip frameworks_base-3c5ebd1e8df10f72dc7ca5f6203f72f320b4c485.tar.gz frameworks_base-3c5ebd1e8df10f72dc7ca5f6203f72f320b4c485.tar.bz2 |
Refactoring out some params code.
Change-Id: Ie4268faeefd6858057c242bea98aceb3800cef75
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src')
4 files changed, 21 insertions, 56 deletions
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 d68b1a5..4cd412d 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs @@ -23,20 +23,7 @@ #include "params.rsh" void root(rs_allocation *v_out, const void *usrData) { - SgFragmentShader *shader = (SgFragmentShader *)rsGetElementAt(*v_out, 0); const SgCamera *camera = (const SgCamera*)usrData; - if (rsIsObject(shader->shaderConst)) { - uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(shader->shaderConst, 0); - - int numParams = 0; - if (rsIsObject(shader->shaderConstParams)) { - numParams = rsAllocationGetDimX(shader->shaderConstParams); - } - for (int i = 0; i < numParams; i ++) { - SgShaderParam *current = (SgShaderParam*)rsGetElementAt(shader->shaderConstParams, i); - processParam(current, constantBuffer, camera); - } - rsgAllocationSyncAll(shader->shaderConst); - } + processAllParams(shader->shaderConst, shader->shaderConstParams, camera); } 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 a122bd9f..92ac6bb 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs @@ -31,32 +31,6 @@ void root(rs_allocation *v_out, const void *usrData) { } const SgCamera *camera = (const SgCamera*)usrData; - // Data we are updating - if (rsIsObject(drawable->pf_const)) { - uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(drawable->pf_const, 0); - - int numParams = 0; - if (rsIsObject(drawable->pf_constParams)) { - numParams = rsAllocationGetDimX(drawable->pf_constParams); - } - for (int i = 0; i < numParams; i ++) { - SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pf_constParams, i); - processParam(current, constantBuffer, camera); - } - //rsgAllocationSyncAll(drawable->pf_const); - } - - if (rsIsObject(drawable->pv_const)) { - uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(drawable->pv_const, 0); - - int numParams = 0; - if (rsIsObject(drawable->pv_constParams)) { - numParams = rsAllocationGetDimX(drawable->pv_constParams); - } - for (int i = 0; i < numParams; i ++) { - SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pv_constParams, i); - processParam(current, constantBuffer, camera); - } - //rsgAllocationSyncAll(drawable->pv_const); - } + processAllParams(drawable->pf_const, drawable->pf_constParams, camera); + processAllParams(drawable->pv_const, drawable->pv_constParams, camera); } diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh index e7adb66..01e6ae5 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh @@ -112,3 +112,20 @@ static void processParam(SgShaderParam *p, uint8_t *constantBuffer, const SgCame break; } } + +static void processAllParams(rs_allocation shaderConst, + rs_allocation allParams, + const SgCamera *camera) { + if (rsIsObject(shaderConst)) { + uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(shaderConst, 0); + + int numParams = 0; + if (rsIsObject(allParams)) { + numParams = rsAllocationGetDimX(allParams); + } + for (int i = 0; i < numParams; i ++) { + SgShaderParam *current = (SgShaderParam*)rsGetElementAt(allParams, i); + processParam(current, constantBuffer, camera); + } + } +} 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 f67379e..0890b01 100644 --- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs +++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs @@ -23,20 +23,7 @@ #include "params.rsh" void root(rs_allocation *v_out, const void *usrData) { - SgVertexShader *shader = (SgVertexShader *)rsGetElementAt(*v_out, 0); const SgCamera *camera = (const SgCamera*)usrData; - if (rsIsObject(shader->shaderConst)) { - uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(shader->shaderConst, 0); - - int numParams = 0; - if (rsIsObject(shader->shaderConstParams)) { - numParams = rsAllocationGetDimX(shader->shaderConstParams); - } - for (int i = 0; i < numParams; i ++) { - SgShaderParam *current = (SgShaderParam*)rsGetElementAt(shader->shaderConstParams, i); - processParam(current, constantBuffer, camera); - } - rsgAllocationSyncAll(shader->shaderConst); - } + processAllParams(shader->shaderConst, shader->shaderConstParams, camera); } |