16a360ef49a83c623784ce97e32f7c07b170ef364David Gross/* 26a360ef49a83c623784ce97e32f7c07b170ef364David Gross * Copyright (C) 2011-2014 The Android Open Source Project 36a360ef49a83c623784ce97e32f7c07b170ef364David Gross * 46a360ef49a83c623784ce97e32f7c07b170ef364David Gross * Licensed under the Apache License, Version 2.0 (the "License"); 56a360ef49a83c623784ce97e32f7c07b170ef364David Gross * you may not use this file except in compliance with the License. 66a360ef49a83c623784ce97e32f7c07b170ef364David Gross * You may obtain a copy of the License at 76a360ef49a83c623784ce97e32f7c07b170ef364David Gross * 86a360ef49a83c623784ce97e32f7c07b170ef364David Gross * http://www.apache.org/licenses/LICENSE-2.0 96a360ef49a83c623784ce97e32f7c07b170ef364David Gross * 106a360ef49a83c623784ce97e32f7c07b170ef364David Gross * Unless required by applicable law or agreed to in writing, software 116a360ef49a83c623784ce97e32f7c07b170ef364David Gross * distributed under the License is distributed on an "AS IS" BASIS, 126a360ef49a83c623784ce97e32f7c07b170ef364David Gross * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136a360ef49a83c623784ce97e32f7c07b170ef364David Gross * See the License for the specific language governing permissions and 146a360ef49a83c623784ce97e32f7c07b170ef364David Gross * limitations under the License. 156a360ef49a83c623784ce97e32f7c07b170ef364David Gross */ 166a360ef49a83c623784ce97e32f7c07b170ef364David Gross 176a360ef49a83c623784ce97e32f7c07b170ef364David Gross/* 186a360ef49a83c623784ce97e32f7c07b170ef364David Gross * This file is auto-generated. DO NOT MODIFY! 196a360ef49a83c623784ce97e32f7c07b170ef364David Gross * The source Renderscript file: reflection3264_divergent.rs 206a360ef49a83c623784ce97e32f7c07b170ef364David Gross */ 216a360ef49a83c623784ce97e32f7c07b170ef364David Gross 226a360ef49a83c623784ce97e32f7c07b170ef364David Grosspackage foo; 236a360ef49a83c623784ce97e32f7c07b170ef364David Gross 246a360ef49a83c623784ce97e32f7c07b170ef364David Grossimport android.os.Build; 256a360ef49a83c623784ce97e32f7c07b170ef364David Grossimport android.os.Process; 266a360ef49a83c623784ce97e32f7c07b170ef364David Grossimport java.lang.reflect.Field; 276a360ef49a83c623784ce97e32f7c07b170ef364David Grossimport android.renderscript.*; 286a360ef49a83c623784ce97e32f7c07b170ef364David Grossimport foo.reflection3264_divergentBitCode; 296a360ef49a83c623784ce97e32f7c07b170ef364David Gross 306a360ef49a83c623784ce97e32f7c07b170ef364David Gross/** 316a360ef49a83c623784ce97e32f7c07b170ef364David Gross * @hide 326a360ef49a83c623784ce97e32f7c07b170ef364David Gross */ 336a360ef49a83c623784ce97e32f7c07b170ef364David Grosspublic class ScriptField_NonDivergent extends android.renderscript.Script.FieldBase { 346a360ef49a83c623784ce97e32f7c07b170ef364David Gross static public class Item { 356a360ef49a83c623784ce97e32f7c07b170ef364David Gross 366a360ef49a83c623784ce97e32f7c07b170ef364David Gross int i; 376a360ef49a83c623784ce97e32f7c07b170ef364David Gross int j; 386a360ef49a83c623784ce97e32f7c07b170ef364David Gross 396a360ef49a83c623784ce97e32f7c07b170ef364David Gross Item() { 406a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 416a360ef49a83c623784ce97e32f7c07b170ef364David Gross 426a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 436a360ef49a83c623784ce97e32f7c07b170ef364David Gross 446a360ef49a83c623784ce97e32f7c07b170ef364David Gross private Item mItemArray[]; 456a360ef49a83c623784ce97e32f7c07b170ef364David Gross private FieldPacker mIOBuffer; 466a360ef49a83c623784ce97e32f7c07b170ef364David Gross private static java.lang.ref.WeakReference<Element> mElementCache = new java.lang.ref.WeakReference<Element>(null); 476a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static Element createElement(RenderScript rs) { 486a360ef49a83c623784ce97e32f7c07b170ef364David Gross Element.Builder eb = new Element.Builder(rs); 496a360ef49a83c623784ce97e32f7c07b170ef364David Gross eb.add(Element.I32(rs), "i"); 506a360ef49a83c623784ce97e32f7c07b170ef364David Gross eb.add(Element.I32(rs), "j"); 516a360ef49a83c623784ce97e32f7c07b170ef364David Gross return eb.create(); 526a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 536a360ef49a83c623784ce97e32f7c07b170ef364David Gross 546a360ef49a83c623784ce97e32f7c07b170ef364David Gross private ScriptField_NonDivergent(RenderScript rs) { 556a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray = null; 566a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer = null; 576a360ef49a83c623784ce97e32f7c07b170ef364David Gross mElement = createElement(rs); 586a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 596a360ef49a83c623784ce97e32f7c07b170ef364David Gross 606a360ef49a83c623784ce97e32f7c07b170ef364David Gross public ScriptField_NonDivergent(RenderScript rs, int count) { 616a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray = null; 626a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer = null; 636a360ef49a83c623784ce97e32f7c07b170ef364David Gross mElement = createElement(rs); 646a360ef49a83c623784ce97e32f7c07b170ef364David Gross init(rs, count); 656a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 666a360ef49a83c623784ce97e32f7c07b170ef364David Gross 676a360ef49a83c623784ce97e32f7c07b170ef364David Gross public ScriptField_NonDivergent(RenderScript rs, int count, int usages) { 686a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray = null; 696a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer = null; 706a360ef49a83c623784ce97e32f7c07b170ef364David Gross mElement = createElement(rs); 716a360ef49a83c623784ce97e32f7c07b170ef364David Gross init(rs, count, usages); 726a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 736a360ef49a83c623784ce97e32f7c07b170ef364David Gross 746a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static ScriptField_NonDivergent create1D(RenderScript rs, int dimX, int usages) { 756a360ef49a83c623784ce97e32f7c07b170ef364David Gross ScriptField_NonDivergent obj = new ScriptField_NonDivergent(rs); 766a360ef49a83c623784ce97e32f7c07b170ef364David Gross obj.mAllocation = Allocation.createSized(rs, obj.mElement, dimX, usages); 776a360ef49a83c623784ce97e32f7c07b170ef364David Gross return obj; 786a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 796a360ef49a83c623784ce97e32f7c07b170ef364David Gross 806a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static ScriptField_NonDivergent create1D(RenderScript rs, int dimX) { 816a360ef49a83c623784ce97e32f7c07b170ef364David Gross return create1D(rs, dimX, Allocation.USAGE_SCRIPT); 826a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 836a360ef49a83c623784ce97e32f7c07b170ef364David Gross 846a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static ScriptField_NonDivergent create2D(RenderScript rs, int dimX, int dimY) { 856a360ef49a83c623784ce97e32f7c07b170ef364David Gross return create2D(rs, dimX, dimY, Allocation.USAGE_SCRIPT); 866a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 876a360ef49a83c623784ce97e32f7c07b170ef364David Gross 886a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static ScriptField_NonDivergent create2D(RenderScript rs, int dimX, int dimY, int usages) { 896a360ef49a83c623784ce97e32f7c07b170ef364David Gross ScriptField_NonDivergent obj = new ScriptField_NonDivergent(rs); 906a360ef49a83c623784ce97e32f7c07b170ef364David Gross Type.Builder b = new Type.Builder(rs, obj.mElement); 916a360ef49a83c623784ce97e32f7c07b170ef364David Gross b.setX(dimX); 926a360ef49a83c623784ce97e32f7c07b170ef364David Gross b.setY(dimY); 936a360ef49a83c623784ce97e32f7c07b170ef364David Gross Type t = b.create(); 946a360ef49a83c623784ce97e32f7c07b170ef364David Gross obj.mAllocation = Allocation.createTyped(rs, t, usages); 956a360ef49a83c623784ce97e32f7c07b170ef364David Gross return obj; 966a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 976a360ef49a83c623784ce97e32f7c07b170ef364David Gross 986a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static Type.Builder createTypeBuilder(RenderScript rs) { 996a360ef49a83c623784ce97e32f7c07b170ef364David Gross Element e = createElement(rs); 1006a360ef49a83c623784ce97e32f7c07b170ef364David Gross return new Type.Builder(rs, e); 1016a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1026a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1036a360ef49a83c623784ce97e32f7c07b170ef364David Gross public static ScriptField_NonDivergent createCustom(RenderScript rs, Type.Builder tb, int usages) { 1046a360ef49a83c623784ce97e32f7c07b170ef364David Gross ScriptField_NonDivergent obj = new ScriptField_NonDivergent(rs); 1056a360ef49a83c623784ce97e32f7c07b170ef364David Gross Type t = tb.create(); 1066a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (t.getElement() != obj.mElement) { 1076a360ef49a83c623784ce97e32f7c07b170ef364David Gross throw new RSIllegalArgumentException("Type.Builder did not match expected element type."); 1086a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1096a360ef49a83c623784ce97e32f7c07b170ef364David Gross obj.mAllocation = Allocation.createTyped(rs, t, usages); 1106a360ef49a83c623784ce97e32f7c07b170ef364David Gross return obj; 1116a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1126a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1136a360ef49a83c623784ce97e32f7c07b170ef364David Gross private void copyToArrayLocal(Item i, FieldPacker fp) { 1146a360ef49a83c623784ce97e32f7c07b170ef364David Gross fp.addI32(i.i); 1156a360ef49a83c623784ce97e32f7c07b170ef364David Gross fp.addI32(i.j); 1166a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1176a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1186a360ef49a83c623784ce97e32f7c07b170ef364David Gross private void copyToArray(Item i, int index) { 1196a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); 1206a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer.reset(index * mElement.getBytesSize()); 1216a360ef49a83c623784ce97e32f7c07b170ef364David Gross copyToArrayLocal(i, mIOBuffer); 1226a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1236a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1246a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized void set(Item i, int index, boolean copyNow) { 1256a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; 1266a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray[index] = i; 1276a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (copyNow) { 1286a360ef49a83c623784ce97e32f7c07b170ef364David Gross copyToArray(i, index); 1296a360ef49a83c623784ce97e32f7c07b170ef364David Gross FieldPacker fp = new FieldPacker(mElement.getBytesSize()); 1306a360ef49a83c623784ce97e32f7c07b170ef364David Gross copyToArrayLocal(i, fp); 1316a360ef49a83c623784ce97e32f7c07b170ef364David Gross mAllocation.setFromFieldPacker(index, fp); 1326a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1336a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1346a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1356a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1366a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized Item get(int index) { 1376a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) return null; 1386a360ef49a83c623784ce97e32f7c07b170ef364David Gross return mItemArray[index]; 1396a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1406a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1416a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized void set_i(int index, int v, boolean copyNow) { 1426a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); 1436a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; 1446a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray[index] == null) mItemArray[index] = new Item(); 1456a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray[index].i = v; 1466a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (copyNow) { 1476a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer.reset(index * mElement.getBytesSize()); 1486a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer.addI32(v); 1496a360ef49a83c623784ce97e32f7c07b170ef364David Gross FieldPacker fp = new FieldPacker(4); 1506a360ef49a83c623784ce97e32f7c07b170ef364David Gross fp.addI32(v); 1516a360ef49a83c623784ce97e32f7c07b170ef364David Gross mAllocation.setFromFieldPacker(index, 0, fp); 1526a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1536a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1546a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1556a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1566a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized void set_j(int index, int v, boolean copyNow) { 1576a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mIOBuffer == null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); 1586a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; 1596a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray[index] == null) mItemArray[index] = new Item(); 1606a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray[index].j = v; 1616a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (copyNow) { 1626a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer.reset(index * mElement.getBytesSize() + 4); 1636a360ef49a83c623784ce97e32f7c07b170ef364David Gross mIOBuffer.addI32(v); 1646a360ef49a83c623784ce97e32f7c07b170ef364David Gross FieldPacker fp = new FieldPacker(4); 1656a360ef49a83c623784ce97e32f7c07b170ef364David Gross fp.addI32(v); 1666a360ef49a83c623784ce97e32f7c07b170ef364David Gross mAllocation.setFromFieldPacker(index, 1, fp); 1676a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1686a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1696a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1706a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1716a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized int get_i(int index) { 1726a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) return 0; 1736a360ef49a83c623784ce97e32f7c07b170ef364David Gross return mItemArray[index].i; 1746a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1756a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1766a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized int get_j(int index) { 1776a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray == null) return 0; 1786a360ef49a83c623784ce97e32f7c07b170ef364David Gross return mItemArray[index].j; 1796a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1806a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1816a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized void copyAll() { 1826a360ef49a83c623784ce97e32f7c07b170ef364David Gross for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct); 1836a360ef49a83c623784ce97e32f7c07b170ef364David Gross mAllocation.setFromFieldPacker(0, mIOBuffer); 1846a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1856a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1866a360ef49a83c623784ce97e32f7c07b170ef364David Gross public synchronized void resize(int newSize) { 1876a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mItemArray != null) { 1886a360ef49a83c623784ce97e32f7c07b170ef364David Gross int oldSize = mItemArray.length; 1896a360ef49a83c623784ce97e32f7c07b170ef364David Gross int copySize = Math.min(oldSize, newSize); 1906a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (newSize == oldSize) return; 1916a360ef49a83c623784ce97e32f7c07b170ef364David Gross Item ni[] = new Item[newSize]; 1926a360ef49a83c623784ce97e32f7c07b170ef364David Gross System.arraycopy(mItemArray, 0, ni, 0, copySize); 1936a360ef49a83c623784ce97e32f7c07b170ef364David Gross mItemArray = ni; 1946a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1956a360ef49a83c623784ce97e32f7c07b170ef364David Gross 1966a360ef49a83c623784ce97e32f7c07b170ef364David Gross mAllocation.resize(newSize); 1976a360ef49a83c623784ce97e32f7c07b170ef364David Gross if (mIOBuffer != null) mIOBuffer = new FieldPacker(mElement.getBytesSize() * getType().getX()/* count */); 1986a360ef49a83c623784ce97e32f7c07b170ef364David Gross } 1996a360ef49a83c623784ce97e32f7c07b170ef364David Gross 2006a360ef49a83c623784ce97e32f7c07b170ef364David Gross} 2016a360ef49a83c623784ce97e32f7c07b170ef364David Gross 202