diff options
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 9 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Script.java | 51 |
2 files changed, 54 insertions, 6 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 00e8769d4e5e..50d888fa242b 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -517,6 +517,8 @@ public class RenderScript { } native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params); native void rsnScriptForEach(int con, int id, int slot, int ain, int aout); + native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params, + int xstart, int xend, int ystart, int yend, int zstart, int zend); synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) { validate(); if (params == null) { @@ -525,6 +527,13 @@ public class RenderScript { rsnScriptForEach(mContext, id, slot, ain, aout, params); } } + + synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params, + int xstart, int xend, int ystart, int yend, int zstart, int zend) { + validate(); + rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend); + } + native void rsnScriptInvokeV(int con, int id, int slot, byte[] params); synchronized void nScriptInvokeV(int id, int slot, byte[] params) { validate(); diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index fe80967e6f35..b53ba0d7e80a 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -166,6 +166,25 @@ public class Script extends BaseObj { mRS.nScriptForEach(getID(mRS), slot, in_id, out_id, params); } + protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) { + if (ain == null && aout == null) { + throw new RSIllegalArgumentException( + "At least one of ain or aout is required to be non-null."); + } + int in_id = 0; + if (ain != null) { + in_id = ain.getID(mRS); + } + int out_id = 0; + if (aout != null) { + out_id = aout.getID(mRS); + } + byte[] params = null; + if (v != null) { + params = v.getData(); + } + mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend); + } Script(int id, RenderScript rs) { super(id, rs); @@ -320,29 +339,43 @@ public class Script extends BaseObj { } public static final class LaunchOptions { - protected int xstart = -1; - protected int ystart = -1; - protected int xend = -1 ; - protected int yend = -1; + protected int xstart = 0; + protected int ystart = 0; + protected int xend = 0; + protected int yend = 0; + protected int zstart = 0; + protected int zend = 0; protected int strategy; - public void setX(int xstartArg, int xendArg) { + public LaunchOptions setX(int xstartArg, int xendArg) { if (xstartArg < 0 || xendArg <= xstartArg) { throw new RSIllegalArgumentException("Invalid dimensions"); } xstart = xstartArg; xend = xendArg; + return this; } - public void setY(int ystartArg, int yendArg) { + public LaunchOptions setY(int ystartArg, int yendArg) { if (ystartArg < 0 || yendArg <= ystartArg) { throw new RSIllegalArgumentException("Invalid dimensions"); } ystart = ystartArg; yend = yendArg; + return this; + } + + public LaunchOptions setZ(int zstartArg, int zendArg) { + if (zstartArg < 0 || zendArg <= zstartArg) { + throw new RSIllegalArgumentException("Invalid dimensions"); + } + zstart = zstartArg; + zend = zendArg; + return this; } + public int getXStart() { return xstart; } @@ -355,6 +388,12 @@ public class Script extends BaseObj { public int getYEnd() { return yend; } + public int getZStart() { + return zstart; + } + public int getZEnd() { + return zend; + } } } |