| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 1 | /* | 
| Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 2 | * Copyright (C) 2008-2012 The Android Open Source Project | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | package android.renderscript; | 
|  | 18 |  | 
| Artur Satayev | 53ada2a | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 20 | import android.util.SparseArray; | 
|  | 21 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 22 | /** | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 23 | * The parent class for all executable scripts. This should not be used by | 
|  | 24 | * applications. | 
| Xusong Wang | 1f8dc65 | 2021-01-05 10:09:52 -0800 | [diff] [blame] | 25 | * | 
|  | 26 | * @deprecated Renderscript has been deprecated in API level 31. Please refer to the <a | 
|  | 27 | * href="https://developer.android.com/guide/topics/renderscript/migration-guide">migration | 
|  | 28 | * guide</a> for the proposed alternatives. | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 29 | **/ | 
| Xusong Wang | 1f8dc65 | 2021-01-05 10:09:52 -0800 | [diff] [blame] | 30 | @Deprecated | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 31 | public class Script extends BaseObj { | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | /** | 
|  | 34 | * KernelID is an identifier for a Script + root function pair. It is used | 
|  | 35 | * as an identifier for ScriptGroup creation. | 
|  | 36 | * | 
|  | 37 | * This class should not be directly created. Instead use the method in the | 
|  | 38 | * reflected or intrinsic code "getKernelID_funcname()". | 
|  | 39 | * | 
|  | 40 | */ | 
|  | 41 | public static final class KernelID extends BaseObj { | 
|  | 42 | Script mScript; | 
|  | 43 | int mSlot; | 
|  | 44 | int mSig; | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 45 | KernelID(long id, RenderScript rs, Script s, int slot, int sig) { | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 46 | super(id, rs); | 
|  | 47 | mScript = s; | 
|  | 48 | mSlot = slot; | 
|  | 49 | mSig = sig; | 
|  | 50 | } | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | private final SparseArray<KernelID> mKIDs = new SparseArray<KernelID>(); | 
|  | 54 | /** | 
|  | 55 | * Only to be used by generated reflected classes. | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 56 | */ | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 57 | protected KernelID createKernelID(int slot, int sig, Element ein, | 
|  | 58 | Element eout) { | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 59 | KernelID k = mKIDs.get(slot); | 
|  | 60 | if (k != null) { | 
|  | 61 | return k; | 
|  | 62 | } | 
|  | 63 |  | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 64 | long id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig); | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 65 | if (id == 0) { | 
|  | 66 | throw new RSDriverException("Failed to create KernelID"); | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | k = new KernelID(id, mRS, this, slot, sig); | 
|  | 70 | mKIDs.put(slot, k); | 
|  | 71 | return k; | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | /** | 
| Yang Ni | be392ad | 2015-01-23 17:16:02 -0800 | [diff] [blame] | 75 | * InvokeID is an identifier for an invoke function. It is used | 
|  | 76 | * as an identifier for ScriptGroup creation. | 
|  | 77 | * | 
|  | 78 | * This class should not be directly created. Instead use the method in the | 
|  | 79 | * reflected or intrinsic code "getInvokeID_funcname()". | 
|  | 80 | * | 
|  | 81 | */ | 
|  | 82 | public static final class InvokeID extends BaseObj { | 
|  | 83 | Script mScript; | 
|  | 84 | int mSlot; | 
|  | 85 | InvokeID(long id, RenderScript rs, Script s, int slot) { | 
|  | 86 | super(id, rs); | 
|  | 87 | mScript = s; | 
|  | 88 | mSlot = slot; | 
|  | 89 | } | 
|  | 90 | } | 
|  | 91 |  | 
|  | 92 | private final SparseArray<InvokeID> mIIDs = new SparseArray<InvokeID>(); | 
|  | 93 | /** | 
| Yang Ni | be392ad | 2015-01-23 17:16:02 -0800 | [diff] [blame] | 94 | * Only to be used by generated reflected classes. | 
|  | 95 | */ | 
|  | 96 | protected InvokeID createInvokeID(int slot) { | 
|  | 97 | InvokeID i = mIIDs.get(slot); | 
|  | 98 | if (i != null) { | 
|  | 99 | return i; | 
|  | 100 | } | 
|  | 101 |  | 
|  | 102 | long id = mRS.nScriptInvokeIDCreate(getID(mRS), slot); | 
|  | 103 | if (id == 0) { | 
|  | 104 | throw new RSDriverException("Failed to create KernelID"); | 
|  | 105 | } | 
|  | 106 |  | 
|  | 107 | i = new InvokeID(id, mRS, this, slot); | 
|  | 108 | mIIDs.put(slot, i); | 
|  | 109 | return i; | 
|  | 110 | } | 
|  | 111 |  | 
|  | 112 | /** | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 113 | * FieldID is an identifier for a Script + exported field pair. It is used | 
|  | 114 | * as an identifier for ScriptGroup creation. | 
|  | 115 | * | 
|  | 116 | * This class should not be directly created. Instead use the method in the | 
|  | 117 | * reflected or intrinsic code "getFieldID_funcname()". | 
|  | 118 | * | 
|  | 119 | */ | 
|  | 120 | public static final class FieldID extends BaseObj { | 
|  | 121 | Script mScript; | 
|  | 122 | int mSlot; | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 123 | FieldID(long id, RenderScript rs, Script s, int slot) { | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 124 | super(id, rs); | 
|  | 125 | mScript = s; | 
|  | 126 | mSlot = slot; | 
|  | 127 | } | 
|  | 128 | } | 
|  | 129 |  | 
|  | 130 | private final SparseArray<FieldID> mFIDs = new SparseArray(); | 
|  | 131 | /** | 
|  | 132 | * Only to be used by generated reflected classes. | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 133 | */ | 
|  | 134 | protected FieldID createFieldID(int slot, Element e) { | 
|  | 135 | FieldID f = mFIDs.get(slot); | 
|  | 136 | if (f != null) { | 
|  | 137 | return f; | 
|  | 138 | } | 
|  | 139 |  | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 140 | long id = mRS.nScriptFieldIDCreate(getID(mRS), slot); | 
| Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 141 | if (id == 0) { | 
|  | 142 | throw new RSDriverException("Failed to create FieldID"); | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | f = new FieldID(id, mRS, this, slot); | 
|  | 146 | mFIDs.put(slot, f); | 
|  | 147 | return f; | 
|  | 148 | } | 
|  | 149 |  | 
|  | 150 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 151 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 152 | * Only intended for use by generated reflected code. | 
|  | 153 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 154 | */ | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 155 | protected void invoke(int slot) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 156 | mRS.nScriptInvoke(getID(mRS), slot); | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 157 | } | 
|  | 158 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 159 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 160 | * Only intended for use by generated reflected code. | 
|  | 161 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 162 | */ | 
| Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 163 | protected void invoke(int slot, FieldPacker v) { | 
|  | 164 | if (v != null) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 165 | mRS.nScriptInvokeV(getID(mRS), slot, v.getData()); | 
| Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 166 | } else { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 167 | mRS.nScriptInvoke(getID(mRS), slot); | 
| Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 168 | } | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 169 | } | 
|  | 170 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 171 | /** | 
| Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 172 | * Only intended for use by generated reflected code. | 
|  | 173 | * | 
| Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 174 | */ | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 175 | protected void forEach(int slot, Allocation ain, Allocation aout, | 
|  | 176 | FieldPacker v) { | 
|  | 177 | forEach(slot, ain, aout, v, null); | 
| Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 178 | } | 
|  | 179 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 180 | /** | 
|  | 181 | * Only intended for use by generated reflected code. | 
|  | 182 | * | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 183 | */ | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 184 | protected void forEach(int slot, Allocation ain, Allocation aout, | 
|  | 185 | FieldPacker v, LaunchOptions sc) { | 
|  | 186 | // TODO: Is this necessary if nScriptForEach calls validate as well? | 
| Jason Sams | 678cc7f | 2014-03-05 16:09:02 -0800 | [diff] [blame] | 187 | mRS.validate(); | 
|  | 188 | mRS.validateObject(ain); | 
|  | 189 | mRS.validateObject(aout); | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 190 |  | 
| Jason Sams | d1516df | 2015-05-05 18:00:34 -0700 | [diff] [blame] | 191 | if (ain == null && aout == null && sc == null) { | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 192 | throw new RSIllegalArgumentException( | 
| Jason Sams | d1516df | 2015-05-05 18:00:34 -0700 | [diff] [blame] | 193 | "At least one of input allocation, output allocation, or LaunchOptions is required to be non-null."); | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 194 | } | 
| Tim Murray | ba9dd06 | 2013-02-12 16:22:34 -0800 | [diff] [blame] | 195 |  | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 196 | long[] in_ids = null; | 
| Stephen Hines | c9c7daf | 2014-08-13 17:32:19 +0000 | [diff] [blame] | 197 | if (ain != null) { | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 198 | in_ids    = mInIdsBuffer; | 
|  | 199 | in_ids[0] = ain.getID(mRS); | 
| Stephen Hines | c9c7daf | 2014-08-13 17:32:19 +0000 | [diff] [blame] | 200 | } | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 201 |  | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 202 | long out_id = 0; | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 203 | if (aout != null) { | 
|  | 204 | out_id = aout.getID(mRS); | 
|  | 205 | } | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 206 |  | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 207 | byte[] params = null; | 
|  | 208 | if (v != null) { | 
|  | 209 | params = v.getData(); | 
|  | 210 | } | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 211 |  | 
|  | 212 | int[] limits = null; | 
|  | 213 | if (sc != null) { | 
|  | 214 | limits = new int[6]; | 
|  | 215 |  | 
|  | 216 | limits[0] = sc.xstart; | 
|  | 217 | limits[1] = sc.xend; | 
|  | 218 | limits[2] = sc.ystart; | 
|  | 219 | limits[3] = sc.yend; | 
|  | 220 | limits[4] = sc.zstart; | 
|  | 221 | limits[5] = sc.zend; | 
|  | 222 | } | 
|  | 223 |  | 
|  | 224 | mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits); | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 225 | } | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 226 |  | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 227 | /** | 
|  | 228 | * Only intended for use by generated reflected code. | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 229 | */ | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 230 | protected void forEach(int slot, Allocation[] ains, Allocation aout, | 
|  | 231 | FieldPacker v) { | 
| Jason Sams | 6a420b5 | 2015-03-30 15:31:26 -0700 | [diff] [blame] | 232 |  | 
|  | 233 | // FieldPacker is kept here to support regular params in the future. | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 234 | forEach(slot, ains, aout, v, null); | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 235 | } | 
|  | 236 |  | 
|  | 237 | /** | 
|  | 238 | * Only intended for use by generated reflected code. | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 239 | */ | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 240 | protected void forEach(int slot, Allocation[] ains, Allocation aout, | 
|  | 241 | FieldPacker v, LaunchOptions sc) { | 
|  | 242 | // TODO: Is this necessary if nScriptForEach calls validate as well? | 
| Jason Sams | 6a420b5 | 2015-03-30 15:31:26 -0700 | [diff] [blame] | 243 | // FieldPacker is kept here to support regular params in the future. | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 244 | mRS.validate(); | 
| Andreas Gampe | c8ddcdd | 2015-03-15 15:57:30 -0700 | [diff] [blame] | 245 | if (ains != null) { | 
|  | 246 | for (Allocation ain : ains) { | 
|  | 247 | mRS.validateObject(ain); | 
|  | 248 | } | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 249 | } | 
| Stephen Hines | c9c7daf | 2014-08-13 17:32:19 +0000 | [diff] [blame] | 250 | mRS.validateObject(aout); | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 251 |  | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 252 | if (ains == null && aout == null) { | 
|  | 253 | throw new RSIllegalArgumentException( | 
|  | 254 | "At least one of ain or aout is required to be non-null."); | 
|  | 255 | } | 
|  | 256 |  | 
| Andreas Gampe | ad555f9 | 2015-03-17 20:05:46 -0700 | [diff] [blame] | 257 | long[] in_ids; | 
|  | 258 | if (ains != null) { | 
|  | 259 | in_ids = new long[ains.length]; | 
|  | 260 | for (int index = 0; index < ains.length; ++index) { | 
|  | 261 | in_ids[index] = ains[index].getID(mRS); | 
|  | 262 | } | 
|  | 263 | } else { | 
|  | 264 | in_ids = null; | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 265 | } | 
|  | 266 |  | 
|  | 267 | long out_id = 0; | 
|  | 268 | if (aout != null) { | 
|  | 269 | out_id = aout.getID(mRS); | 
|  | 270 | } | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 271 |  | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 272 | byte[] params = null; | 
|  | 273 | if (v != null) { | 
|  | 274 | params = v.getData(); | 
|  | 275 | } | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 276 |  | 
|  | 277 | int[] limits = null; | 
|  | 278 | if (sc != null) { | 
|  | 279 | limits = new int[6]; | 
|  | 280 |  | 
|  | 281 | limits[0] = sc.xstart; | 
|  | 282 | limits[1] = sc.xend; | 
|  | 283 | limits[2] = sc.ystart; | 
|  | 284 | limits[3] = sc.yend; | 
|  | 285 | limits[4] = sc.zstart; | 
|  | 286 | limits[5] = sc.zend; | 
|  | 287 | } | 
|  | 288 |  | 
|  | 289 | mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits); | 
| Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 290 | } | 
|  | 291 |  | 
| Matt Wala | 36eb1f7 | 2015-07-20 15:35:27 -0700 | [diff] [blame] | 292 | /** | 
| David Gross | 26ef7a73 | 2016-01-12 12:19:15 -0800 | [diff] [blame] | 293 | * Only intended for use by generated reflected code.  (General reduction) | 
|  | 294 | * | 
| David Gross | 26ef7a73 | 2016-01-12 12:19:15 -0800 | [diff] [blame] | 295 | */ | 
|  | 296 | protected void reduce(int slot, Allocation[] ains, Allocation aout, LaunchOptions sc) { | 
|  | 297 | mRS.validate(); | 
|  | 298 | if (ains == null || ains.length < 1) { | 
|  | 299 | throw new RSIllegalArgumentException( | 
|  | 300 | "At least one input is required."); | 
|  | 301 | } | 
|  | 302 | if (aout == null) { | 
|  | 303 | throw new RSIllegalArgumentException( | 
|  | 304 | "aout is required to be non-null."); | 
|  | 305 | } | 
|  | 306 | for (Allocation ain : ains) { | 
|  | 307 | mRS.validateObject(ain); | 
|  | 308 | } | 
|  | 309 |  | 
|  | 310 | long[] in_ids = new long[ains.length]; | 
|  | 311 | for (int index = 0; index < ains.length; ++index) { | 
|  | 312 | in_ids[index] = ains[index].getID(mRS); | 
|  | 313 | } | 
|  | 314 | long out_id = aout.getID(mRS); | 
|  | 315 |  | 
|  | 316 | int[] limits = null; | 
|  | 317 | if (sc != null) { | 
|  | 318 | limits = new int[6]; | 
|  | 319 |  | 
|  | 320 | limits[0] = sc.xstart; | 
|  | 321 | limits[1] = sc.xend; | 
|  | 322 | limits[2] = sc.ystart; | 
|  | 323 | limits[3] = sc.yend; | 
|  | 324 | limits[4] = sc.zstart; | 
|  | 325 | limits[5] = sc.zend; | 
|  | 326 | } | 
|  | 327 |  | 
| David Gross | 4a45785 | 2016-06-02 14:46:55 -0700 | [diff] [blame] | 328 | mRS.nScriptReduce(getID(mRS), slot, in_ids, out_id, limits); | 
| David Gross | 26ef7a73 | 2016-01-12 12:19:15 -0800 | [diff] [blame] | 329 | } | 
|  | 330 |  | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 331 | long[] mInIdsBuffer; | 
|  | 332 |  | 
| Tim Murray | 7a629fa | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 333 | Script(long id, RenderScript rs) { | 
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 334 | super(id, rs); | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 335 |  | 
|  | 336 | mInIdsBuffer = new long[1]; | 
| Yang Ni | 6484b6b | 2016-03-24 09:40:32 -0700 | [diff] [blame] | 337 |  | 
|  | 338 | /* The constructors for the derived classes (including ScriptIntrinsic | 
|  | 339 | * derived classes and ScriptC derived classes generated by Slang | 
|  | 340 | * reflection) seem to be simple enough, so we just put the guard.open() | 
|  | 341 | * call here, rather than in the end of the constructor for the derived | 
|  | 342 | * class. This, of course, assumes the derived constructor would not | 
|  | 343 | * throw any exception after calling this constructor. | 
|  | 344 | * | 
|  | 345 | * If new derived classes are added with more complicated constructors | 
|  | 346 | * that throw exceptions, this call has to be (duplicated and) moved | 
|  | 347 | * to the end of each derived class constructor. | 
|  | 348 | */ | 
|  | 349 | guard.open("destroy"); | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 350 | } | 
|  | 351 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 352 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 353 | * Only intended for use by generated reflected code. | 
|  | 354 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 355 | */ | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 356 | public void bindAllocation(Allocation va, int slot) { | 
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 357 | mRS.validate(); | 
| Jason Sams | 678cc7f | 2014-03-05 16:09:02 -0800 | [diff] [blame] | 358 | mRS.validateObject(va); | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 359 | if (va != null) { | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 360 |  | 
|  | 361 | android.content.Context context = mRS.getApplicationContext(); | 
|  | 362 |  | 
|  | 363 | if (context.getApplicationInfo().targetSdkVersion >= 20) { | 
| Jason Sams | cf9c894 | 2014-01-14 16:18:14 -0800 | [diff] [blame] | 364 | final Type t = va.mType; | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 365 | if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) || | 
|  | 366 | (t.getZ() != 0)) { | 
|  | 367 |  | 
| Jason Sams | cf9c894 | 2014-01-14 16:18:14 -0800 | [diff] [blame] | 368 | throw new RSIllegalArgumentException( | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 369 | "API 20+ only allows simple 1D allocations to be " + | 
|  | 370 | "used with bind."); | 
| Jason Sams | cf9c894 | 2014-01-14 16:18:14 -0800 | [diff] [blame] | 371 | } | 
|  | 372 | } | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 373 | mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot); | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 374 | } else { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 375 | mRS.nScriptBindAllocation(getID(mRS), 0, slot); | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 376 | } | 
|  | 377 | } | 
|  | 378 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 379 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 380 | * Only intended for use by generated reflected code. | 
|  | 381 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 382 | */ | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 383 | public void setVar(int index, float v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 384 | mRS.nScriptSetVarF(getID(mRS), index, v); | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 385 | } | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 386 | public float getVarF(int index) { | 
|  | 387 | return mRS.nScriptGetVarF(getID(mRS), index); | 
|  | 388 | } | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 389 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 390 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 391 | * Only intended for use by generated reflected code. | 
|  | 392 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 393 | */ | 
| Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 394 | public void setVar(int index, double v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 395 | mRS.nScriptSetVarD(getID(mRS), index, v); | 
| Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 396 | } | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 397 | public double getVarD(int index) { | 
|  | 398 | return mRS.nScriptGetVarD(getID(mRS), index); | 
|  | 399 | } | 
| Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 400 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 401 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 402 | * Only intended for use by generated reflected code. | 
|  | 403 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 404 | */ | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 405 | public void setVar(int index, int v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 406 | mRS.nScriptSetVarI(getID(mRS), index, v); | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 407 | } | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 408 | public int getVarI(int index) { | 
|  | 409 | return mRS.nScriptGetVarI(getID(mRS), index); | 
|  | 410 | } | 
|  | 411 |  | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 412 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 413 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 414 | * Only intended for use by generated reflected code. | 
|  | 415 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 416 | */ | 
| Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 417 | public void setVar(int index, long v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 418 | mRS.nScriptSetVarJ(getID(mRS), index, v); | 
| Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 419 | } | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 420 | public long getVarJ(int index) { | 
|  | 421 | return mRS.nScriptGetVarJ(getID(mRS), index); | 
|  | 422 | } | 
|  | 423 |  | 
| Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 424 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 425 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 426 | * Only intended for use by generated reflected code. | 
|  | 427 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 428 | */ | 
| Jason Sams | 0b9a22c | 2010-07-02 15:35:19 -0700 | [diff] [blame] | 429 | public void setVar(int index, boolean v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 430 | mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0); | 
| Jason Sams | 0b9a22c | 2010-07-02 15:35:19 -0700 | [diff] [blame] | 431 | } | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 432 | public boolean getVarB(int index) { | 
|  | 433 | return mRS.nScriptGetVarI(getID(mRS), index) > 0 ? true : false; | 
|  | 434 | } | 
| Jason Sams | 0b9a22c | 2010-07-02 15:35:19 -0700 | [diff] [blame] | 435 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 436 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 437 | * Only intended for use by generated reflected code. | 
|  | 438 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 439 | */ | 
| Jason Sams | 6f4cf0b | 2010-11-16 17:37:02 -0800 | [diff] [blame] | 440 | public void setVar(int index, BaseObj o) { | 
| Jason Sams | 678cc7f | 2014-03-05 16:09:02 -0800 | [diff] [blame] | 441 | mRS.validate(); | 
|  | 442 | mRS.validateObject(o); | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 443 | mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS)); | 
| Jason Sams | 6f4cf0b | 2010-11-16 17:37:02 -0800 | [diff] [blame] | 444 | } | 
|  | 445 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 446 | /** | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 447 | * Only intended for use by generated reflected code. | 
|  | 448 | * | 
| Jason Sams | 67e3d20 | 2011-01-09 13:49:01 -0800 | [diff] [blame] | 449 | */ | 
| Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 450 | public void setVar(int index, FieldPacker v) { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 451 | mRS.nScriptSetVarV(getID(mRS), index, v.getData()); | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 452 | } | 
|  | 453 |  | 
| Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 454 | /** | 
| Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 455 | * Only intended for use by generated reflected code. | 
|  | 456 | * | 
| Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 457 | */ | 
|  | 458 | public void setVar(int index, FieldPacker v, Element e, int[] dims) { | 
|  | 459 | mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims); | 
|  | 460 | } | 
|  | 461 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 462 | /** | 
|  | 463 | * Only intended for use by generated reflected code. | 
|  | 464 | * | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 465 | */ | 
| Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 466 | public void getVarV(int index, FieldPacker v) { | 
|  | 467 | mRS.nScriptGetVarV(getID(mRS), index, v.getData()); | 
|  | 468 | } | 
|  | 469 |  | 
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 470 | public void setTimeZone(String timeZone) { | 
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 471 | mRS.validate(); | 
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 472 | try { | 
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 473 | mRS.nScriptSetTimeZone(getID(mRS), timeZone.getBytes("UTF-8")); | 
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 474 | } catch (java.io.UnsupportedEncodingException e) { | 
|  | 475 | throw new RuntimeException(e); | 
|  | 476 | } | 
|  | 477 | } | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 478 |  | 
| Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 479 | /** | 
|  | 480 | * Only intended for use by generated reflected code. | 
|  | 481 | * | 
|  | 482 | */ | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 483 | public static class Builder { | 
| Mathew Inwood | 1532447 | 2018-08-06 11:18:49 +0100 | [diff] [blame] | 484 | @UnsupportedAppUsage | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 485 | RenderScript mRS; | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 486 |  | 
| Mathew Inwood | 1532447 | 2018-08-06 11:18:49 +0100 | [diff] [blame] | 487 | @UnsupportedAppUsage | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 488 | Builder(RenderScript rs) { | 
|  | 489 | mRS = rs; | 
|  | 490 | } | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 491 | } | 
|  | 492 |  | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 493 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 494 | /** | 
|  | 495 | * Only intended for use by generated reflected code. | 
|  | 496 | * | 
|  | 497 | */ | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 498 | public static class FieldBase { | 
|  | 499 | protected Element mElement; | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 500 | protected Allocation mAllocation; | 
|  | 501 |  | 
|  | 502 | protected void init(RenderScript rs, int dimx) { | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 503 | mAllocation = Allocation.createSized(rs, mElement, dimx, | 
|  | 504 | Allocation.USAGE_SCRIPT); | 
| Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 505 | } | 
|  | 506 |  | 
|  | 507 | protected void init(RenderScript rs, int dimx, int usages) { | 
| Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 508 | mAllocation = | 
|  | 509 | Allocation.createSized(rs, mElement, dimx, | 
|  | 510 | Allocation.USAGE_SCRIPT | usages); | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 511 | } | 
|  | 512 |  | 
|  | 513 | protected FieldBase() { | 
|  | 514 | } | 
|  | 515 |  | 
|  | 516 | public Element getElement() { | 
|  | 517 | return mElement; | 
|  | 518 | } | 
|  | 519 |  | 
|  | 520 | public Type getType() { | 
| Jason Sams | 31a7e42 | 2010-10-26 13:09:17 -0700 | [diff] [blame] | 521 | return mAllocation.getType(); | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 522 | } | 
|  | 523 |  | 
|  | 524 | public Allocation getAllocation() { | 
|  | 525 | return mAllocation; | 
|  | 526 | } | 
|  | 527 |  | 
|  | 528 | //@Override | 
|  | 529 | public void updateAllocation() { | 
|  | 530 | } | 
| Jason Sams | 2d71bc7 | 2010-03-26 16:06:43 -0700 | [diff] [blame] | 531 | } | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 532 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 533 |  | 
|  | 534 | /** | 
| Jason Sams | 8610f83 | 2015-03-30 17:01:10 -0700 | [diff] [blame] | 535 | * Class for specifying the specifics about how a kernel will be | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 536 | * launched. | 
| Jason Sams | 8610f83 | 2015-03-30 17:01:10 -0700 | [diff] [blame] | 537 | * | 
|  | 538 | * This class can specify a potential range of cells on which to | 
|  | 539 | * run a kernel.  If no set is called for a dimension then this | 
|  | 540 | * class will have no impact on that dimension when the kernel | 
|  | 541 | * is executed. | 
|  | 542 | * | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 543 | * The forEach kernel launch will operate over the intersection of | 
|  | 544 | * the dimensions. | 
| Jason Sams | 8610f83 | 2015-03-30 17:01:10 -0700 | [diff] [blame] | 545 | * | 
|  | 546 | * Example: | 
|  | 547 | * LaunchOptions with setX(5, 15) | 
|  | 548 | * Allocation with dimension X=10, Y=10 | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 549 | * The resulting forEach run would execute over: | 
|  | 550 | * x = 5 to 9 (inclusive) and | 
|  | 551 | * y = 0 to 9 (inclusive). | 
| Jason Sams | 8610f83 | 2015-03-30 17:01:10 -0700 | [diff] [blame] | 552 | * | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 553 | * | 
|  | 554 | */ | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 555 | public static final class LaunchOptions { | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 556 | private int xstart = 0; | 
|  | 557 | private int ystart = 0; | 
|  | 558 | private int xend = 0; | 
|  | 559 | private int yend = 0; | 
|  | 560 | private int zstart = 0; | 
|  | 561 | private int zend = 0; | 
|  | 562 | private int strategy; | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 563 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 564 | /** | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 565 | * Set the X range. xstartArg is the lowest coordinate of the range, | 
|  | 566 | * and xendArg-1 is the highest coordinate of the range. | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 567 | * | 
|  | 568 | * @param xstartArg Must be >= 0 | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 569 | * @param xendArg Must be > xstartArg | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 570 | * | 
|  | 571 | * @return LaunchOptions | 
|  | 572 | */ | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 573 | public LaunchOptions setX(int xstartArg, int xendArg) { | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 574 | if (xstartArg < 0 || xendArg <= xstartArg) { | 
|  | 575 | throw new RSIllegalArgumentException("Invalid dimensions"); | 
|  | 576 | } | 
|  | 577 | xstart = xstartArg; | 
|  | 578 | xend = xendArg; | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 579 | return this; | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 580 | } | 
|  | 581 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 582 | /** | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 583 | * Set the Y range. ystartArg is the lowest coordinate of the range, | 
|  | 584 | * and yendArg-1 is the highest coordinate of the range. | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 585 | * | 
|  | 586 | * @param ystartArg Must be >= 0 | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 587 | * @param yendArg Must be > ystartArg | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 588 | * | 
|  | 589 | * @return LaunchOptions | 
|  | 590 | */ | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 591 | public LaunchOptions setY(int ystartArg, int yendArg) { | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 592 | if (ystartArg < 0 || yendArg <= ystartArg) { | 
|  | 593 | throw new RSIllegalArgumentException("Invalid dimensions"); | 
|  | 594 | } | 
|  | 595 | ystart = ystartArg; | 
|  | 596 | yend = yendArg; | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 597 | return this; | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 598 | } | 
|  | 599 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 600 | /** | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 601 | * Set the Z range. zstartArg is the lowest coordinate of the range, | 
|  | 602 | * and zendArg-1 is the highest coordinate of the range. | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 603 | * | 
|  | 604 | * @param zstartArg Must be >= 0 | 
| Miao Wang | 53fdcfb | 2016-03-29 15:14:21 -0700 | [diff] [blame] | 605 | * @param zendArg Must be > zstartArg | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 606 | * | 
|  | 607 | * @return LaunchOptions | 
|  | 608 | */ | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 609 | public LaunchOptions setZ(int zstartArg, int zendArg) { | 
|  | 610 | if (zstartArg < 0 || zendArg <= zstartArg) { | 
|  | 611 | throw new RSIllegalArgumentException("Invalid dimensions"); | 
|  | 612 | } | 
|  | 613 | zstart = zstartArg; | 
|  | 614 | zend = zendArg; | 
|  | 615 | return this; | 
|  | 616 | } | 
|  | 617 |  | 
|  | 618 |  | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 619 | /** | 
|  | 620 | * Returns the current X start | 
|  | 621 | * | 
|  | 622 | * @return int current value | 
|  | 623 | */ | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 624 | public int getXStart() { | 
|  | 625 | return xstart; | 
|  | 626 | } | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 627 | /** | 
|  | 628 | * Returns the current X end | 
|  | 629 | * | 
|  | 630 | * @return int current value | 
|  | 631 | */ | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 632 | public int getXEnd() { | 
|  | 633 | return xend; | 
|  | 634 | } | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 635 | /** | 
|  | 636 | * Returns the current Y start | 
|  | 637 | * | 
|  | 638 | * @return int current value | 
|  | 639 | */ | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 640 | public int getYStart() { | 
|  | 641 | return ystart; | 
|  | 642 | } | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 643 | /** | 
|  | 644 | * Returns the current Y end | 
|  | 645 | * | 
|  | 646 | * @return int current value | 
|  | 647 | */ | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 648 | public int getYEnd() { | 
|  | 649 | return yend; | 
|  | 650 | } | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 651 | /** | 
|  | 652 | * Returns the current Z start | 
|  | 653 | * | 
|  | 654 | * @return int current value | 
|  | 655 | */ | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 656 | public int getZStart() { | 
|  | 657 | return zstart; | 
|  | 658 | } | 
| Jason Sams | f64cca9 | 2013-04-19 12:56:37 -0700 | [diff] [blame] | 659 | /** | 
|  | 660 | * Returns the current Z end | 
|  | 661 | * | 
|  | 662 | * @return int current value | 
|  | 663 | */ | 
| Tim Murray | eb8c29c | 2013-02-07 12:16:41 -0800 | [diff] [blame] | 664 | public int getZEnd() { | 
|  | 665 | return zend; | 
|  | 666 | } | 
| Tim Murray | fbfaa85 | 2012-12-14 16:01:58 -0800 | [diff] [blame] | 667 |  | 
|  | 668 | } | 
| Jason Sams | 69f0d31 | 2009-08-03 18:11:17 -0700 | [diff] [blame] | 669 | } |