@@ -87,6 +87,7 @@ public class RenderScript {
8787 * Name of the file that holds the object cache.
8888 */
8989 private static final String CACHE_PATH = "com.android.renderscript.cache" ;
90+ static String mCachePath ;
9091
9192 /**
9293 * Sets the directory to use as a persistent storage for the
@@ -95,8 +96,6 @@ public class RenderScript {
9596 * @hide
9697 * @param cacheDir A directory the current process can write to
9798 */
98-
99- static String mCachePath ;
10099 public static void setupDiskCache (File cacheDir ) {
101100 File f = new File (cacheDir , CACHE_PATH );
102101 mCachePath = f .getAbsolutePath ();
@@ -905,7 +904,9 @@ public void run() {
905904 }
906905
907906 RenderScript (Context ctx ) {
908- mApplicationContext = ctx .getApplicationContext ();
907+ if (ctx != null ) {
908+ mApplicationContext = ctx .getApplicationContext ();
909+ }
909910 }
910911
911912 /**
@@ -917,21 +918,16 @@ public final Context getApplicationContext() {
917918 return mApplicationContext ;
918919 }
919920
920- static int getTargetSdkVersion (Context ctx ) {
921- return ctx .getApplicationInfo ().targetSdkVersion ;
922- }
923-
924921 /**
925922 * Create a basic RenderScript context.
926923 *
924+ * @hide
927925 * @param ctx The context.
928926 * @return RenderScript
929927 */
930- public static RenderScript create (Context ctx ) {
928+ public static RenderScript create (Context ctx , int sdkVersion ) {
931929 RenderScript rs = new RenderScript (ctx );
932930
933- int sdkVersion = getTargetSdkVersion (ctx );
934-
935931 rs .mDev = rs .nDeviceCreate ();
936932 rs .mContext = rs .nContextCreate (rs .mDev , 0 , sdkVersion );
937933 if (rs .mContext == 0 ) {
@@ -942,6 +938,17 @@ public static RenderScript create(Context ctx) {
942938 return rs ;
943939 }
944940
941+ /**
942+ * Create a basic RenderScript context.
943+ *
944+ * @param ctx The context.
945+ * @return RenderScript
946+ */
947+ public static RenderScript create (Context ctx ) {
948+ int v = ctx .getApplicationInfo ().targetSdkVersion ;
949+ return create (ctx , v );
950+ }
951+
945952 /**
946953 * Print the currently available debugging information about the state of
947954 * the RS context to the log.
0 commit comments