summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/renderscript/RenderScript.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/renderscript/RenderScript.java')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java101
1 files changed, 81 insertions, 20 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index ad10832..03294b5 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2008-2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package android.renderscript;
+import java.io.File;
import java.lang.reflect.Field;
import android.content.Context;
@@ -82,6 +83,25 @@ 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;
+
+ /**
+ * Sets the directory to use as a persistent storage for the
+ * renderscript object file cache.
+ *
+ * @hide
+ * @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();
+ }
+
// Methods below are wrapped to protect the non-threadsafe
// lockless fifo.
@@ -231,10 +251,10 @@ public class RenderScript {
rsnTypeGetNativeData(mContext, id, typeData);
}
- native int rsnAllocationCreateTyped(int con, int type, int mip, int usage);
- synchronized int nAllocationCreateTyped(int type, int mip, int usage) {
+ native int rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer);
+ synchronized int nAllocationCreateTyped(int type, int mip, int usage, int pointer) {
validate();
- return rsnAllocationCreateTyped(mContext, type, mip, usage);
+ return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer);
}
native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
@@ -269,6 +289,33 @@ public class RenderScript {
validate();
rsnAllocationSyncAll(mContext, alloc, src);
}
+ native int rsnAllocationGetSurfaceTextureID(int con, int alloc);
+ synchronized int nAllocationGetSurfaceTextureID(int alloc) {
+ validate();
+ return rsnAllocationGetSurfaceTextureID(mContext, alloc);
+ }
+ native void rsnAllocationGetSurfaceTextureID2(int con, int alloc, SurfaceTexture st);
+ synchronized void nAllocationGetSurfaceTextureID2(int alloc, SurfaceTexture st) {
+ validate();
+ rsnAllocationGetSurfaceTextureID2(mContext, alloc, st);
+ }
+ native void rsnAllocationSetSurface(int con, int alloc, Surface sur);
+ synchronized void nAllocationSetSurface(int alloc, Surface sur) {
+ validate();
+ rsnAllocationSetSurface(mContext, alloc, sur);
+ }
+ native void rsnAllocationIoSend(int con, int alloc);
+ synchronized void nAllocationIoSend(int alloc) {
+ validate();
+ rsnAllocationIoSend(mContext, alloc);
+ }
+ native void rsnAllocationIoReceive(int con, int alloc);
+ synchronized void nAllocationIoReceive(int alloc) {
+ validate();
+ rsnAllocationIoReceive(mContext, alloc);
+ }
+
+
native void rsnAllocationGenerateMipmaps(int con, int alloc);
synchronized void nAllocationGenerateMipmaps(int alloc) {
validate();
@@ -547,15 +594,15 @@ public class RenderScript {
validate();
rsnProgramBindSampler(mContext, vpf, slot, s);
}
- native int rsnProgramFragmentCreate(int con, String shader, int[] params);
- synchronized int nProgramFragmentCreate(String shader, int[] params) {
+ native int rsnProgramFragmentCreate(int con, String shader, String[] texNames, int[] params);
+ synchronized int nProgramFragmentCreate(String shader, String[] texNames, int[] params) {
validate();
- return rsnProgramFragmentCreate(mContext, shader, params);
+ return rsnProgramFragmentCreate(mContext, shader, texNames, params);
}
- native int rsnProgramVertexCreate(int con, String shader, int[] params);
- synchronized int nProgramVertexCreate(String shader, int[] params) {
+ native int rsnProgramVertexCreate(int con, String shader, String[] texNames, int[] params);
+ synchronized int nProgramVertexCreate(String shader, String[] texNames, int[] params) {
validate();
- return rsnProgramVertexCreate(mContext, shader, params);
+ return rsnProgramVertexCreate(mContext, shader, texNames, params);
}
native int rsnMeshCreate(int con, int[] vtx, int[] idx, int[] prim);
@@ -584,6 +631,11 @@ public class RenderScript {
rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount);
}
+ native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q);
+ synchronized int nPathCreate(int prim, boolean isStatic, int vtx, int loop, float q) {
+ validate();
+ return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q);
+ }
int mDev;
int mContext;
@@ -837,7 +889,8 @@ public class RenderScript {
mRS.mErrorCallback.mErrorNum = subID;
mRS.mErrorCallback.run();
} else {
- //throw new RSRuntimeException("Received error num " + subID + ", details: " + e);
+ // Do not throw here. In these cases, we do not have
+ // a fatal error.
}
continue;
}
@@ -856,7 +909,9 @@ public class RenderScript {
}
RenderScript(Context ctx) {
- mApplicationContext = ctx.getApplicationContext();
+ if (ctx != null) {
+ mApplicationContext = ctx.getApplicationContext();
+ }
}
/**
@@ -868,21 +923,16 @@ public class RenderScript {
return mApplicationContext;
}
- static int getTargetSdkVersion(Context ctx) {
- return ctx.getApplicationInfo().targetSdkVersion;
- }
-
/**
* Create a basic RenderScript context.
*
+ * @hide
* @param ctx The context.
* @return RenderScript
*/
- public static RenderScript create(Context ctx) {
+ public static RenderScript create(Context ctx, int sdkVersion) {
RenderScript rs = new RenderScript(ctx);
- int sdkVersion = getTargetSdkVersion(ctx);
-
rs.mDev = rs.nDeviceCreate();
rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
if (rs.mContext == 0) {
@@ -894,6 +944,17 @@ public class RenderScript {
}
/**
+ * Create a basic RenderScript context.
+ *
+ * @param ctx The context.
+ * @return RenderScript
+ */
+ public static RenderScript create(Context ctx) {
+ int v = ctx.getApplicationInfo().targetSdkVersion;
+ return create(ctx, v);
+ }
+
+ /**
* Print the currently available debugging information about the state of
* the RS context to the log.
*
@@ -939,7 +1000,7 @@ public class RenderScript {
int safeID(BaseObj o) {
if(o != null) {
- return o.getID();
+ return o.getID(this);
}
return 0;
}