| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1 | /* |
| Stephen Hines | 3beb60e | 2012-02-14 20:38:20 -0800 | [diff] [blame] | 2 | * Copyright (C) 2008-2012 The Android Open Source Project |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 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 | package android.renderscript; |
| 18 | |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 19 | import java.lang.reflect.Field; |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 20 | import android.util.Log; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 21 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 22 | /** @deprecated renderscript is deprecated in J |
| Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 23 | * <p>The most basic data type. An element represents one cell of a memory allocation. |
| Alex Sakhartchouk | 3476977 | 2011-02-28 16:01:28 -0800 | [diff] [blame] | 24 | * Element is the basic data type of Renderscript. An element can be of two forms: Basic elements or Complex forms. |
| Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 25 | * Examples of basic elements are:</p> |
| 26 | * <ul> |
| 27 | * <li>Single float value</li> |
| 28 | * <li>4 element float vector</li> |
| 29 | * <li>single RGB-565 color</li> |
| 30 | * <li>single unsigned int 16</li> |
| 31 | * </ul> |
| Alex Sakhartchouk | 3476977 | 2011-02-28 16:01:28 -0800 | [diff] [blame] | 32 | * <p>Complex elements contain a list of sub-elements and names that |
| Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 33 | * represents a structure of data. The fields can be accessed by name |
| 34 | * from a script or shader. The memory layout is defined and ordered. Data |
| Stephen Hines | f257e51 | 2011-06-14 14:54:29 -0700 | [diff] [blame] | 35 | * alignment is determined by the most basic primitive type. i.e. a float4 |
| 36 | * vector will be aligned to sizeof(float) and not sizeof(float4). The |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 37 | * ordering of elements in memory will be the order in which they were added |
| Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 38 | * with each component aligned as necessary. No re-ordering will be done.</p> |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 39 | * |
| Robert Ly | 11518ac | 2011-02-09 13:57:06 -0800 | [diff] [blame] | 40 | * <p>The primary source of elements are from scripts. A script that exports a |
| 41 | * bind point for a data structure generates a Renderscript element to represent the |
| 42 | * data exported by the script. The other common source of elements is from bitmap formats.</p> |
| Joe Fernandez | 3aef8e1d | 2011-12-20 10:38:34 -0800 | [diff] [blame] | 43 | * |
| 44 | * <div class="special reference"> |
| 45 | * <h3>Developer Guides</h3> |
| 46 | * <p>For more information about creating an application that uses Renderscript, read the |
| 47 | * <a href="{@docRoot}guide/topics/graphics/renderscript.html">Renderscript</a> developer guide.</p> |
| 48 | * </div> |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 49 | **/ |
| 50 | public class Element extends BaseObj { |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 51 | int mSize; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 52 | Element[] mElements; |
| 53 | String[] mElementNames; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 54 | int[] mArraySizes; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 55 | int[] mOffsetInBytes; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 56 | |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 57 | int[] mVisibleElementMap; |
| 58 | |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 59 | DataType mType; |
| 60 | DataKind mKind; |
| 61 | boolean mNormalized; |
| 62 | int mVectorSize; |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 63 | |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 64 | private void updateVisibleSubElements() { |
| 65 | if (mElements == null) { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | int noPaddingFieldCount = 0; |
| 70 | int fieldCount = mElementNames.length; |
| 71 | // Find out how many elements are not padding |
| 72 | for (int ct = 0; ct < fieldCount; ct ++) { |
| 73 | if (mElementNames[ct].charAt(0) != '#') { |
| 74 | noPaddingFieldCount ++; |
| 75 | } |
| 76 | } |
| 77 | mVisibleElementMap = new int[noPaddingFieldCount]; |
| 78 | |
| 79 | // Make a map that points us at non-padding elements |
| 80 | for (int ct = 0, ctNoPadding = 0; ct < fieldCount; ct ++) { |
| 81 | if (mElementNames[ct].charAt(0) != '#') { |
| 82 | mVisibleElementMap[ctNoPadding ++] = ct; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 87 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 88 | * @return element size in bytes |
| 89 | */ |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 90 | public int getBytesSize() {return mSize;} |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 91 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 92 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 93 | * Returns the number of vector components. 2 for float2, 4 for |
| 94 | * float4, etc. |
| Alex Sakhartchouk | fd79e02 | 2011-12-22 14:30:55 -0800 | [diff] [blame] | 95 | * @return element vector size |
| 96 | */ |
| 97 | public int getVectorSize() {return mVectorSize;} |
| 98 | |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 99 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 100 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 101 | * DataType represents the basic type information for a basic element. The |
| Alex Sakhartchouk | f5d8ac7 | 2011-12-16 09:44:26 -0800 | [diff] [blame] | 102 | * naming convention follows. For numeric types it is FLOAT, |
| 103 | * SIGNED, or UNSIGNED followed by the _BITS where BITS is the |
| 104 | * size of the data. BOOLEAN is a true / false (1,0) |
| 105 | * represented in an 8 bit container. The UNSIGNED variants |
| 106 | * with multiple bit definitions are for packed graphical data |
| 107 | * formats and represent vectors with per vector member sizes |
| 108 | * which are treated as a single unit for packing and alignment |
| 109 | * purposes. |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 110 | * |
| 111 | * MATRIX the three matrix types contain FLOAT_32 elements and are treated |
| 112 | * as 32 bits for alignment purposes. |
| 113 | * |
| 114 | * RS_* objects. 32 bit opaque handles. |
| 115 | */ |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 116 | public enum DataType { |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 117 | /** @hide |
| 118 | */ |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 119 | NONE (0, 0), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 120 | //FLOAT_16 (1, 2), |
| 121 | FLOAT_32 (2, 4), |
| Stephen Hines | 02f41705 | 2010-09-30 15:19:22 -0700 | [diff] [blame] | 122 | FLOAT_64 (3, 8), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 123 | SIGNED_8 (4, 1), |
| 124 | SIGNED_16 (5, 2), |
| 125 | SIGNED_32 (6, 4), |
| Stephen Hines | ef1dac2 | 2010-10-01 15:39:33 -0700 | [diff] [blame] | 126 | SIGNED_64 (7, 8), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 127 | UNSIGNED_8 (8, 1), |
| 128 | UNSIGNED_16 (9, 2), |
| 129 | UNSIGNED_32 (10, 4), |
| Stephen Hines | 52d8363 | 2010-10-11 16:10:42 -0700 | [diff] [blame] | 130 | UNSIGNED_64 (11, 8), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 131 | |
| Jason Sams | f110d4b | 2010-06-21 17:42:41 -0700 | [diff] [blame] | 132 | BOOLEAN(12, 1), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 133 | |
| Jason Sams | f110d4b | 2010-06-21 17:42:41 -0700 | [diff] [blame] | 134 | UNSIGNED_5_6_5 (13, 2), |
| 135 | UNSIGNED_5_5_5_1 (14, 2), |
| 136 | UNSIGNED_4_4_4_4 (15, 2), |
| 137 | |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 138 | MATRIX_4X4 (16, 64), |
| 139 | MATRIX_3X3 (17, 36), |
| 140 | MATRIX_2X2 (18, 16), |
| 141 | |
| 142 | RS_ELEMENT (1000, 4), |
| 143 | RS_TYPE (1001, 4), |
| 144 | RS_ALLOCATION (1002, 4), |
| 145 | RS_SAMPLER (1003, 4), |
| 146 | RS_SCRIPT (1004, 4), |
| 147 | RS_MESH (1005, 4), |
| 148 | RS_PROGRAM_FRAGMENT (1006, 4), |
| 149 | RS_PROGRAM_VERTEX (1007, 4), |
| 150 | RS_PROGRAM_RASTER (1008, 4), |
| Stephen Hines | 3a29141 | 2012-04-11 17:27:29 -0700 | [diff] [blame] | 151 | RS_PROGRAM_STORE (1009, 4), |
| 152 | RS_FONT (1010, 4); |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 153 | |
| 154 | int mID; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 155 | int mSize; |
| 156 | DataType(int id, int size) { |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 157 | mID = id; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 158 | mSize = size; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 162 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 163 | * The special interpretation of the data if required. This is primarly |
| 164 | * useful for graphical data. USER indicates no special interpretation is |
| 165 | * expected. PIXEL is used in conjunction with the standard data types for |
| 166 | * representing texture formats. |
| 167 | */ |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 168 | public enum DataKind { |
| 169 | USER (0), |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 170 | |
| 171 | PIXEL_L (7), |
| 172 | PIXEL_A (8), |
| 173 | PIXEL_LA (9), |
| 174 | PIXEL_RGB (10), |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 175 | PIXEL_RGBA (11), |
| 176 | PIXEL_DEPTH (12); |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 177 | |
| 178 | int mID; |
| 179 | DataKind(int id) { |
| 180 | mID = id; |
| 181 | } |
| 182 | } |
| 183 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 184 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 185 | * Return if a element is too complex for use as a data source for a Mesh or |
| 186 | * a Program. |
| 187 | * |
| 188 | * @return boolean |
| 189 | */ |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 190 | public boolean isComplex() { |
| 191 | if (mElements == null) { |
| 192 | return false; |
| 193 | } |
| 194 | for (int ct=0; ct < mElements.length; ct++) { |
| 195 | if (mElements[ct].mElements != null) { |
| 196 | return true; |
| 197 | } |
| 198 | } |
| 199 | return false; |
| 200 | } |
| 201 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 202 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 203 | * Elements could be simple, such as an int or a float, or a |
| 204 | * structure with multiple sub elements, such as a collection of |
| 205 | * floats, float2, float4. This function returns zero for simple |
| 206 | * elements or the number of sub-elements otherwise. |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 207 | * @return number of sub-elements in this element |
| 208 | */ |
| 209 | public int getSubElementCount() { |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 210 | if (mVisibleElementMap == null) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 213 | return mVisibleElementMap.length; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 216 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 217 | * For complex elements, this function will return the |
| 218 | * sub-element at index |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 219 | * @param index index of the sub-element to return |
| 220 | * @return sub-element in this element at given index |
| 221 | */ |
| 222 | public Element getSubElement(int index) { |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 223 | if (mVisibleElementMap == null) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 224 | throw new RSIllegalArgumentException("Element contains no sub-elements"); |
| 225 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 226 | if (index < 0 || index >= mVisibleElementMap.length) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 227 | throw new RSIllegalArgumentException("Illegal sub-element index"); |
| 228 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 229 | return mElements[mVisibleElementMap[index]]; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 232 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 233 | * For complex elements, this function will return the |
| 234 | * sub-element name at index |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 235 | * @param index index of the sub-element |
| 236 | * @return sub-element in this element at given index |
| 237 | */ |
| 238 | public String getSubElementName(int index) { |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 239 | if (mVisibleElementMap == null) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 240 | throw new RSIllegalArgumentException("Element contains no sub-elements"); |
| 241 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 242 | if (index < 0 || index >= mVisibleElementMap.length) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 243 | throw new RSIllegalArgumentException("Illegal sub-element index"); |
| 244 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 245 | return mElementNames[mVisibleElementMap[index]]; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 248 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 249 | * For complex elements, some sub-elements could be statically |
| 250 | * sized arrays. This function will return the array size for |
| 251 | * sub-element at index |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 252 | * @param index index of the sub-element |
| 253 | * @return array size of sub-element in this element at given index |
| 254 | */ |
| 255 | public int getSubElementArraySize(int index) { |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 256 | if (mVisibleElementMap == null) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 257 | throw new RSIllegalArgumentException("Element contains no sub-elements"); |
| 258 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 259 | if (index < 0 || index >= mVisibleElementMap.length) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 260 | throw new RSIllegalArgumentException("Illegal sub-element index"); |
| 261 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 262 | return mArraySizes[mVisibleElementMap[index]]; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 265 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | 918e840 | 2012-04-11 14:04:23 -0700 | [diff] [blame] | 266 | * This function specifies the location of a sub-element within |
| 267 | * the element |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 268 | * @param index index of the sub-element |
| 269 | * @return offset in bytes of sub-element in this element at given index |
| 270 | */ |
| 271 | public int getSubElementOffsetBytes(int index) { |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 272 | if (mVisibleElementMap == null) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 273 | throw new RSIllegalArgumentException("Element contains no sub-elements"); |
| 274 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 275 | if (index < 0 || index >= mVisibleElementMap.length) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 276 | throw new RSIllegalArgumentException("Illegal sub-element index"); |
| 277 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 278 | return mOffsetInBytes[mVisibleElementMap[index]]; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 281 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | f5d8ac7 | 2011-12-16 09:44:26 -0800 | [diff] [blame] | 282 | * @return element data type |
| 283 | */ |
| 284 | public DataType getDataType() { |
| 285 | return mType; |
| 286 | } |
| 287 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 288 | /** @hide renderscript is deprecated in J |
| Alex Sakhartchouk | f5d8ac7 | 2011-12-16 09:44:26 -0800 | [diff] [blame] | 289 | * @return element data kind |
| 290 | */ |
| 291 | public DataKind getDataKind() { |
| 292 | return mKind; |
| 293 | } |
| 294 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 295 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 296 | * Utility function for returning an Element containing a single Boolean. |
| 297 | * |
| 298 | * @param rs Context to which the element will belong. |
| 299 | * |
| 300 | * @return Element |
| 301 | */ |
| Jason Sams | f110d4b | 2010-06-21 17:42:41 -0700 | [diff] [blame] | 302 | public static Element BOOLEAN(RenderScript rs) { |
| 303 | if(rs.mElement_BOOLEAN == null) { |
| 304 | rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN); |
| 305 | } |
| 306 | return rs.mElement_BOOLEAN; |
| 307 | } |
| 308 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 309 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 310 | * Utility function for returning an Element containing a single UNSIGNED_8. |
| 311 | * |
| 312 | * @param rs Context to which the element will belong. |
| 313 | * |
| 314 | * @return Element |
| 315 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 316 | public static Element U8(RenderScript rs) { |
| 317 | if(rs.mElement_U8 == null) { |
| 318 | rs.mElement_U8 = createUser(rs, DataType.UNSIGNED_8); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 319 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 320 | return rs.mElement_U8; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 321 | } |
| 322 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 323 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 324 | * Utility function for returning an Element containing a single SIGNED_8. |
| 325 | * |
| 326 | * @param rs Context to which the element will belong. |
| 327 | * |
| 328 | * @return Element |
| 329 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 330 | public static Element I8(RenderScript rs) { |
| 331 | if(rs.mElement_I8 == null) { |
| 332 | rs.mElement_I8 = createUser(rs, DataType.SIGNED_8); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 333 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 334 | return rs.mElement_I8; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 337 | /** @deprecated renderscript is deprecated in J |
| 338 | */ |
| Jason Sams | e29f3e7 | 2010-06-08 15:40:48 -0700 | [diff] [blame] | 339 | public static Element U16(RenderScript rs) { |
| 340 | if(rs.mElement_U16 == null) { |
| 341 | rs.mElement_U16 = createUser(rs, DataType.UNSIGNED_16); |
| 342 | } |
| 343 | return rs.mElement_U16; |
| 344 | } |
| 345 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 346 | /** @deprecated renderscript is deprecated in J |
| 347 | */ |
| Jason Sams | e29f3e7 | 2010-06-08 15:40:48 -0700 | [diff] [blame] | 348 | public static Element I16(RenderScript rs) { |
| 349 | if(rs.mElement_I16 == null) { |
| 350 | rs.mElement_I16 = createUser(rs, DataType.SIGNED_16); |
| 351 | } |
| 352 | return rs.mElement_I16; |
| 353 | } |
| 354 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 355 | /** @deprecated renderscript is deprecated in J |
| 356 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 357 | public static Element U32(RenderScript rs) { |
| 358 | if(rs.mElement_U32 == null) { |
| 359 | rs.mElement_U32 = createUser(rs, DataType.UNSIGNED_32); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 360 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 361 | return rs.mElement_U32; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 362 | } |
| 363 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 364 | /** @deprecated renderscript is deprecated in J |
| 365 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 366 | public static Element I32(RenderScript rs) { |
| 367 | if(rs.mElement_I32 == null) { |
| 368 | rs.mElement_I32 = createUser(rs, DataType.SIGNED_32); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 369 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 370 | return rs.mElement_I32; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 371 | } |
| 372 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 373 | /** @deprecated renderscript is deprecated in J |
| 374 | */ |
| Stephen Hines | 52d8363 | 2010-10-11 16:10:42 -0700 | [diff] [blame] | 375 | public static Element U64(RenderScript rs) { |
| 376 | if(rs.mElement_U64 == null) { |
| 377 | rs.mElement_U64 = createUser(rs, DataType.UNSIGNED_64); |
| 378 | } |
| 379 | return rs.mElement_U64; |
| 380 | } |
| 381 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 382 | /** @deprecated renderscript is deprecated in J |
| 383 | */ |
| Stephen Hines | ef1dac2 | 2010-10-01 15:39:33 -0700 | [diff] [blame] | 384 | public static Element I64(RenderScript rs) { |
| 385 | if(rs.mElement_I64 == null) { |
| 386 | rs.mElement_I64 = createUser(rs, DataType.SIGNED_64); |
| 387 | } |
| 388 | return rs.mElement_I64; |
| 389 | } |
| 390 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 391 | /** @deprecated renderscript is deprecated in J |
| 392 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 393 | public static Element F32(RenderScript rs) { |
| 394 | if(rs.mElement_F32 == null) { |
| 395 | rs.mElement_F32 = createUser(rs, DataType.FLOAT_32); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 396 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 397 | return rs.mElement_F32; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 398 | } |
| 399 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 400 | /** @deprecated renderscript is deprecated in J |
| 401 | */ |
| Stephen Hines | 02f41705 | 2010-09-30 15:19:22 -0700 | [diff] [blame] | 402 | public static Element F64(RenderScript rs) { |
| 403 | if(rs.mElement_F64 == null) { |
| 404 | rs.mElement_F64 = createUser(rs, DataType.FLOAT_64); |
| 405 | } |
| 406 | return rs.mElement_F64; |
| 407 | } |
| 408 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 409 | /** @deprecated renderscript is deprecated in J |
| 410 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 411 | public static Element ELEMENT(RenderScript rs) { |
| 412 | if(rs.mElement_ELEMENT == null) { |
| 413 | rs.mElement_ELEMENT = createUser(rs, DataType.RS_ELEMENT); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 414 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 415 | return rs.mElement_ELEMENT; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 416 | } |
| 417 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 418 | /** @deprecated renderscript is deprecated in J |
| 419 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 420 | public static Element TYPE(RenderScript rs) { |
| 421 | if(rs.mElement_TYPE == null) { |
| 422 | rs.mElement_TYPE = createUser(rs, DataType.RS_TYPE); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 423 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 424 | return rs.mElement_TYPE; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 427 | /** @deprecated renderscript is deprecated in J |
| 428 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 429 | public static Element ALLOCATION(RenderScript rs) { |
| 430 | if(rs.mElement_ALLOCATION == null) { |
| 431 | rs.mElement_ALLOCATION = createUser(rs, DataType.RS_ALLOCATION); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 432 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 433 | return rs.mElement_ALLOCATION; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 436 | /** @deprecated renderscript is deprecated in J |
| 437 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 438 | public static Element SAMPLER(RenderScript rs) { |
| 439 | if(rs.mElement_SAMPLER == null) { |
| 440 | rs.mElement_SAMPLER = createUser(rs, DataType.RS_SAMPLER); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 441 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 442 | return rs.mElement_SAMPLER; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 445 | /** @deprecated renderscript is deprecated in J |
| 446 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 447 | public static Element SCRIPT(RenderScript rs) { |
| 448 | if(rs.mElement_SCRIPT == null) { |
| 449 | rs.mElement_SCRIPT = createUser(rs, DataType.RS_SCRIPT); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 450 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 451 | return rs.mElement_SCRIPT; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 454 | /** @deprecated renderscript is deprecated in J |
| 455 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 456 | public static Element MESH(RenderScript rs) { |
| 457 | if(rs.mElement_MESH == null) { |
| 458 | rs.mElement_MESH = createUser(rs, DataType.RS_MESH); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 459 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 460 | return rs.mElement_MESH; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 461 | } |
| 462 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 463 | /** @deprecated renderscript is deprecated in J |
| 464 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 465 | public static Element PROGRAM_FRAGMENT(RenderScript rs) { |
| 466 | if(rs.mElement_PROGRAM_FRAGMENT == null) { |
| 467 | rs.mElement_PROGRAM_FRAGMENT = createUser(rs, DataType.RS_PROGRAM_FRAGMENT); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 468 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 469 | return rs.mElement_PROGRAM_FRAGMENT; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 470 | } |
| 471 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 472 | /** @deprecated renderscript is deprecated in J |
| 473 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 474 | public static Element PROGRAM_VERTEX(RenderScript rs) { |
| 475 | if(rs.mElement_PROGRAM_VERTEX == null) { |
| 476 | rs.mElement_PROGRAM_VERTEX = createUser(rs, DataType.RS_PROGRAM_VERTEX); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 477 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 478 | return rs.mElement_PROGRAM_VERTEX; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 481 | /** @deprecated renderscript is deprecated in J |
| 482 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 483 | public static Element PROGRAM_RASTER(RenderScript rs) { |
| 484 | if(rs.mElement_PROGRAM_RASTER == null) { |
| 485 | rs.mElement_PROGRAM_RASTER = createUser(rs, DataType.RS_PROGRAM_RASTER); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 486 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 487 | return rs.mElement_PROGRAM_RASTER; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 488 | } |
| 489 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 490 | /** @deprecated renderscript is deprecated in J |
| 491 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 492 | public static Element PROGRAM_STORE(RenderScript rs) { |
| 493 | if(rs.mElement_PROGRAM_STORE == null) { |
| 494 | rs.mElement_PROGRAM_STORE = createUser(rs, DataType.RS_PROGRAM_STORE); |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 495 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 496 | return rs.mElement_PROGRAM_STORE; |
| Jason Sams | a70f416 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| Stephen Hines | 9da1b5d | 2012-04-30 16:36:04 -0700 | [diff] [blame] | 499 | /** @deprecated renderscript is deprecated in J |
| 500 | */ |
| Stephen Hines | 3a29141 | 2012-04-11 17:27:29 -0700 | [diff] [blame] | 501 | public static Element FONT(RenderScript rs) { |
| 502 | if(rs.mElement_FONT == null) { |
| 503 | rs.mElement_FONT = createUser(rs, DataType.RS_FONT); |
| 504 | } |
| 505 | return rs.mElement_FONT; |
| 506 | } |
| 507 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 508 | /** @deprecated renderscript is deprecated in J |
| 509 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 510 | public static Element A_8(RenderScript rs) { |
| 511 | if(rs.mElement_A_8 == null) { |
| 512 | rs.mElement_A_8 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_A); |
| 513 | } |
| 514 | return rs.mElement_A_8; |
| 515 | } |
| 516 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 517 | /** @deprecated renderscript is deprecated in J |
| 518 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 519 | public static Element RGB_565(RenderScript rs) { |
| 520 | if(rs.mElement_RGB_565 == null) { |
| 521 | rs.mElement_RGB_565 = createPixel(rs, DataType.UNSIGNED_5_6_5, DataKind.PIXEL_RGB); |
| 522 | } |
| 523 | return rs.mElement_RGB_565; |
| 524 | } |
| 525 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 526 | /** @deprecated renderscript is deprecated in J |
| 527 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 528 | public static Element RGB_888(RenderScript rs) { |
| 529 | if(rs.mElement_RGB_888 == null) { |
| 530 | rs.mElement_RGB_888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGB); |
| 531 | } |
| 532 | return rs.mElement_RGB_888; |
| 533 | } |
| 534 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 535 | /** @deprecated renderscript is deprecated in J |
| 536 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 537 | public static Element RGBA_5551(RenderScript rs) { |
| 538 | if(rs.mElement_RGBA_5551 == null) { |
| 539 | rs.mElement_RGBA_5551 = createPixel(rs, DataType.UNSIGNED_5_5_5_1, DataKind.PIXEL_RGBA); |
| 540 | } |
| 541 | return rs.mElement_RGBA_5551; |
| 542 | } |
| 543 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 544 | /** @deprecated renderscript is deprecated in J |
| 545 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 546 | public static Element RGBA_4444(RenderScript rs) { |
| 547 | if(rs.mElement_RGBA_4444 == null) { |
| 548 | rs.mElement_RGBA_4444 = createPixel(rs, DataType.UNSIGNED_4_4_4_4, DataKind.PIXEL_RGBA); |
| 549 | } |
| 550 | return rs.mElement_RGBA_4444; |
| 551 | } |
| 552 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 553 | /** @deprecated renderscript is deprecated in J |
| 554 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 555 | public static Element RGBA_8888(RenderScript rs) { |
| 556 | if(rs.mElement_RGBA_8888 == null) { |
| 557 | rs.mElement_RGBA_8888 = createPixel(rs, DataType.UNSIGNED_8, DataKind.PIXEL_RGBA); |
| 558 | } |
| 559 | return rs.mElement_RGBA_8888; |
| 560 | } |
| 561 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 562 | /** @deprecated renderscript is deprecated in J |
| 563 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 564 | public static Element F32_2(RenderScript rs) { |
| 565 | if(rs.mElement_FLOAT_2 == null) { |
| 566 | rs.mElement_FLOAT_2 = createVector(rs, DataType.FLOAT_32, 2); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 567 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 568 | return rs.mElement_FLOAT_2; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 569 | } |
| 570 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 571 | /** @deprecated renderscript is deprecated in J |
| 572 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 573 | public static Element F32_3(RenderScript rs) { |
| 574 | if(rs.mElement_FLOAT_3 == null) { |
| 575 | rs.mElement_FLOAT_3 = createVector(rs, DataType.FLOAT_32, 3); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 576 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 577 | return rs.mElement_FLOAT_3; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 578 | } |
| 579 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 580 | /** @deprecated renderscript is deprecated in J |
| 581 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 582 | public static Element F32_4(RenderScript rs) { |
| 583 | if(rs.mElement_FLOAT_4 == null) { |
| 584 | rs.mElement_FLOAT_4 = createVector(rs, DataType.FLOAT_32, 4); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 585 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 586 | return rs.mElement_FLOAT_4; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 587 | } |
| 588 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 589 | /** @deprecated renderscript is deprecated in J |
| 590 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 591 | public static Element F64_2(RenderScript rs) { |
| 592 | if(rs.mElement_DOUBLE_2 == null) { |
| 593 | rs.mElement_DOUBLE_2 = createVector(rs, DataType.FLOAT_64, 2); |
| 594 | } |
| 595 | return rs.mElement_DOUBLE_2; |
| 596 | } |
| 597 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 598 | /** @deprecated renderscript is deprecated in J |
| 599 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 600 | public static Element F64_3(RenderScript rs) { |
| 601 | if(rs.mElement_DOUBLE_3 == null) { |
| 602 | rs.mElement_DOUBLE_3 = createVector(rs, DataType.FLOAT_64, 3); |
| 603 | } |
| 604 | return rs.mElement_DOUBLE_3; |
| 605 | } |
| 606 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 607 | /** @deprecated renderscript is deprecated in J |
| 608 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 609 | public static Element F64_4(RenderScript rs) { |
| 610 | if(rs.mElement_DOUBLE_4 == null) { |
| 611 | rs.mElement_DOUBLE_4 = createVector(rs, DataType.FLOAT_64, 4); |
| 612 | } |
| 613 | return rs.mElement_DOUBLE_4; |
| 614 | } |
| 615 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 616 | /** @deprecated renderscript is deprecated in J |
| 617 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 618 | public static Element U8_2(RenderScript rs) { |
| 619 | if(rs.mElement_UCHAR_2 == null) { |
| 620 | rs.mElement_UCHAR_2 = createVector(rs, DataType.UNSIGNED_8, 2); |
| 621 | } |
| 622 | return rs.mElement_UCHAR_2; |
| 623 | } |
| 624 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 625 | /** @deprecated renderscript is deprecated in J |
| 626 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 627 | public static Element U8_3(RenderScript rs) { |
| 628 | if(rs.mElement_UCHAR_3 == null) { |
| 629 | rs.mElement_UCHAR_3 = createVector(rs, DataType.UNSIGNED_8, 3); |
| 630 | } |
| 631 | return rs.mElement_UCHAR_3; |
| 632 | } |
| 633 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 634 | /** @deprecated renderscript is deprecated in J |
| 635 | */ |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 636 | public static Element U8_4(RenderScript rs) { |
| 637 | if(rs.mElement_UCHAR_4 == null) { |
| 638 | rs.mElement_UCHAR_4 = createVector(rs, DataType.UNSIGNED_8, 4); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 639 | } |
| Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 640 | return rs.mElement_UCHAR_4; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 641 | } |
| 642 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 643 | /** @deprecated renderscript is deprecated in J |
| 644 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 645 | public static Element I8_2(RenderScript rs) { |
| 646 | if(rs.mElement_CHAR_2 == null) { |
| 647 | rs.mElement_CHAR_2 = createVector(rs, DataType.SIGNED_8, 2); |
| 648 | } |
| 649 | return rs.mElement_CHAR_2; |
| 650 | } |
| 651 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 652 | /** @deprecated renderscript is deprecated in J |
| 653 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 654 | public static Element I8_3(RenderScript rs) { |
| 655 | if(rs.mElement_CHAR_3 == null) { |
| 656 | rs.mElement_CHAR_3 = createVector(rs, DataType.SIGNED_8, 3); |
| 657 | } |
| 658 | return rs.mElement_CHAR_3; |
| 659 | } |
| 660 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 661 | /** @deprecated renderscript is deprecated in J |
| 662 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 663 | public static Element I8_4(RenderScript rs) { |
| 664 | if(rs.mElement_CHAR_4 == null) { |
| 665 | rs.mElement_CHAR_4 = createVector(rs, DataType.SIGNED_8, 4); |
| 666 | } |
| 667 | return rs.mElement_CHAR_4; |
| 668 | } |
| 669 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 670 | /** @deprecated renderscript is deprecated in J |
| 671 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 672 | public static Element U16_2(RenderScript rs) { |
| 673 | if(rs.mElement_USHORT_2 == null) { |
| 674 | rs.mElement_USHORT_2 = createVector(rs, DataType.UNSIGNED_16, 2); |
| 675 | } |
| 676 | return rs.mElement_USHORT_2; |
| 677 | } |
| 678 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 679 | /** @deprecated renderscript is deprecated in J |
| 680 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 681 | public static Element U16_3(RenderScript rs) { |
| 682 | if(rs.mElement_USHORT_3 == null) { |
| 683 | rs.mElement_USHORT_3 = createVector(rs, DataType.UNSIGNED_16, 3); |
| 684 | } |
| 685 | return rs.mElement_USHORT_3; |
| 686 | } |
| 687 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 688 | /** @deprecated renderscript is deprecated in J |
| 689 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 690 | public static Element U16_4(RenderScript rs) { |
| 691 | if(rs.mElement_USHORT_4 == null) { |
| 692 | rs.mElement_USHORT_4 = createVector(rs, DataType.UNSIGNED_16, 4); |
| 693 | } |
| 694 | return rs.mElement_USHORT_4; |
| 695 | } |
| 696 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 697 | /** @deprecated renderscript is deprecated in J |
| 698 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 699 | public static Element I16_2(RenderScript rs) { |
| 700 | if(rs.mElement_SHORT_2 == null) { |
| 701 | rs.mElement_SHORT_2 = createVector(rs, DataType.SIGNED_16, 2); |
| 702 | } |
| 703 | return rs.mElement_SHORT_2; |
| 704 | } |
| 705 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 706 | /** @deprecated renderscript is deprecated in J |
| 707 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 708 | public static Element I16_3(RenderScript rs) { |
| 709 | if(rs.mElement_SHORT_3 == null) { |
| 710 | rs.mElement_SHORT_3 = createVector(rs, DataType.SIGNED_16, 3); |
| 711 | } |
| 712 | return rs.mElement_SHORT_3; |
| 713 | } |
| 714 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 715 | /** @deprecated renderscript is deprecated in J |
| 716 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 717 | public static Element I16_4(RenderScript rs) { |
| 718 | if(rs.mElement_SHORT_4 == null) { |
| 719 | rs.mElement_SHORT_4 = createVector(rs, DataType.SIGNED_16, 4); |
| 720 | } |
| 721 | return rs.mElement_SHORT_4; |
| 722 | } |
| 723 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 724 | /** @deprecated renderscript is deprecated in J |
| 725 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 726 | public static Element U32_2(RenderScript rs) { |
| 727 | if(rs.mElement_UINT_2 == null) { |
| 728 | rs.mElement_UINT_2 = createVector(rs, DataType.UNSIGNED_32, 2); |
| 729 | } |
| 730 | return rs.mElement_UINT_2; |
| 731 | } |
| 732 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 733 | /** @deprecated renderscript is deprecated in J |
| 734 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 735 | public static Element U32_3(RenderScript rs) { |
| 736 | if(rs.mElement_UINT_3 == null) { |
| 737 | rs.mElement_UINT_3 = createVector(rs, DataType.UNSIGNED_32, 3); |
| 738 | } |
| 739 | return rs.mElement_UINT_3; |
| 740 | } |
| 741 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 742 | /** @deprecated renderscript is deprecated in J |
| 743 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 744 | public static Element U32_4(RenderScript rs) { |
| 745 | if(rs.mElement_UINT_4 == null) { |
| 746 | rs.mElement_UINT_4 = createVector(rs, DataType.UNSIGNED_32, 4); |
| 747 | } |
| 748 | return rs.mElement_UINT_4; |
| 749 | } |
| 750 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 751 | /** @deprecated renderscript is deprecated in J |
| 752 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 753 | public static Element I32_2(RenderScript rs) { |
| 754 | if(rs.mElement_INT_2 == null) { |
| 755 | rs.mElement_INT_2 = createVector(rs, DataType.SIGNED_32, 2); |
| 756 | } |
| 757 | return rs.mElement_INT_2; |
| 758 | } |
| 759 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 760 | /** @deprecated renderscript is deprecated in J |
| 761 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 762 | public static Element I32_3(RenderScript rs) { |
| 763 | if(rs.mElement_INT_3 == null) { |
| 764 | rs.mElement_INT_3 = createVector(rs, DataType.SIGNED_32, 3); |
| 765 | } |
| 766 | return rs.mElement_INT_3; |
| 767 | } |
| 768 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 769 | /** @deprecated renderscript is deprecated in J |
| 770 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 771 | public static Element I32_4(RenderScript rs) { |
| 772 | if(rs.mElement_INT_4 == null) { |
| 773 | rs.mElement_INT_4 = createVector(rs, DataType.SIGNED_32, 4); |
| 774 | } |
| 775 | return rs.mElement_INT_4; |
| 776 | } |
| 777 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 778 | /** @deprecated renderscript is deprecated in J |
| 779 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 780 | public static Element U64_2(RenderScript rs) { |
| 781 | if(rs.mElement_ULONG_2 == null) { |
| 782 | rs.mElement_ULONG_2 = createVector(rs, DataType.UNSIGNED_64, 2); |
| 783 | } |
| 784 | return rs.mElement_ULONG_2; |
| 785 | } |
| 786 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 787 | /** @deprecated renderscript is deprecated in J |
| 788 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 789 | public static Element U64_3(RenderScript rs) { |
| 790 | if(rs.mElement_ULONG_3 == null) { |
| 791 | rs.mElement_ULONG_3 = createVector(rs, DataType.UNSIGNED_64, 3); |
| 792 | } |
| 793 | return rs.mElement_ULONG_3; |
| 794 | } |
| 795 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 796 | /** @deprecated renderscript is deprecated in J |
| 797 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 798 | public static Element U64_4(RenderScript rs) { |
| 799 | if(rs.mElement_ULONG_4 == null) { |
| 800 | rs.mElement_ULONG_4 = createVector(rs, DataType.UNSIGNED_64, 4); |
| 801 | } |
| 802 | return rs.mElement_ULONG_4; |
| 803 | } |
| 804 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 805 | /** @deprecated renderscript is deprecated in J |
| 806 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 807 | public static Element I64_2(RenderScript rs) { |
| 808 | if(rs.mElement_LONG_2 == null) { |
| 809 | rs.mElement_LONG_2 = createVector(rs, DataType.SIGNED_64, 2); |
| 810 | } |
| 811 | return rs.mElement_LONG_2; |
| 812 | } |
| 813 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 814 | /** @deprecated renderscript is deprecated in J |
| 815 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 816 | public static Element I64_3(RenderScript rs) { |
| 817 | if(rs.mElement_LONG_3 == null) { |
| 818 | rs.mElement_LONG_3 = createVector(rs, DataType.SIGNED_64, 3); |
| 819 | } |
| 820 | return rs.mElement_LONG_3; |
| 821 | } |
| 822 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 823 | /** @deprecated renderscript is deprecated in J |
| 824 | */ |
| Stephen Hines | 836c4a5 | 2011-06-01 14:38:10 -0700 | [diff] [blame] | 825 | public static Element I64_4(RenderScript rs) { |
| 826 | if(rs.mElement_LONG_4 == null) { |
| 827 | rs.mElement_LONG_4 = createVector(rs, DataType.SIGNED_64, 4); |
| 828 | } |
| 829 | return rs.mElement_LONG_4; |
| 830 | } |
| 831 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 832 | /** @deprecated renderscript is deprecated in J |
| 833 | */ |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 834 | public static Element MATRIX_4X4(RenderScript rs) { |
| 835 | if(rs.mElement_MATRIX_4X4 == null) { |
| 836 | rs.mElement_MATRIX_4X4 = createUser(rs, DataType.MATRIX_4X4); |
| 837 | } |
| 838 | return rs.mElement_MATRIX_4X4; |
| 839 | } |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 840 | /** @deprecated renderscript is deprecated in J |
| 841 | */ |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 842 | public static Element MATRIX4X4(RenderScript rs) { |
| 843 | return MATRIX_4X4(rs); |
| 844 | } |
| 845 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 846 | /** @deprecated renderscript is deprecated in J |
| 847 | */ |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 848 | public static Element MATRIX_3X3(RenderScript rs) { |
| 849 | if(rs.mElement_MATRIX_3X3 == null) { |
| 850 | rs.mElement_MATRIX_3X3 = createUser(rs, DataType.MATRIX_3X3); |
| 851 | } |
| Alex Sakhartchouk | 3476977 | 2011-02-28 16:01:28 -0800 | [diff] [blame] | 852 | return rs.mElement_MATRIX_3X3; |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 853 | } |
| 854 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 855 | /** @deprecated renderscript is deprecated in J |
| 856 | */ |
| Jason Sams | 1d45c47 | 2010-08-25 14:31:48 -0700 | [diff] [blame] | 857 | public static Element MATRIX_2X2(RenderScript rs) { |
| 858 | if(rs.mElement_MATRIX_2X2 == null) { |
| 859 | rs.mElement_MATRIX_2X2 = createUser(rs, DataType.MATRIX_2X2); |
| 860 | } |
| 861 | return rs.mElement_MATRIX_2X2; |
| 862 | } |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 863 | |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 864 | Element(int id, RenderScript rs, Element[] e, String[] n, int[] as) { |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 865 | super(id, rs); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 866 | mSize = 0; |
| Alex Sakhartchouk | fd79e02 | 2011-12-22 14:30:55 -0800 | [diff] [blame] | 867 | mVectorSize = 1; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 868 | mElements = e; |
| 869 | mElementNames = n; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 870 | mArraySizes = as; |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 871 | mType = DataType.NONE; |
| 872 | mKind = DataKind.USER; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 873 | mOffsetInBytes = new int[mElements.length]; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 874 | for (int ct = 0; ct < mElements.length; ct++ ) { |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 875 | mOffsetInBytes[ct] = mSize; |
| Alex Sakhartchouk | 9e401bc | 2010-10-13 14:22:02 -0700 | [diff] [blame] | 876 | mSize += mElements[ct].mSize * mArraySizes[ct]; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 877 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 878 | updateVisibleSubElements(); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 879 | } |
| 880 | |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 881 | Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { |
| 882 | super(id, rs); |
| Jason Sams | 252c078 | 2011-01-11 17:42:52 -0800 | [diff] [blame] | 883 | if ((dt != DataType.UNSIGNED_5_6_5) && |
| 884 | (dt != DataType.UNSIGNED_4_4_4_4) && |
| 885 | (dt != DataType.UNSIGNED_5_5_5_1)) { |
| Alex Sakhartchouk | e60149d | 2011-11-15 15:15:21 -0800 | [diff] [blame] | 886 | if (size == 3) { |
| 887 | mSize = dt.mSize * 4; |
| 888 | } else { |
| 889 | mSize = dt.mSize * size; |
| 890 | } |
| Jason Sams | 252c078 | 2011-01-11 17:42:52 -0800 | [diff] [blame] | 891 | } else { |
| 892 | mSize = dt.mSize; |
| 893 | } |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 894 | mType = dt; |
| 895 | mKind = dk; |
| 896 | mNormalized = norm; |
| 897 | mVectorSize = size; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 898 | } |
| 899 | |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 900 | Element(int id, RenderScript rs) { |
| 901 | super(id, rs); |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | @Override |
| 905 | void updateFromNative() { |
| Jason Sams | 06d69de | 2010-11-09 17:11:40 -0800 | [diff] [blame] | 906 | super.updateFromNative(); |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 907 | |
| 908 | // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements |
| 909 | int[] dataBuffer = new int[5]; |
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 910 | mRS.nElementGetNativeData(getID(mRS), dataBuffer); |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 911 | |
| 912 | mNormalized = dataBuffer[2] == 1 ? true : false; |
| 913 | mVectorSize = dataBuffer[3]; |
| 914 | mSize = 0; |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 915 | for (DataType dt: DataType.values()) { |
| 916 | if(dt.mID == dataBuffer[0]){ |
| 917 | mType = dt; |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 918 | mSize = mType.mSize * mVectorSize; |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 919 | } |
| 920 | } |
| 921 | for (DataKind dk: DataKind.values()) { |
| 922 | if(dk.mID == dataBuffer[1]){ |
| 923 | mKind = dk; |
| 924 | } |
| 925 | } |
| 926 | |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 927 | int numSubElements = dataBuffer[4]; |
| 928 | if(numSubElements > 0) { |
| 929 | mElements = new Element[numSubElements]; |
| 930 | mElementNames = new String[numSubElements]; |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 931 | mArraySizes = new int[numSubElements]; |
| 932 | mOffsetInBytes = new int[numSubElements]; |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 933 | |
| 934 | int[] subElementIds = new int[numSubElements]; |
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 935 | mRS.nElementGetSubElements(getID(mRS), subElementIds, mElementNames, mArraySizes); |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 936 | for(int i = 0; i < numSubElements; i ++) { |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 937 | mElements[i] = new Element(subElementIds[i], mRS); |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 938 | mElements[i].updateFromNative(); |
| Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 939 | mOffsetInBytes[i] = mSize; |
| 940 | mSize += mElements[i].mSize * mArraySizes[i]; |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 941 | } |
| 942 | } |
| Alex Sakhartchouk | 3aac0ab | 2011-12-22 13:11:48 -0800 | [diff] [blame] | 943 | updateVisibleSubElements(); |
| Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 944 | } |
| 945 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 946 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 947 | * Create a custom Element of the specified DataType. The DataKind will be |
| 948 | * set to USER and the vector size to 1 indicating non-vector. |
| 949 | * |
| 950 | * @param rs The context associated with the new Element. |
| 951 | * @param dt The DataType for the new element. |
| 952 | * @return Element |
| 953 | */ |
| Jason Sams | bf6ef8d7 | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 954 | static Element createUser(RenderScript rs, DataType dt) { |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 955 | DataKind dk = DataKind.USER; |
| 956 | boolean norm = false; |
| 957 | int vecSize = 1; |
| 958 | int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize); |
| 959 | return new Element(id, rs, dt, dk, norm, vecSize); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 960 | } |
| 961 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 962 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 963 | * Create a custom vector element of the specified DataType and vector size. |
| Stephen Hines | 3beb60e | 2012-02-14 20:38:20 -0800 | [diff] [blame] | 964 | * DataKind will be set to USER. Only primitive types (FLOAT_32, FLOAT_64, |
| 965 | * SIGNED_8, SIGNED_16, SIGNED_32, SIGNED_64, UNSIGNED_8, UNSIGNED_16, |
| 966 | * UNSIGNED_32, UNSIGNED_64, BOOLEAN) are supported. |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 967 | * |
| 968 | * @param rs The context associated with the new Element. |
| Stephen Hines | 3beb60e | 2012-02-14 20:38:20 -0800 | [diff] [blame] | 969 | * @param dt The DataType for the new Element. |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 970 | * @param size Vector size for the new Element. Range 2-4 inclusive |
| 971 | * supported. |
| 972 | * |
| 973 | * @return Element |
| 974 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 975 | public static Element createVector(RenderScript rs, DataType dt, int size) { |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 976 | if (size < 2 || size > 4) { |
| Jason Sams | bf6ef8d7 | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 977 | throw new RSIllegalArgumentException("Vector size out of range 2-4."); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 978 | } |
| Stephen Hines | 3beb60e | 2012-02-14 20:38:20 -0800 | [diff] [blame] | 979 | |
| 980 | switch (dt) { |
| 981 | // Support only primitive integer/float/boolean types as vectors. |
| 982 | case FLOAT_32: |
| 983 | case FLOAT_64: |
| 984 | case SIGNED_8: |
| 985 | case SIGNED_16: |
| 986 | case SIGNED_32: |
| 987 | case SIGNED_64: |
| 988 | case UNSIGNED_8: |
| 989 | case UNSIGNED_16: |
| 990 | case UNSIGNED_32: |
| 991 | case UNSIGNED_64: |
| 992 | case BOOLEAN: { |
| 993 | DataKind dk = DataKind.USER; |
| 994 | boolean norm = false; |
| 995 | int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); |
| 996 | return new Element(id, rs, dt, dk, norm, size); |
| 997 | } |
| 998 | |
| 999 | default: { |
| 1000 | throw new RSIllegalArgumentException("Cannot create vector of " + |
| 1001 | "non-primitive type."); |
| 1002 | } |
| 1003 | } |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1006 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1007 | * Create a new pixel Element type. A matching DataType and DataKind must |
| 1008 | * be provided. The DataType and DataKind must contain the same number of |
| 1009 | * components. Vector size will be set to 1. |
| 1010 | * |
| 1011 | * @param rs The context associated with the new Element. |
| 1012 | * @param dt The DataType for the new element. |
| 1013 | * @param dk The DataKind to specify the mapping of each component in the |
| 1014 | * DataType. |
| 1015 | * |
| 1016 | * @return Element |
| 1017 | */ |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1018 | public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) { |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1019 | if (!(dk == DataKind.PIXEL_L || |
| 1020 | dk == DataKind.PIXEL_A || |
| 1021 | dk == DataKind.PIXEL_LA || |
| 1022 | dk == DataKind.PIXEL_RGB || |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1023 | dk == DataKind.PIXEL_RGBA || |
| 1024 | dk == DataKind.PIXEL_DEPTH)) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1025 | throw new RSIllegalArgumentException("Unsupported DataKind"); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1026 | } |
| 1027 | if (!(dt == DataType.UNSIGNED_8 || |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1028 | dt == DataType.UNSIGNED_16 || |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1029 | dt == DataType.UNSIGNED_5_6_5 || |
| 1030 | dt == DataType.UNSIGNED_4_4_4_4 || |
| 1031 | dt == DataType.UNSIGNED_5_5_5_1)) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1032 | throw new RSIllegalArgumentException("Unsupported DataType"); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1033 | } |
| 1034 | if (dt == DataType.UNSIGNED_5_6_5 && dk != DataKind.PIXEL_RGB) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1035 | throw new RSIllegalArgumentException("Bad kind and type combo"); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1036 | } |
| 1037 | if (dt == DataType.UNSIGNED_5_5_5_1 && dk != DataKind.PIXEL_RGBA) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1038 | throw new RSIllegalArgumentException("Bad kind and type combo"); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1039 | } |
| 1040 | if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1041 | throw new RSIllegalArgumentException("Bad kind and type combo"); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1042 | } |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1043 | if (dt == DataType.UNSIGNED_16 && |
| 1044 | dk != DataKind.PIXEL_DEPTH) { |
| 1045 | throw new RSIllegalArgumentException("Bad kind and type combo"); |
| 1046 | } |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1047 | |
| 1048 | int size = 1; |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1049 | switch (dk) { |
| 1050 | case PIXEL_LA: |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1051 | size = 2; |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1052 | break; |
| 1053 | case PIXEL_RGB: |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1054 | size = 3; |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1055 | break; |
| 1056 | case PIXEL_RGBA: |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1057 | size = 4; |
| Alex Sakhartchouk | 8e90f2b | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1058 | break; |
| 1059 | case PIXEL_DEPTH: |
| 1060 | size = 2; |
| 1061 | break; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1062 | } |
| 1063 | |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 1064 | boolean norm = true; |
| 1065 | int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); |
| 1066 | return new Element(id, rs, dt, dk, norm, size); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1067 | } |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1068 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1069 | /** @deprecated renderscript is deprecated in J |
| Stephen Hines | f257e51 | 2011-06-14 14:54:29 -0700 | [diff] [blame] | 1070 | * Check if the current Element is compatible with another Element. |
| 1071 | * Primitive Elements are compatible if they share the same underlying |
| 1072 | * size and type (i.e. U8 is compatible with A_8). User-defined Elements |
| 1073 | * must be equal in order to be compatible. This requires strict name |
| 1074 | * equivalence for all sub-Elements (in addition to structural equivalence). |
| 1075 | * |
| 1076 | * @param e The Element to check compatibility with. |
| 1077 | * |
| 1078 | * @return boolean true if the Elements are compatible, otherwise false. |
| 1079 | */ |
| 1080 | public boolean isCompatible(Element e) { |
| 1081 | // Try strict BaseObj equality to start with. |
| 1082 | if (this.equals(e)) { |
| 1083 | return true; |
| 1084 | } |
| 1085 | |
| 1086 | // Ignore mKind because it is allowed to be different (user vs. pixel). |
| 1087 | // We also ignore mNormalized because it can be different. The mType |
| Stephen Hines | 2094811 | 2012-02-14 19:42:42 -0800 | [diff] [blame] | 1088 | // field must not be NONE since we require name equivalence for |
| 1089 | // all user-created Elements. |
| Stephen Hines | f257e51 | 2011-06-14 14:54:29 -0700 | [diff] [blame] | 1090 | return ((mSize == e.mSize) && |
| Stephen Hines | 2094811 | 2012-02-14 19:42:42 -0800 | [diff] [blame] | 1091 | (mType != DataType.NONE) && |
| Stephen Hines | f257e51 | 2011-06-14 14:54:29 -0700 | [diff] [blame] | 1092 | (mType == e.mType) && |
| 1093 | (mVectorSize == e.mVectorSize)); |
| 1094 | } |
| 1095 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1096 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1097 | * Builder class for producing complex elements with matching field and name |
| 1098 | * pairs. The builder starts empty. The order in which elements are added |
| 1099 | * is retained for the layout in memory. |
| 1100 | * |
| 1101 | */ |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1102 | public static class Builder { |
| 1103 | RenderScript mRS; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1104 | Element[] mElements; |
| 1105 | String[] mElementNames; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1106 | int[] mArraySizes; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1107 | int mCount; |
| Alex Sakhartchouk | e60149d | 2011-11-15 15:15:21 -0800 | [diff] [blame] | 1108 | int mSkipPadding; |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1109 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1110 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1111 | * Create a builder object. |
| 1112 | * |
| 1113 | * @param rs |
| 1114 | */ |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1115 | public Builder(RenderScript rs) { |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1116 | mRS = rs; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1117 | mCount = 0; |
| 1118 | mElements = new Element[8]; |
| 1119 | mElementNames = new String[8]; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1120 | mArraySizes = new int[8]; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1123 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1124 | * Add an array of elements to this element. |
| 1125 | * |
| 1126 | * @param element |
| 1127 | * @param name |
| 1128 | * @param arraySize |
| 1129 | */ |
| Jason Sams | bf6ef8d7 | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 1130 | public Builder add(Element element, String name, int arraySize) { |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1131 | if (arraySize < 1) { |
| Jason Sams | c1d6210 | 2010-11-04 14:32:19 -0700 | [diff] [blame] | 1132 | throw new RSIllegalArgumentException("Array size cannot be less than 1."); |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1133 | } |
| Alex Sakhartchouk | e60149d | 2011-11-15 15:15:21 -0800 | [diff] [blame] | 1134 | |
| 1135 | // Skip padding fields after a vector 3 type. |
| 1136 | if (mSkipPadding != 0) { |
| 1137 | if (name.startsWith("#padding_")) { |
| 1138 | mSkipPadding = 0; |
| 1139 | return this; |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | if (element.mVectorSize == 3) { |
| 1144 | mSkipPadding = 1; |
| 1145 | } else { |
| 1146 | mSkipPadding = 0; |
| 1147 | } |
| 1148 | |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1149 | if(mCount == mElements.length) { |
| 1150 | Element[] e = new Element[mCount + 8]; |
| 1151 | String[] s = new String[mCount + 8]; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1152 | int[] as = new int[mCount + 8]; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1153 | System.arraycopy(mElements, 0, e, 0, mCount); |
| 1154 | System.arraycopy(mElementNames, 0, s, 0, mCount); |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1155 | System.arraycopy(mArraySizes, 0, as, 0, mCount); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1156 | mElements = e; |
| 1157 | mElementNames = s; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1158 | mArraySizes = as; |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1159 | } |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1160 | mElements[mCount] = element; |
| 1161 | mElementNames[mCount] = name; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1162 | mArraySizes[mCount] = arraySize; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1163 | mCount++; |
| Jason Sams | bf6ef8d7 | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 1164 | return this; |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1165 | } |
| 1166 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1167 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1168 | * Add a single element to this Element. |
| 1169 | * |
| 1170 | * @param element |
| 1171 | * @param name |
| 1172 | */ |
| Jason Sams | bf6ef8d7 | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 1173 | public Builder add(Element element, String name) { |
| 1174 | return add(element, name, 1); |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
| Alex Sakhartchouk | a0c2eb2 | 2012-04-19 16:30:58 -0700 | [diff] [blame] | 1177 | /** @deprecated renderscript is deprecated in J |
| Jason Sams | a1b13ed | 2010-11-12 14:58:37 -0800 | [diff] [blame] | 1178 | * Create the element from this builder. |
| 1179 | * |
| 1180 | * |
| 1181 | * @return Element |
| 1182 | */ |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1183 | public Element create() { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 1184 | mRS.validate(); |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1185 | Element[] ein = new Element[mCount]; |
| 1186 | String[] sin = new String[mCount]; |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1187 | int[] asin = new int[mCount]; |
| Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 1188 | java.lang.System.arraycopy(mElements, 0, ein, 0, mCount); |
| 1189 | java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount); |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1190 | java.lang.System.arraycopy(mArraySizes, 0, asin, 0, mCount); |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 1191 | |
| 1192 | int[] ids = new int[ein.length]; |
| 1193 | for (int ct = 0; ct < ein.length; ct++ ) { |
| Jason Sams | e07694b | 2012-04-03 15:36:36 -0700 | [diff] [blame] | 1194 | ids[ct] = ein[ct].getID(mRS); |
| Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 1195 | } |
| Jason Sams | 70d4e50 | 2010-09-02 17:35:23 -0700 | [diff] [blame] | 1196 | int id = mRS.nElementCreate2(ids, sin, asin); |
| 1197 | return new Element(id, mRS, ein, sin, asin); |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1198 | } |
| 1199 | } |
| Jason Sams | 36e612a | 2009-07-31 16:26:13 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |