diff options
Diffstat (limited to 'rs/java/android/renderscript/ScriptC.java')
-rw-r--r-- | rs/java/android/renderscript/ScriptC.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rs/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java index 9e76f52..3176e28 100644 --- a/rs/java/android/renderscript/ScriptC.java +++ b/rs/java/android/renderscript/ScriptC.java @@ -67,6 +67,26 @@ public class ScriptC extends Script { } /** + * Only intended for use by the generated derived classes. + * + * @param rs + * @hide + */ + protected ScriptC(RenderScript rs, String resName, byte[] bitcode32, byte[] bitcode64) { + super(0, rs); + long id = 0; + if (RenderScript.sPointerSize == 4) { + id = internalStringCreate(rs, resName, bitcode32); + } else { + id = internalStringCreate(rs, resName, bitcode64); + } + if (id == 0) { + throw new RSRuntimeException("Loading of ScriptC script failed."); + } + setID(id); + } + + /** * Name of the file that holds the object cache. */ private static final String CACHE_PATH = "com.android.renderscript.cache"; @@ -113,4 +133,17 @@ public class ScriptC extends Script { // Log.v(TAG, "Create script for resource = " + resName); return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength); } + + private static synchronized long internalStringCreate(RenderScript rs, String resName, byte[] bitcode) { + // Create the RS cache path if we haven't done so already. + if (mCachePath == null) { + File f = new File(rs.mCacheDir, CACHE_PATH); + mCachePath = f.getAbsolutePath(); + f.mkdirs(); + } + // Log.v(TAG, "Create script for resource = " + resName); + return rs.nScriptCCreate(resName, mCachePath, bitcode, bitcode.length); + } + + } |