Compiling Renderscript Source Code
As I mentioned in my previous post (Compiling renderscript code at runtime), I try to compile renderscript code at runtime. As suggested by Kietz I need to alter the ScriptC class
Solution 1:
RenderScript's source can be found at android.googlesource.com, along with that of the rest of Android. If you want to rebuild Android or a part of it, here is probably a good place to start.
However, that is overkill. If you can't modify ScriptC
directly, just inherit from it. This is possible because the only methods you need from ScriptC
are its protected constructors. For example, I wrote HackedScriptC
which does nothing but forward its arguments to ScriptC()
:
package com.example.android.rs.extremehax;
import android.content.res.Resources;
import android.renderscript.RenderScript;
import android.renderscript.ScriptC;
publicclassHackedScriptCextendsScriptC {
publicHackedScriptC(RenderScript rs, Resources resources, int id) {
// simple passthru to the only constructor that ScriptC_mono usessuper(rs, resources, id);
}
}
It can now be substituted for ScriptC
in a glue class:
package com.example.android.rs.extremehax;
// ... publicclassScriptC_monoextendsHackedScriptC {
// otherwise identical glue class...
In your case, you would not invoke the super constructor ScriptC(RenderScript,Resources,int)
because that invokes internalCreate
, which you want to override. Instead, invoke ScriptC(int,RenderScript)
.
Post a Comment for "Compiling Renderscript Source Code"