| /* |
| * Copyright (C) 2011-2014 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| /* |
| * This file is auto-generated. DO NOT MODIFY! |
| * The source Renderscript file: reflection3264_divergent.rs |
| */ |
| |
| package foo; |
| |
| import android.support.v8.renderscript.*; |
| import foo.reflection3264_divergentBitCode; |
| |
| /** |
| * @hide |
| */ |
| public class ScriptField_Divergent extends android.support.v8.renderscript.Script.FieldBase { |
| static public class Item { |
| |
| int i; |
| Allocation a; |
| int j; |
| |
| Item() { |
| } |
| |
| } |
| |
| private Item mItemArray[]; |
| private FieldPacker mIOBuffer; |
| private static java.lang.ref.WeakReference<Element> mElementCache = new java.lang.ref.WeakReference<Element>(null); |
| public static Element createElement(RenderScript rs) { |
| Element.Builder eb = new Element.Builder(rs); |
| eb.add(Element.I32(rs), "i"); |
| if (RenderScript.getPointerSize() == 8) { |
| eb.add(Element.U32(rs), "#rs_padding_1"); |
| } |
| |
| eb.add(Element.ALLOCATION(rs), "a"); |
| eb.add(Element.I32(rs), "j"); |
| if (RenderScript.getPointerSize() == 8) { |
| eb.add(Element.U32(rs), "#rs_padding_2"); |
| } |
| |
| return eb.create(); |
| } |
| |
| private ScriptField_Divergent(RenderScript rs) { |
| mItemArray = null; |
| mIOBuffer = null; |
| mElement = createElement(rs); |
| } |
| |
| public ScriptField_Divergent(RenderScript rs, int count) { |
| mItemArray = null; |
| mIOBuffer = null; |
| mElement = createElement(rs); |
| init(rs, count); |
| } |
| |
| public ScriptField_Divergent(RenderScript rs, int count, int usages) { |
| mItemArray = null; |
| mIOBuffer = null; |
| mElement = createElement(rs); |
| init(rs, count, usages); |
| } |
| |
| public static ScriptField_Divergent create1D(RenderScript rs, int dimX, int usages) { |
| ScriptField_Divergent obj = new ScriptField_Divergent(rs); |
| obj.mAllocation = Allocation.createSized(rs, obj.mElement, dimX, usages); |
| return obj; |
| } |
| |
| public static ScriptField_Divergent create1D(RenderScript rs, int dimX) { |
| return create1D(rs, dimX, Allocation.USAGE_SCRIPT); |
| } |
| |
| public static ScriptField_Divergent create2D(RenderScript rs, int dimX, int dimY) { |
| return create2D(rs, dimX, dimY, Allocation.USAGE_SCRIPT); |
| } |
| |
| public static ScriptField_Divergent create2D(RenderScript rs, int dimX, int dimY, int usages) { |
| ScriptField_Divergent obj = new ScriptField_Divergent(rs); |
| Type.Builder b = new Type.Builder(rs, obj.mElement); |
| b.setX(dimX); |
| b.setY(dimY); |
| Type t = b.create(); |
| obj.mAllocation = Allocation.createTyped(rs, t, usages); |
| return obj; |
| } |
| |
| public static Type.Builder createTypeBuilder(RenderScript rs) { |
| Element e = createElement(rs); |
| return new Type.Builder(rs, e); |
| } |
| |
| public static ScriptField_Divergent createCustom(RenderScript rs, Type.Builder tb, int usages) { |
| ScriptField_Divergent obj = new ScriptField_Divergent(rs); |
| Type t = tb.create(); |
| if (t.getElement() != obj.mElement) { |
| throw new RSIllegalArgumentException("Type.Builder did not match expected element type."); |
| } |
| obj.mAllocation = Allocation.createTyped(rs, t, usages); |
| return obj; |
| } |
| |
| private void copyToArrayLocal(Item i, FieldPacker fp) { |
| fp.addI32(i.i); |
| fp.skip((RenderScript.getPointerSize() == 8) ? 4 : 0); |
| fp.addObj(i.a); |
| fp.addI32(i.j); |
| fp.skip((RenderScript.getPointerSize() == 8) ? 4 : 0); |
| } |
| |
| private void copyToArray(Item i, int index) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); |
| mIOBuffer.reset(index * mElement.getBytesSize()); |
| copyToArrayLocal(i, mIOBuffer); |
| } |
| |
| public synchronized void set(Item i, int index, boolean copyNow) { |
| if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; |
| mItemArray[index] = i; |
| if (copyNow) { |
| copyToArray(i, index); |
| FieldPacker fp = new FieldPacker(mElement.getBytesSize()); |
| copyToArrayLocal(i, fp); |
| mAllocation.setFromFieldPacker(index, fp); |
| } |
| |
| } |
| |
| public synchronized Item get(int index) { |
| if (mItemArray == null) return null; |
| return mItemArray[index]; |
| } |
| |
| public synchronized void set_i(int index, int v, boolean copyNow) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); |
| if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; |
| if (mItemArray[index] == null) mItemArray[index] = new Item(); |
| mItemArray[index].i = v; |
| if (copyNow) { |
| mIOBuffer.reset(index * mElement.getBytesSize()); |
| mIOBuffer.addI32(v); |
| FieldPacker fp = new FieldPacker(4); |
| fp.addI32(v); |
| mAllocation.setFromFieldPacker(index, 0, fp); |
| } |
| |
| } |
| |
| public synchronized void set_a(int index, Allocation v, boolean copyNow) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); |
| if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; |
| if (mItemArray[index] == null) mItemArray[index] = new Item(); |
| mItemArray[index].a = v; |
| if (copyNow) { |
| mIOBuffer.reset(index * mElement.getBytesSize() + ((RenderScript.getPointerSize() == 8) ? 8 : 4)); |
| mIOBuffer.addObj(v); |
| FieldPacker fp = new FieldPacker((RenderScript.getPointerSize() == 8) ? 32 : 4); |
| fp.addObj(v); |
| mAllocation.setFromFieldPacker(index, (RenderScript.getPointerSize() == 8) ? 2 : 1, fp); |
| } |
| |
| } |
| |
| public synchronized void set_j(int index, int v, boolean copyNow) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); |
| if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; |
| if (mItemArray[index] == null) mItemArray[index] = new Item(); |
| mItemArray[index].j = v; |
| if (copyNow) { |
| mIOBuffer.reset(index * mElement.getBytesSize() + ((RenderScript.getPointerSize() == 8) ? 40 : 8)); |
| mIOBuffer.addI32(v); |
| FieldPacker fp = new FieldPacker(4); |
| fp.addI32(v); |
| mAllocation.setFromFieldPacker(index, (RenderScript.getPointerSize() == 8) ? 3 : 2, fp); |
| } |
| |
| } |
| |
| public synchronized int get_i(int index) { |
| if (mItemArray == null) return 0; |
| return mItemArray[index].i; |
| } |
| |
| public synchronized Allocation get_a(int index) { |
| if (mItemArray == null) return null; |
| return mItemArray[index].a; |
| } |
| |
| public synchronized int get_j(int index) { |
| if (mItemArray == null) return 0; |
| return mItemArray[index].j; |
| } |
| |
| public synchronized void copyAll() { |
| for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct); |
| mAllocation.setFromFieldPacker(0, mIOBuffer); |
| } |
| |
| } |
| |