• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: reflection3264_divergent.rs
20 */
21
22package foo;
23
24import android.os.Build;
25import android.os.Process;
26import java.lang.reflect.Field;
27import android.renderscript.*;
28import foo.reflection3264_divergentBitCode;
29
30/**
31 * @hide
32 */
33public class ScriptField_DivergentNest extends android.renderscript.Script.FieldBase {
34    static public class Item {
35
36        int x;
37        ScriptField_Divergent.Item d;
38        int y;
39
40        Item() {
41            d = new ScriptField_Divergent.Item();
42        }
43
44    }
45
46    private Item mItemArray[];
47    private FieldPacker mIOBuffer;
48    private static java.lang.ref.WeakReference<Element> mElementCache = new java.lang.ref.WeakReference<Element>(null);
49    public static Element createElement(RenderScript rs) {
50        Element.Builder eb = new Element.Builder(rs);
51        eb.add(Element.I32(rs), "x");
52        if (sIs64Bit) {
53            eb.add(Element.U32(rs), "#rs_padding_1");
54        }
55
56        eb.add(ScriptField_Divergent.createElement(rs), "d");
57        eb.add(Element.I32(rs), "y");
58        if (sIs64Bit) {
59            eb.add(Element.U32(rs), "#rs_padding_2");
60        }
61
62        return eb.create();
63    }
64
65    private  ScriptField_DivergentNest(RenderScript rs) {
66        mItemArray = null;
67        mIOBuffer = null;
68        mElement = createElement(rs);
69    }
70
71    public  ScriptField_DivergentNest(RenderScript rs, int count) {
72        mItemArray = null;
73        mIOBuffer = null;
74        mElement = createElement(rs);
75        init(rs, count);
76    }
77
78    public  ScriptField_DivergentNest(RenderScript rs, int count, int usages) {
79        mItemArray = null;
80        mIOBuffer = null;
81        mElement = createElement(rs);
82        init(rs, count, usages);
83    }
84
85    public static ScriptField_DivergentNest create1D(RenderScript rs, int dimX, int usages) {
86        ScriptField_DivergentNest obj = new ScriptField_DivergentNest(rs);
87        obj.mAllocation = Allocation.createSized(rs, obj.mElement, dimX, usages);
88        return obj;
89    }
90
91    public static ScriptField_DivergentNest create1D(RenderScript rs, int dimX) {
92        return create1D(rs, dimX, Allocation.USAGE_SCRIPT);
93    }
94
95    public static ScriptField_DivergentNest create2D(RenderScript rs, int dimX, int dimY) {
96        return create2D(rs, dimX, dimY, Allocation.USAGE_SCRIPT);
97    }
98
99    public static ScriptField_DivergentNest create2D(RenderScript rs, int dimX, int dimY, int usages) {
100        ScriptField_DivergentNest obj = new ScriptField_DivergentNest(rs);
101        Type.Builder b = new Type.Builder(rs, obj.mElement);
102        b.setX(dimX);
103        b.setY(dimY);
104        Type t = b.create();
105        obj.mAllocation = Allocation.createTyped(rs, t, usages);
106        return obj;
107    }
108
109    public static Type.Builder createTypeBuilder(RenderScript rs) {
110        Element e = createElement(rs);
111        return new Type.Builder(rs, e);
112    }
113
114    public static ScriptField_DivergentNest createCustom(RenderScript rs, Type.Builder tb, int usages) {
115        ScriptField_DivergentNest obj = new ScriptField_DivergentNest(rs);
116        Type t = tb.create();
117        if (t.getElement() != obj.mElement) {
118            throw new RSIllegalArgumentException("Type.Builder did not match expected element type.");
119        }
120        obj.mAllocation = Allocation.createTyped(rs, t, usages);
121        return obj;
122    }
123
124    private void copyToArrayLocal(Item i, FieldPacker fp) {
125        fp.addI32(i.x);
126        fp.skip(sIs64Bit ? 4 : 0);
127        fp.addI32(i.d.i);
128        fp.skip(sIs64Bit ? 4 : 0);
129        fp.addObj(i.d.a);
130        fp.addI32(i.d.j);
131        fp.skip(sIs64Bit ? 4 : 0);
132        fp.addI32(i.y);
133        fp.skip(sIs64Bit ? 4 : 0);
134    }
135
136    private void copyToArray(Item i, int index) {
137        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
138        mIOBuffer.reset(index * mElement.getBytesSize());
139        copyToArrayLocal(i, mIOBuffer);
140    }
141
142    public synchronized void set(Item i, int index, boolean copyNow) {
143        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
144        mItemArray[index] = i;
145        if (copyNow)  {
146            copyToArray(i, index);
147            FieldPacker fp = new FieldPacker(mElement.getBytesSize());
148            copyToArrayLocal(i, fp);
149            mAllocation.setFromFieldPacker(index, fp);
150        }
151
152    }
153
154    public synchronized Item get(int index) {
155        if (mItemArray == null) return null;
156        return mItemArray[index];
157    }
158
159    public synchronized void set_x(int index, int v, boolean copyNow) {
160        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
161        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
162        if (mItemArray[index] == null) mItemArray[index] = new Item();
163        mItemArray[index].x = v;
164        if (copyNow)  {
165            mIOBuffer.reset(index * mElement.getBytesSize());
166            mIOBuffer.addI32(v);
167            FieldPacker fp = new FieldPacker(4);
168            fp.addI32(v);
169            mAllocation.setFromFieldPacker(index, 0, fp);
170        }
171
172    }
173
174    public synchronized void set_d(int index, ScriptField_Divergent.Item v, boolean copyNow) {
175        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
176        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
177        if (mItemArray[index] == null) mItemArray[index] = new Item();
178        mItemArray[index].d = v;
179        if (copyNow)  {
180            mIOBuffer.reset(index * mElement.getBytesSize() + (sIs64Bit ? 8 : 4));
181            mIOBuffer.addI32(v.i);
182            mIOBuffer.skip(sIs64Bit ? 4 : 0);
183            mIOBuffer.addObj(v.a);
184            mIOBuffer.addI32(v.j);
185            mIOBuffer.skip(sIs64Bit ? 4 : 0);
186            FieldPacker fp = new FieldPacker(sIs64Bit ? 48 : 12);
187            fp.addI32(v.i);
188            fp.skip(sIs64Bit ? 4 : 0);
189            fp.addObj(v.a);
190            fp.addI32(v.j);
191            fp.skip(sIs64Bit ? 4 : 0);
192            mAllocation.setFromFieldPacker(index, sIs64Bit ? 2 : 1, fp);
193        }
194
195    }
196
197    public synchronized void set_y(int index, int v, boolean copyNow) {
198        if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
199        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
200        if (mItemArray[index] == null) mItemArray[index] = new Item();
201        mItemArray[index].y = v;
202        if (copyNow)  {
203            mIOBuffer.reset(index * mElement.getBytesSize() + (sIs64Bit ? 56 : 16));
204            mIOBuffer.addI32(v);
205            FieldPacker fp = new FieldPacker(4);
206            fp.addI32(v);
207            mAllocation.setFromFieldPacker(index, sIs64Bit ? 3 : 2, fp);
208        }
209
210    }
211
212    public synchronized int get_x(int index) {
213        if (mItemArray == null) return 0;
214        return mItemArray[index].x;
215    }
216
217    public synchronized ScriptField_Divergent.Item get_d(int index) {
218        if (mItemArray == null) return null;
219        return mItemArray[index].d;
220    }
221
222    public synchronized int get_y(int index) {
223        if (mItemArray == null) return 0;
224        return mItemArray[index].y;
225    }
226
227    public synchronized void copyAll() {
228        for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
229        mAllocation.setFromFieldPacker(0, mIOBuffer);
230    }
231
232    public synchronized void resize(int newSize) {
233        if (mItemArray != null)  {
234            int oldSize = mItemArray.length;
235            int copySize = Math.min(oldSize, newSize);
236            if (newSize == oldSize) return;
237            Item ni[] = new Item[newSize];
238            System.arraycopy(mItemArray, 0, ni, 0, copySize);
239            mItemArray = ni;
240        }
241
242        mAllocation.resize(newSize);
243        if (mIOBuffer != null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */);
244    }
245
246    private static boolean sIs64Bit;
247
248    static {
249        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
250            sIs64Bit = Process.is64Bit();
251        }
252
253        else {
254            try {
255                Field f = RenderScript.class.getDeclaredField("sPointerSize");
256                f.setAccessible(true);
257                sIs64Bit = (f.getInt(null) == 8);
258            }
259
260            catch (Throwable e) {
261                sIs64Bit = false;
262            }
263
264        }
265
266    }
267
268}
269
270