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