Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 439752d4 authored by Stephen Hines's avatar Stephen Hines Committed by Android (Google) Code Review
Browse files

Merge "Defer RS cache creation until a ScriptC is built." into jb-mr2-dev

parents 8515256a 7d25a829
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -83,11 +83,7 @@ public class RenderScript {
    native void nContextInitToClient(int con);
    native void nContextDeinitToClient(int con);

    /**
     * Name of the file that holds the object cache.
     */
    private static final String CACHE_PATH = "com.android.renderscript.cache";
    static String mCachePath;
    static File mCacheDir;

     /**
     * Sets the directory to use as a persistent storage for the
@@ -97,9 +93,8 @@ public class RenderScript {
     * @param cacheDir A directory the current process can write to
     */
    public static void setupDiskCache(File cacheDir) {
        File f = new File(cacheDir, CACHE_PATH);
        mCachePath = f.getAbsolutePath();
        f.mkdirs();
        // Defer creation of cache path to nScriptCCreate().
        mCacheDir = cacheDir;
    }

    public enum ContextType {
+13 −1
Original line number Diff line number Diff line
@@ -64,6 +64,12 @@ public class ScriptC extends Script {
        rs.addAllocSizeForGC(mGCSize);
    }

    /**
     * Name of the file that holds the object cache.
     */
    private static final String CACHE_PATH = "com.android.renderscript.cache";

    static String mCachePath;

    private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) {
        byte[] pgm;
@@ -96,7 +102,13 @@ public class ScriptC extends Script {

        String resName = resources.getResourceEntryName(resourceID);

        // 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, rs.mCachePath, pgm, pgmLength);
        return rs.nScriptCCreate(resName, mCachePath, pgm, pgmLength);
    }
}