blob: eb1687a37a492befef0265e1cb881dea49ef8cbc [file] [log] [blame]
Jason Sams69f0d312009-08-03 18:11:17 -07001/*
Stephen Hinesadeb8092012-04-20 14:26:06 -07002 * Copyright (C) 2008-2012 The Android Open Source Project
Jason Sams69f0d312009-08-03 18:11:17 -07003 *
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
17package android.renderscript;
18
Jason Sams08a81582012-09-18 12:32:10 -070019import android.util.SparseArray;
20
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070021/**
Tim Murrayc11e25c2013-04-09 11:01:01 -070022 * The parent class for all executable scripts. This should not be used by
23 * applications.
Jason Sams69f0d312009-08-03 18:11:17 -070024 **/
25public class Script extends BaseObj {
Jason Sams08a81582012-09-18 12:32:10 -070026
27 /**
28 * KernelID is an identifier for a Script + root function pair. It is used
29 * as an identifier for ScriptGroup creation.
30 *
31 * This class should not be directly created. Instead use the method in the
32 * reflected or intrinsic code "getKernelID_funcname()".
33 *
34 */
35 public static final class KernelID extends BaseObj {
36 Script mScript;
37 int mSlot;
38 int mSig;
Tim Murray7a629fa2013-11-19 12:45:54 -080039 KernelID(long id, RenderScript rs, Script s, int slot, int sig) {
Jason Sams08a81582012-09-18 12:32:10 -070040 super(id, rs);
41 mScript = s;
42 mSlot = slot;
43 mSig = sig;
44 }
45 }
46
47 private final SparseArray<KernelID> mKIDs = new SparseArray<KernelID>();
48 /**
49 * Only to be used by generated reflected classes.
Jason Sams08a81582012-09-18 12:32:10 -070050 */
Chris Wailesbe7b1de2014-07-15 10:56:14 -070051 protected KernelID createKernelID(int slot, int sig, Element ein,
52 Element eout) {
Jason Sams08a81582012-09-18 12:32:10 -070053 KernelID k = mKIDs.get(slot);
54 if (k != null) {
55 return k;
56 }
57
Tim Murray7a629fa2013-11-19 12:45:54 -080058 long id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig);
Jason Sams08a81582012-09-18 12:32:10 -070059 if (id == 0) {
60 throw new RSDriverException("Failed to create KernelID");
61 }
62
63 k = new KernelID(id, mRS, this, slot, sig);
64 mKIDs.put(slot, k);
65 return k;
66 }
67
68 /**
69 * FieldID is an identifier for a Script + exported field pair. It is used
70 * as an identifier for ScriptGroup creation.
71 *
72 * This class should not be directly created. Instead use the method in the
73 * reflected or intrinsic code "getFieldID_funcname()".
74 *
75 */
76 public static final class FieldID extends BaseObj {
77 Script mScript;
78 int mSlot;
Tim Murray7a629fa2013-11-19 12:45:54 -080079 FieldID(long id, RenderScript rs, Script s, int slot) {
Jason Sams08a81582012-09-18 12:32:10 -070080 super(id, rs);
81 mScript = s;
82 mSlot = slot;
83 }
84 }
85
86 private final SparseArray<FieldID> mFIDs = new SparseArray();
87 /**
88 * Only to be used by generated reflected classes.
Jason Sams08a81582012-09-18 12:32:10 -070089 */
90 protected FieldID createFieldID(int slot, Element e) {
91 FieldID f = mFIDs.get(slot);
92 if (f != null) {
93 return f;
94 }
95
Tim Murray7a629fa2013-11-19 12:45:54 -080096 long id = mRS.nScriptFieldIDCreate(getID(mRS), slot);
Jason Sams08a81582012-09-18 12:32:10 -070097 if (id == 0) {
98 throw new RSDriverException("Failed to create FieldID");
99 }
100
101 f = new FieldID(id, mRS, this, slot);
102 mFIDs.put(slot, f);
103 return f;
104 }
105
106
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700107 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800108 * Only intended for use by generated reflected code.
109 *
Jason Sams67e3d202011-01-09 13:49:01 -0800110 */
Jason Sams2d71bc72010-03-26 16:06:43 -0700111 protected void invoke(int slot) {
Jason Samse07694b2012-04-03 15:36:36 -0700112 mRS.nScriptInvoke(getID(mRS), slot);
Jason Sams2d71bc72010-03-26 16:06:43 -0700113 }
114
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700115 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800116 * Only intended for use by generated reflected code.
117 *
Jason Sams67e3d202011-01-09 13:49:01 -0800118 */
Jason Sams96ed4cf2010-06-15 12:15:57 -0700119 protected void invoke(int slot, FieldPacker v) {
120 if (v != null) {
Jason Samse07694b2012-04-03 15:36:36 -0700121 mRS.nScriptInvokeV(getID(mRS), slot, v.getData());
Jason Sams96ed4cf2010-06-15 12:15:57 -0700122 } else {
Jason Samse07694b2012-04-03 15:36:36 -0700123 mRS.nScriptInvoke(getID(mRS), slot);
Jason Sams96ed4cf2010-06-15 12:15:57 -0700124 }
Jason Sams4d339932010-05-11 14:03:58 -0700125 }
126
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700127 /**
Jason Sams6e494d32011-04-27 16:33:11 -0700128 * Only intended for use by generated reflected code.
129 *
Jason Sams6e494d32011-04-27 16:33:11 -0700130 */
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700131 protected void forEach(int slot, Allocation ain, Allocation aout,
132 FieldPacker v) {
133 forEach(slot, ain, aout, v, null);
Jason Sams6e494d32011-04-27 16:33:11 -0700134 }
135
Jason Samsf64cca92013-04-19 12:56:37 -0700136 /**
137 * Only intended for use by generated reflected code.
138 *
Jason Samsf64cca92013-04-19 12:56:37 -0700139 */
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700140 protected void forEach(int slot, Allocation ain, Allocation aout,
141 FieldPacker v, LaunchOptions sc) {
142 // TODO: Is this necessary if nScriptForEach calls validate as well?
Jason Sams678cc7f2014-03-05 16:09:02 -0800143 mRS.validate();
144 mRS.validateObject(ain);
145 mRS.validateObject(aout);
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700146
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800147 if (ain == null && aout == null) {
148 throw new RSIllegalArgumentException(
149 "At least one of ain or aout is required to be non-null.");
150 }
Tim Murrayba9dd062013-02-12 16:22:34 -0800151
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700152 long[] in_ids = null;
Stephen Hinesc9c7daf2014-08-13 17:32:19 +0000153 if (ain != null) {
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700154 in_ids = mInIdsBuffer;
155 in_ids[0] = ain.getID(mRS);
Stephen Hinesc9c7daf2014-08-13 17:32:19 +0000156 }
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700157
Tim Murray7a629fa2013-11-19 12:45:54 -0800158 long out_id = 0;
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800159 if (aout != null) {
160 out_id = aout.getID(mRS);
161 }
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700162
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800163 byte[] params = null;
164 if (v != null) {
165 params = v.getData();
166 }
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700167
168 int[] limits = null;
169 if (sc != null) {
170 limits = new int[6];
171
172 limits[0] = sc.xstart;
173 limits[1] = sc.xend;
174 limits[2] = sc.ystart;
175 limits[3] = sc.yend;
176 limits[4] = sc.zstart;
177 limits[5] = sc.zend;
178 }
179
180 mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800181 }
Jason Sams4d339932010-05-11 14:03:58 -0700182
Chris Wailes94961062014-06-11 12:01:28 -0700183 /**
184 * Only intended for use by generated reflected code.
185 *
186 * @hide
187 */
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700188 protected void forEach(int slot, Allocation[] ains, Allocation aout,
189 FieldPacker v) {
190 forEach(slot, ains, aout, v, null);
Chris Wailes94961062014-06-11 12:01:28 -0700191 }
192
193 /**
194 * Only intended for use by generated reflected code.
195 *
196 * @hide
197 */
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700198 protected void forEach(int slot, Allocation[] ains, Allocation aout,
199 FieldPacker v, LaunchOptions sc) {
200 // TODO: Is this necessary if nScriptForEach calls validate as well?
Chris Wailes94961062014-06-11 12:01:28 -0700201 mRS.validate();
Chris Wailes94961062014-06-11 12:01:28 -0700202 for (Allocation ain : ains) {
203 mRS.validateObject(ain);
204 }
Stephen Hinesc9c7daf2014-08-13 17:32:19 +0000205 mRS.validateObject(aout);
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700206
Chris Wailes94961062014-06-11 12:01:28 -0700207 if (ains == null && aout == null) {
208 throw new RSIllegalArgumentException(
209 "At least one of ain or aout is required to be non-null.");
210 }
211
Chris Wailes94961062014-06-11 12:01:28 -0700212 long[] in_ids = new long[ains.length];
213 for (int index = 0; index < ains.length; ++index) {
214 in_ids[index] = ains[index].getID(mRS);
215 }
216
217 long out_id = 0;
218 if (aout != null) {
219 out_id = aout.getID(mRS);
220 }
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700221
Chris Wailes94961062014-06-11 12:01:28 -0700222 byte[] params = null;
223 if (v != null) {
224 params = v.getData();
225 }
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700226
227 int[] limits = null;
228 if (sc != null) {
229 limits = new int[6];
230
231 limits[0] = sc.xstart;
232 limits[1] = sc.xend;
233 limits[2] = sc.ystart;
234 limits[3] = sc.yend;
235 limits[4] = sc.zstart;
236 limits[5] = sc.zend;
237 }
238
239 mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
Chris Wailes94961062014-06-11 12:01:28 -0700240 }
241
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700242 long[] mInIdsBuffer;
243
Tim Murray7a629fa2013-11-19 12:45:54 -0800244 Script(long id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -0700245 super(id, rs);
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700246
247 mInIdsBuffer = new long[1];
Jason Sams69f0d312009-08-03 18:11:17 -0700248 }
249
Jason Sams67e3d202011-01-09 13:49:01 -0800250
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700251 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800252 * Only intended for use by generated reflected code.
253 *
Jason Sams67e3d202011-01-09 13:49:01 -0800254 */
Jason Sams69f0d312009-08-03 18:11:17 -0700255 public void bindAllocation(Allocation va, int slot) {
Jason Sams771bebb2009-12-07 12:40:12 -0800256 mRS.validate();
Jason Sams678cc7f2014-03-05 16:09:02 -0800257 mRS.validateObject(va);
Jason Sams4d339932010-05-11 14:03:58 -0700258 if (va != null) {
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700259
260 android.content.Context context = mRS.getApplicationContext();
261
262 if (context.getApplicationInfo().targetSdkVersion >= 20) {
Jason Samscf9c8942014-01-14 16:18:14 -0800263 final Type t = va.mType;
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700264 if (t.hasMipmaps() || t.hasFaces() || (t.getY() != 0) ||
265 (t.getZ() != 0)) {
266
Jason Samscf9c8942014-01-14 16:18:14 -0800267 throw new RSIllegalArgumentException(
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700268 "API 20+ only allows simple 1D allocations to be " +
269 "used with bind.");
Jason Samscf9c8942014-01-14 16:18:14 -0800270 }
271 }
Jason Samse07694b2012-04-03 15:36:36 -0700272 mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
Jason Sams4d339932010-05-11 14:03:58 -0700273 } else {
Jason Samse07694b2012-04-03 15:36:36 -0700274 mRS.nScriptBindAllocation(getID(mRS), 0, slot);
Jason Sams4d339932010-05-11 14:03:58 -0700275 }
276 }
277
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700278 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800279 * Only intended for use by generated reflected code.
280 *
Jason Sams67e3d202011-01-09 13:49:01 -0800281 */
Jason Sams4d339932010-05-11 14:03:58 -0700282 public void setVar(int index, float v) {
Jason Samse07694b2012-04-03 15:36:36 -0700283 mRS.nScriptSetVarF(getID(mRS), index, v);
Jason Sams4d339932010-05-11 14:03:58 -0700284 }
Tim Murray7c4caad2013-04-10 16:21:40 -0700285 public float getVarF(int index) {
286 return mRS.nScriptGetVarF(getID(mRS), index);
287 }
Jason Sams4d339932010-05-11 14:03:58 -0700288
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700289 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800290 * Only intended for use by generated reflected code.
291 *
Jason Sams67e3d202011-01-09 13:49:01 -0800292 */
Stephen Hinesca54ec32010-09-20 17:20:30 -0700293 public void setVar(int index, double v) {
Jason Samse07694b2012-04-03 15:36:36 -0700294 mRS.nScriptSetVarD(getID(mRS), index, v);
Stephen Hinesca54ec32010-09-20 17:20:30 -0700295 }
Tim Murray7c4caad2013-04-10 16:21:40 -0700296 public double getVarD(int index) {
297 return mRS.nScriptGetVarD(getID(mRS), index);
298 }
Stephen Hinesca54ec32010-09-20 17:20:30 -0700299
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700300 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800301 * Only intended for use by generated reflected code.
302 *
Jason Sams67e3d202011-01-09 13:49:01 -0800303 */
Jason Sams4d339932010-05-11 14:03:58 -0700304 public void setVar(int index, int v) {
Jason Samse07694b2012-04-03 15:36:36 -0700305 mRS.nScriptSetVarI(getID(mRS), index, v);
Jason Sams4d339932010-05-11 14:03:58 -0700306 }
Tim Murray7c4caad2013-04-10 16:21:40 -0700307 public int getVarI(int index) {
308 return mRS.nScriptGetVarI(getID(mRS), index);
309 }
310
Jason Sams4d339932010-05-11 14:03:58 -0700311
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700312 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800313 * Only intended for use by generated reflected code.
314 *
Jason Sams67e3d202011-01-09 13:49:01 -0800315 */
Stephen Hines031ec58c2010-10-11 10:54:21 -0700316 public void setVar(int index, long v) {
Jason Samse07694b2012-04-03 15:36:36 -0700317 mRS.nScriptSetVarJ(getID(mRS), index, v);
Stephen Hines031ec58c2010-10-11 10:54:21 -0700318 }
Tim Murray7c4caad2013-04-10 16:21:40 -0700319 public long getVarJ(int index) {
320 return mRS.nScriptGetVarJ(getID(mRS), index);
321 }
322
Stephen Hines031ec58c2010-10-11 10:54:21 -0700323
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700324 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800325 * Only intended for use by generated reflected code.
326 *
Jason Sams67e3d202011-01-09 13:49:01 -0800327 */
Jason Sams0b9a22c2010-07-02 15:35:19 -0700328 public void setVar(int index, boolean v) {
Jason Samse07694b2012-04-03 15:36:36 -0700329 mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0);
Jason Sams0b9a22c2010-07-02 15:35:19 -0700330 }
Tim Murray7c4caad2013-04-10 16:21:40 -0700331 public boolean getVarB(int index) {
332 return mRS.nScriptGetVarI(getID(mRS), index) > 0 ? true : false;
333 }
Jason Sams0b9a22c2010-07-02 15:35:19 -0700334
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700335 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800336 * Only intended for use by generated reflected code.
337 *
Jason Sams67e3d202011-01-09 13:49:01 -0800338 */
Jason Sams6f4cf0b2010-11-16 17:37:02 -0800339 public void setVar(int index, BaseObj o) {
Jason Sams678cc7f2014-03-05 16:09:02 -0800340 mRS.validate();
341 mRS.validateObject(o);
Jason Samse07694b2012-04-03 15:36:36 -0700342 mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
Jason Sams6f4cf0b2010-11-16 17:37:02 -0800343 }
344
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700345 /**
Jason Sams67e3d202011-01-09 13:49:01 -0800346 * Only intended for use by generated reflected code.
347 *
Jason Sams67e3d202011-01-09 13:49:01 -0800348 */
Jason Sams4d339932010-05-11 14:03:58 -0700349 public void setVar(int index, FieldPacker v) {
Jason Samse07694b2012-04-03 15:36:36 -0700350 mRS.nScriptSetVarV(getID(mRS), index, v.getData());
Jason Sams69f0d312009-08-03 18:11:17 -0700351 }
352
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700353 /**
Stephen Hinesadeb8092012-04-20 14:26:06 -0700354 * Only intended for use by generated reflected code.
355 *
Stephen Hinesadeb8092012-04-20 14:26:06 -0700356 */
357 public void setVar(int index, FieldPacker v, Element e, int[] dims) {
358 mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims);
359 }
360
Jason Samsf64cca92013-04-19 12:56:37 -0700361 /**
362 * Only intended for use by generated reflected code.
363 *
Jason Samsf64cca92013-04-19 12:56:37 -0700364 */
Tim Murray7c4caad2013-04-10 16:21:40 -0700365 public void getVarV(int index, FieldPacker v) {
366 mRS.nScriptGetVarV(getID(mRS), index, v.getData());
367 }
368
Jason Sams22534172009-08-04 16:58:20 -0700369 public void setTimeZone(String timeZone) {
Jason Sams771bebb2009-12-07 12:40:12 -0800370 mRS.validate();
Jason Sams22534172009-08-04 16:58:20 -0700371 try {
Jason Samse07694b2012-04-03 15:36:36 -0700372 mRS.nScriptSetTimeZone(getID(mRS), timeZone.getBytes("UTF-8"));
Jason Sams22534172009-08-04 16:58:20 -0700373 } catch (java.io.UnsupportedEncodingException e) {
374 throw new RuntimeException(e);
375 }
376 }
Jason Sams69f0d312009-08-03 18:11:17 -0700377
Tim Murrayc11e25c2013-04-09 11:01:01 -0700378 /**
379 * Only intended for use by generated reflected code.
380 *
381 */
Jason Sams69f0d312009-08-03 18:11:17 -0700382 public static class Builder {
383 RenderScript mRS;
Jason Sams69f0d312009-08-03 18:11:17 -0700384
385 Builder(RenderScript rs) {
386 mRS = rs;
387 }
Jason Sams69f0d312009-08-03 18:11:17 -0700388 }
389
Jason Sams2d71bc72010-03-26 16:06:43 -0700390
Jason Samsf64cca92013-04-19 12:56:37 -0700391 /**
392 * Only intended for use by generated reflected code.
393 *
394 */
Jason Sams2d71bc72010-03-26 16:06:43 -0700395 public static class FieldBase {
396 protected Element mElement;
Jason Sams2d71bc72010-03-26 16:06:43 -0700397 protected Allocation mAllocation;
398
399 protected void init(RenderScript rs, int dimx) {
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700400 mAllocation = Allocation.createSized(rs, mElement, dimx,
401 Allocation.USAGE_SCRIPT);
Jason Sams5476b452010-12-08 16:14:36 -0800402 }
403
404 protected void init(RenderScript rs, int dimx, int usages) {
Chris Wailesbe7b1de2014-07-15 10:56:14 -0700405 mAllocation =
406 Allocation.createSized(rs, mElement, dimx,
407 Allocation.USAGE_SCRIPT | usages);
Jason Sams2d71bc72010-03-26 16:06:43 -0700408 }
409
410 protected FieldBase() {
411 }
412
413 public Element getElement() {
414 return mElement;
415 }
416
417 public Type getType() {
Jason Sams31a7e422010-10-26 13:09:17 -0700418 return mAllocation.getType();
Jason Sams2d71bc72010-03-26 16:06:43 -0700419 }
420
421 public Allocation getAllocation() {
422 return mAllocation;
423 }
424
425 //@Override
426 public void updateAllocation() {
427 }
Jason Sams2d71bc72010-03-26 16:06:43 -0700428 }
Tim Murrayfbfaa852012-12-14 16:01:58 -0800429
Jason Samsf64cca92013-04-19 12:56:37 -0700430
431 /**
432 * Class used to specify clipping for a kernel launch.
433 *
434 */
Tim Murrayfbfaa852012-12-14 16:01:58 -0800435 public static final class LaunchOptions {
Jason Samsf64cca92013-04-19 12:56:37 -0700436 private int xstart = 0;
437 private int ystart = 0;
438 private int xend = 0;
439 private int yend = 0;
440 private int zstart = 0;
441 private int zend = 0;
442 private int strategy;
Tim Murrayfbfaa852012-12-14 16:01:58 -0800443
Jason Samsf64cca92013-04-19 12:56:37 -0700444 /**
445 * Set the X range. If the end value is set to 0 the X dimension is not
446 * clipped.
447 *
448 * @param xstartArg Must be >= 0
449 * @param xendArg Must be >= xstartArg
450 *
451 * @return LaunchOptions
452 */
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800453 public LaunchOptions setX(int xstartArg, int xendArg) {
Tim Murrayfbfaa852012-12-14 16:01:58 -0800454 if (xstartArg < 0 || xendArg <= xstartArg) {
455 throw new RSIllegalArgumentException("Invalid dimensions");
456 }
457 xstart = xstartArg;
458 xend = xendArg;
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800459 return this;
Tim Murrayfbfaa852012-12-14 16:01:58 -0800460 }
461
Jason Samsf64cca92013-04-19 12:56:37 -0700462 /**
463 * Set the Y range. If the end value is set to 0 the Y dimension is not
464 * clipped.
465 *
466 * @param ystartArg Must be >= 0
467 * @param yendArg Must be >= ystartArg
468 *
469 * @return LaunchOptions
470 */
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800471 public LaunchOptions setY(int ystartArg, int yendArg) {
Tim Murrayfbfaa852012-12-14 16:01:58 -0800472 if (ystartArg < 0 || yendArg <= ystartArg) {
473 throw new RSIllegalArgumentException("Invalid dimensions");
474 }
475 ystart = ystartArg;
476 yend = yendArg;
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800477 return this;
Tim Murrayfbfaa852012-12-14 16:01:58 -0800478 }
479
Jason Samsf64cca92013-04-19 12:56:37 -0700480 /**
481 * Set the Z range. If the end value is set to 0 the Z dimension is not
482 * clipped.
483 *
484 * @param zstartArg Must be >= 0
485 * @param zendArg Must be >= zstartArg
486 *
487 * @return LaunchOptions
488 */
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800489 public LaunchOptions setZ(int zstartArg, int zendArg) {
490 if (zstartArg < 0 || zendArg <= zstartArg) {
491 throw new RSIllegalArgumentException("Invalid dimensions");
492 }
493 zstart = zstartArg;
494 zend = zendArg;
495 return this;
496 }
497
498
Jason Samsf64cca92013-04-19 12:56:37 -0700499 /**
500 * Returns the current X start
501 *
502 * @return int current value
503 */
Tim Murrayfbfaa852012-12-14 16:01:58 -0800504 public int getXStart() {
505 return xstart;
506 }
Jason Samsf64cca92013-04-19 12:56:37 -0700507 /**
508 * Returns the current X end
509 *
510 * @return int current value
511 */
Tim Murrayfbfaa852012-12-14 16:01:58 -0800512 public int getXEnd() {
513 return xend;
514 }
Jason Samsf64cca92013-04-19 12:56:37 -0700515 /**
516 * Returns the current Y start
517 *
518 * @return int current value
519 */
Tim Murrayfbfaa852012-12-14 16:01:58 -0800520 public int getYStart() {
521 return ystart;
522 }
Jason Samsf64cca92013-04-19 12:56:37 -0700523 /**
524 * Returns the current Y end
525 *
526 * @return int current value
527 */
Tim Murrayfbfaa852012-12-14 16:01:58 -0800528 public int getYEnd() {
529 return yend;
530 }
Jason Samsf64cca92013-04-19 12:56:37 -0700531 /**
532 * Returns the current Z start
533 *
534 * @return int current value
535 */
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800536 public int getZStart() {
537 return zstart;
538 }
Jason Samsf64cca92013-04-19 12:56:37 -0700539 /**
540 * Returns the current Z end
541 *
542 * @return int current value
543 */
Tim Murrayeb8c29c2013-02-07 12:16:41 -0800544 public int getZEnd() {
545 return zend;
546 }
Tim Murrayfbfaa852012-12-14 16:01:58 -0800547
548 }
Jason Sams69f0d312009-08-03 18:11:17 -0700549}