1/*
2 * Copyright (C) 2011-2014 The Android Open Source Project
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/*
18 * This file is auto-generated. DO NOT MODIFY!
19 * The source Renderscript file: struct_field.rs
20 */
21
22package struct_field;
23
24import android.renderscript.*;
25import struct_field.struct_fieldBitCode;
26
27/**
28 * @hide
29 */
30public class ScriptField_Outer extends android.renderscript.Script.FieldBase {
31    static public class Item {
32
33        ScriptField_InnerOne.Item innerOneA;
34        long l;
35        ScriptField_InnerOne.Item innerOneB;
36        ScriptField_InnerTwo.Item[] innerTwo3;
37        ScriptField_InnerTwo.Item[] innerTwo2;
38        ScriptField_InnerOne.Item[] innerOne4;
39        ScriptField_InnerOne.Item innerOneC;
40
41        Item() {
42            innerOneA = new ScriptField_InnerOne.Item();
43            innerOneB = new ScriptField_InnerOne.Item();
44            innerTwo3 = new ScriptField_InnerTwo.Item[3];
45            for (int $ct = 0; $ct < 3; $ct++) {
46                innerTwo3[$ct] = new ScriptField_InnerTwo.Item();
47            }
48
49            innerTwo2 = new ScriptField_InnerTwo.Item[2];
50            for (int $ct = 0; $ct < 2; $ct++) {
51                innerTwo2[$ct] = new ScriptField_InnerTwo.Item();
52            }
53
54            innerOne4 = new ScriptField_InnerOne.Item[4];
55            for (int $ct = 0; $ct < 4; $ct++) {
56                innerOne4[$ct] = new ScriptField_InnerOne.Item();
57            }
58
59            innerOneC = new ScriptField_InnerOne.Item();
60        }
61
62    }
63
64    private Item mItemArray[];
65    private FieldPacker mIOBuffer;
66    private static java.lang.ref.WeakReference<Element> mElementCache = new java.lang.ref.WeakReference<Element>(null);
67    public static Element createElement(RenderScript rs) {
68        Element.Builder eb = new Element.Builder(rs);
69        eb.add(ScriptField_InnerOne.createElement(rs), "innerOneA");
70        eb.add(Element.U32(rs), "#rs_padding_1");
71        eb.add(Element.I64(rs), "l");
72        eb.add(ScriptField_InnerOne.createElement(rs), "innerOneB");
73        eb.add(ScriptField_InnerTwo.createElement(rs), "innerTwo3", 3);
74        eb.add(ScriptField_InnerTwo.createElement(rs), "innerTwo2", 2);
75        eb.add(ScriptField_InnerOne.createElement(rs), "innerOne4", 4);
76        eb.add(ScriptField_InnerOne.createElement(rs), "innerOneC");
77        return eb.create();
78    }
79
80    private  ScriptField_Outer(RenderScript rs) {
81        mItemArray = null;
82        mIOBuffer = null;
83        mElement = createElement(rs);
84    }
85
86    public  ScriptField_Outer(RenderScript rs, int count) {
87        mItemArray = null;
88        mIOBuffer = null;
89        mElement = createElement(rs);
90        init(rs, count);
91    }
92
93    public  ScriptField_Outer(RenderScript rs, int count, int usages) {
94        mItemArray = null;
95        mIOBuffer = null;
96        mElement = createElement(rs);
97        init(rs, count, usages);
98    }
99
100    public static ScriptField_Outer create1D(RenderScript rs, int dimX, int usages) {
101        ScriptField_Outer obj = new ScriptField_Outer(rs);
102        obj.mAllocation = Allocation.createSized(rs, obj.mElement, dimX, usages);
103        return obj;
104    }
105
106    public static ScriptField_Outer create1D(RenderScript rs, int dimX) {
107        return create1D(rs, dimX, Allocation.USAGE_SCRIPT);
108    }
109
110    public static ScriptField_Outer create2D(RenderScript rs, int dimX, int dimY) {
111        return create2D(rs, dimX, dimY, Allocation.USAGE_SCRIPT);
112    }
113
114    public static ScriptField_Outer create2D(RenderScript rs, int dimX, int dimY, int usages) {
115        ScriptField_Outer obj = new ScriptField_Outer(rs);
116        Type.Builder b = new Type.Builder(rs, obj.mElement);
117        b.setX(dimX);
118        b.setY(dimY);
119        Type t = b.create();
120        obj.mAllocation = Allocation.createTyped(rs, t, usages);
121        return obj;
122    }
123
124    public static Type.Builder createTypeBuilder(RenderScript rs) {
125        Element e = createElement(rs);
126        return new Type.Builder(rs, e);
127    }
128
129    public static ScriptField_Outer createCustom(RenderScript rs, Type.Builder tb, int usages) {
130        ScriptField_Outer obj = new ScriptField_Outer(rs);
131        Type t = tb.create();
132        if (t.getElement() != obj.mElement) {
133            throw new RSIllegalArgumentException("Type.Builder did not match expected element type.");
134        }
135        obj.mAllocation = Allocation.createTyped(rs, t, usages);
136        return obj;
137    }
138
139    private void copyToArrayLocal(Item i, FieldPacker fp) {
140        fp.addI32(i.innerOneA.x);
141        fp.addI32(i.innerOneA.y);
142        fp.addF32(i.innerOneA.f);
143        fp.skip(4);
144        fp.addI64(i.l);
145        fp.addI32(i.innerOneB.x);
146        fp.addI32(i.innerOneB.y);
147        fp.addF32(i.innerOneB.f);
148        for (int ct2 = 0; ct2 < 3; ct2++) {
149            fp.addI8(i.innerTwo3[ct2].z);
150            fp.skip(3);
151            fp.addI32(i.innerTwo3[ct2].innerOne.x);
152            fp.addI32(i.innerTwo3[ct2].innerOne.y);
153            fp.addF32(i.innerTwo3[ct2].innerOne.f);
154        }
155
156        for (int ct2 = 0; ct2 < 2; ct2++) {
157            fp.addI8(i.innerTwo2[ct2].z);
158            fp.skip(3);
159            fp.addI32(i.innerTwo2[ct2].innerOne.x);
160            fp.addI32(i.innerTwo2[ct2].innerOne.y);
161            fp.addF32(i.innerTwo2[ct2].innerOne.f);
162        }
163
164        for (int ct2 = 0; ct2 < 4; ct2++) {
165            fp.addI32(i.innerOne4[ct2].x);
166            fp.addI32(i.innerOne4[ct2].y);
167            fp.addF32(i.innerOne4[ct2].f);
168        }
169
170        fp.addI32(i.innerOneC.x);
171        fp.addI32(i.innerOneC.y);
172        fp.addF32(i.innerOneC.f);
173    }
174
175    private void copyToArray(Item i, int index) {
176        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
177        mIOBuffer.reset(index * mElement.getBytesSize());
178        copyToArrayLocal(i, mIOBuffer);
179    }
180
181    public synchronized void set(Item i, int index, boolean copyNow) {
182        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
183        mItemArray[index] = i;
184        if (copyNow)  {
185            copyToArray(i, index);
186            FieldPacker fp = new FieldPacker(mElement.getBytesSize());
187            copyToArrayLocal(i, fp);
188            mAllocation.setFromFieldPacker(index, fp);
189        }
190
191    }
192
193    public synchronized Item get(int index) {
194        if (mItemArray == null) return null;
195        return mItemArray[index];
196    }
197
198    public synchronized void set_innerOneA(int index, ScriptField_InnerOne.Item v, boolean copyNow) {
199        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
200        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
201        if (mItemArray[index] == null) mItemArray[index] = new Item();
202        mItemArray[index].innerOneA = v;
203        if (copyNow)  {
204            mIOBuffer.reset(index * mElement.getBytesSize());
205            mIOBuffer.addI32(v.x);
206            mIOBuffer.addI32(v.y);
207            mIOBuffer.addF32(v.f);
208            FieldPacker fp = new FieldPacker(12);
209            fp.addI32(v.x);
210            fp.addI32(v.y);
211            fp.addF32(v.f);
212            mAllocation.setFromFieldPacker(index, 0, fp);
213        }
214
215    }
216
217    public synchronized void set_l(int index, long v, boolean copyNow) {
218        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
219        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
220        if (mItemArray[index] == null) mItemArray[index] = new Item();
221        mItemArray[index].l = v;
222        if (copyNow)  {
223            mIOBuffer.reset(index * mElement.getBytesSize() + 16);
224            mIOBuffer.addI64(v);
225            FieldPacker fp = new FieldPacker(8);
226            fp.addI64(v);
227            mAllocation.setFromFieldPacker(index, 2, fp);
228        }
229
230    }
231
232    public synchronized void set_innerOneB(int index, ScriptField_InnerOne.Item v, boolean copyNow) {
233        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
234        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
235        if (mItemArray[index] == null) mItemArray[index] = new Item();
236        mItemArray[index].innerOneB = v;
237        if (copyNow)  {
238            mIOBuffer.reset(index * mElement.getBytesSize() + 24);
239            mIOBuffer.addI32(v.x);
240            mIOBuffer.addI32(v.y);
241            mIOBuffer.addF32(v.f);
242            FieldPacker fp = new FieldPacker(12);
243            fp.addI32(v.x);
244            fp.addI32(v.y);
245            fp.addF32(v.f);
246            mAllocation.setFromFieldPacker(index, 3, fp);
247        }
248
249    }
250
251    public synchronized void set_innerTwo3(int index, ScriptField_InnerTwo.Item[] v, boolean copyNow) {
252        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
253        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
254        if (mItemArray[index] == null) mItemArray[index] = new Item();
255        mItemArray[index].innerTwo3 = v;
256        if (copyNow)  {
257            mIOBuffer.reset(index * mElement.getBytesSize() + 36);
258            for (int ct1 = 0; ct1 < 3; ct1++) {
259                mIOBuffer.addI8(v[ct1].z);
260                mIOBuffer.skip(3);
261                mIOBuffer.addI32(v[ct1].innerOne.x);
262                mIOBuffer.addI32(v[ct1].innerOne.y);
263                mIOBuffer.addF32(v[ct1].innerOne.f);
264            }
265
266            FieldPacker fp = new FieldPacker(48);
267            for (int ct1 = 0; ct1 < 3; ct1++) {
268                fp.addI8(v[ct1].z);
269                fp.skip(3);
270                fp.addI32(v[ct1].innerOne.x);
271                fp.addI32(v[ct1].innerOne.y);
272                fp.addF32(v[ct1].innerOne.f);
273            }
274
275            mAllocation.setFromFieldPacker(index, 4, fp);
276        }
277
278    }
279
280    public synchronized void set_innerTwo2(int index, ScriptField_InnerTwo.Item[] v, boolean copyNow) {
281        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
282        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
283        if (mItemArray[index] == null) mItemArray[index] = new Item();
284        mItemArray[index].innerTwo2 = v;
285        if (copyNow)  {
286            mIOBuffer.reset(index * mElement.getBytesSize() + 84);
287            for (int ct1 = 0; ct1 < 2; ct1++) {
288                mIOBuffer.addI8(v[ct1].z);
289                mIOBuffer.skip(3);
290                mIOBuffer.addI32(v[ct1].innerOne.x);
291                mIOBuffer.addI32(v[ct1].innerOne.y);
292                mIOBuffer.addF32(v[ct1].innerOne.f);
293            }
294
295            FieldPacker fp = new FieldPacker(32);
296            for (int ct1 = 0; ct1 < 2; ct1++) {
297                fp.addI8(v[ct1].z);
298                fp.skip(3);
299                fp.addI32(v[ct1].innerOne.x);
300                fp.addI32(v[ct1].innerOne.y);
301                fp.addF32(v[ct1].innerOne.f);
302            }
303
304            mAllocation.setFromFieldPacker(index, 5, fp);
305        }
306
307    }
308
309    public synchronized void set_innerOne4(int index, ScriptField_InnerOne.Item[] v, boolean copyNow) {
310        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
311        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
312        if (mItemArray[index] == null) mItemArray[index] = new Item();
313        mItemArray[index].innerOne4 = v;
314        if (copyNow)  {
315            mIOBuffer.reset(index * mElement.getBytesSize() + 116);
316            for (int ct1 = 0; ct1 < 4; ct1++) {
317                mIOBuffer.addI32(v[ct1].x);
318                mIOBuffer.addI32(v[ct1].y);
319                mIOBuffer.addF32(v[ct1].f);
320            }
321
322            FieldPacker fp = new FieldPacker(48);
323            for (int ct1 = 0; ct1 < 4; ct1++) {
324                fp.addI32(v[ct1].x);
325                fp.addI32(v[ct1].y);
326                fp.addF32(v[ct1].f);
327            }
328
329            mAllocation.setFromFieldPacker(index, 6, fp);
330        }
331
332    }
333
334    public synchronized void set_innerOneC(int index, ScriptField_InnerOne.Item v, boolean copyNow) {
335        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
336        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
337        if (mItemArray[index] == null) mItemArray[index] = new Item();
338        mItemArray[index].innerOneC = v;
339        if (copyNow)  {
340            mIOBuffer.reset(index * mElement.getBytesSize() + 164);
341            mIOBuffer.addI32(v.x);
342            mIOBuffer.addI32(v.y);
343            mIOBuffer.addF32(v.f);
344            FieldPacker fp = new FieldPacker(12);
345            fp.addI32(v.x);
346            fp.addI32(v.y);
347            fp.addF32(v.f);
348            mAllocation.setFromFieldPacker(index, 7, fp);
349        }
350
351    }
352
353    public synchronized ScriptField_InnerOne.Item get_innerOneA(int index) {
354        if (mItemArray == null) return null;
355        return mItemArray[index].innerOneA;
356    }
357
358    public synchronized long get_l(int index) {
359        if (mItemArray == null) return 0;
360        return mItemArray[index].l;
361    }
362
363    public synchronized ScriptField_InnerOne.Item get_innerOneB(int index) {
364        if (mItemArray == null) return null;
365        return mItemArray[index].innerOneB;
366    }
367
368    public synchronized ScriptField_InnerTwo.Item[] get_innerTwo3(int index) {
369        if (mItemArray == null) return null;
370        return mItemArray[index].innerTwo3;
371    }
372
373    public synchronized ScriptField_InnerTwo.Item[] get_innerTwo2(int index) {
374        if (mItemArray == null) return null;
375        return mItemArray[index].innerTwo2;
376    }
377
378    public synchronized ScriptField_InnerOne.Item[] get_innerOne4(int index) {
379        if (mItemArray == null) return null;
380        return mItemArray[index].innerOne4;
381    }
382
383    public synchronized ScriptField_InnerOne.Item get_innerOneC(int index) {
384        if (mItemArray == null) return null;
385        return mItemArray[index].innerOneC;
386    }
387
388    public synchronized void copyAll() {
389        for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
390        mAllocation.setFromFieldPacker(0, mIOBuffer);
391    }
392
393    public synchronized void resize(int newSize) {
394        if (mItemArray != null)  {
395            int oldSize = mItemArray.length;
396            int copySize = Math.min(oldSize, newSize);
397            if (newSize == oldSize) return;
398            Item ni[] = new Item[newSize];
399            System.arraycopy(mItemArray, 0, ni, 0, copySize);
400            mItemArray = ni;
401        }
402
403        mAllocation.resize(newSize);
404        if (mIOBuffer != null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
405    }
406
407}
408
409