| /* |
| * Copyright (C) 2010 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: def2.rs |
| */ |
| package foo; |
| |
| import android.renderscript.*; |
| import android.content.res.Resources; |
| import android.util.Log; |
| |
| /** |
| * @hide |
| */ |
| public class ScriptField_DifferentDefinition7 extends android.renderscript.Script.FieldBase { |
| static public class Item { |
| public static final int sizeof = 4; |
| |
| float member1; |
| |
| Item() { |
| } |
| |
| } |
| |
| private Item mItemArray[]; |
| private FieldPacker mIOBuffer; |
| public static Element createElement(RenderScript rs) { |
| Element.Builder eb = new Element.Builder(rs); |
| eb.add(Element.F32(rs), "member1"); |
| return eb.create(); |
| } |
| |
| public ScriptField_DifferentDefinition7(RenderScript rs, int count) { |
| mItemArray = null; |
| mIOBuffer = null; |
| mElement = createElement(rs); |
| init(rs, count); |
| } |
| |
| private void copyToArray(Item i, int index) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */); |
| mIOBuffer.reset(index * Item.sizeof); |
| mIOBuffer.addF32(i.member1); |
| } |
| |
| public 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); |
| mAllocation.subData1D(index, 1, mIOBuffer.getData()); |
| } |
| |
| } |
| |
| public Item get(int index) { |
| if (mItemArray == null) return null; |
| return mItemArray[index]; |
| } |
| |
| public void set_member1(int index, float v, boolean copyNow) { |
| if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */); |
| if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */]; |
| if (mItemArray[index] == null) mItemArray[index] = new Item(); |
| mItemArray[index].member1 = v; |
| if (copyNow) { |
| mIOBuffer.reset(index * Item.sizeof); |
| mIOBuffer.addF32(v); |
| FieldPacker fp = new FieldPacker(4); |
| fp.addF32(v); |
| mAllocation.subElementData(index, 0, fp); |
| } |
| |
| } |
| |
| public float get_member1(int index) { |
| if (mItemArray == null) return 0; |
| return mItemArray[index].member1; |
| } |
| |
| public void copyAll() { |
| for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct); |
| mAllocation.data(mIOBuffer.getData()); |
| } |
| |
| public void resize(int newSize) { |
| if (mItemArray != null) { |
| int oldSize = mItemArray.length; |
| int copySize = Math.min(oldSize, newSize); |
| if (newSize == oldSize) return; |
| Item ni[] = new Item[newSize]; |
| System.arraycopy(mItemArray, 0, ni, 0, copySize); |
| mItemArray = ni; |
| } |
| |
| mAllocation.resize(newSize); |
| } |
| |
| } |
| |