1/* 2 * Copyright (C) 2011-2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* 18 * This file is auto-generated. DO NOT MODIFY! 19 * The source Renderscript file: reduce_general_examples_explicit.rs 20 */ 21 22package examples; 23 24import android.os.Build; 25import android.os.Process; 26import java.lang.reflect.Field; 27import android.renderscript.*; 28import examples.reduce_general_examples_explicitBitCode; 29 30/** 31 * @hide 32 */ 33public class ScriptC_reduce_general_examples_explicit extends ScriptC { 34 private static final String __rs_resource_name = "reduce_general_examples_explicit"; 35 // Constructor 36 public ScriptC_reduce_general_examples_explicit(RenderScript rs) { 37 super(rs, 38 __rs_resource_name, 39 reduce_general_examples_explicitBitCode.getBitCode32(), 40 reduce_general_examples_explicitBitCode.getBitCode64()); 41 mRSLocal = rs; 42 __I32 = Element.I32(rs); 43 __F32 = Element.F32(rs); 44 __U32 = Element.U32(rs); 45 __U8 = Element.U8(rs); 46 } 47 48 private Element __F32; 49 private Element __I32; 50 private Element __U32; 51 private Element __U8; 52 private RenderScript mRSLocal; 53 // To obtain the result, invoke get(), which blocks 54 // until the asynchronously-launched operation has completed. 55 public static class resultArray256_uint { 56 public long[] get() { 57 if (!mGotResult) { 58 int[] outArray = new int[256]; 59 mOut.copyTo(outArray); 60 long[] result = new long[256]; 61 for (int Idx = 0; Idx < 256; ++Idx) { 62 result[Idx] = ((long) ((outArray[Idx]) & 0xffffffffL)); 63 } 64 65 mResult = result; 66 mOut.destroy(); 67 mOut = null; // make Java object eligible for garbage collection 68 if (mTempIns != null) { 69 for (Allocation tempIn : mTempIns) { 70 tempIn.destroy(); 71 } 72 73 mTempIns = null; // make Java objects eligible for garbage collection 74 } 75 76 mGotResult = true; 77 } 78 79 return mResult; 80 } 81 82 private resultArray256_uint(Allocation out) { 83 mTempIns = null; 84 mOut = out; 85 mGotResult = false; 86 } 87 88 private Allocation[] mTempIns; 89 private Allocation mOut; 90 private boolean mGotResult; 91 private long[] mResult; 92 } 93 94 // To obtain the result, invoke get(), which blocks 95 // until the asynchronously-launched operation has completed. 96 public static class result_float { 97 public float get() { 98 if (!mGotResult) { 99 float[] outArray = new float[1]; 100 mOut.copyTo(outArray); 101 mResult = outArray[0]; 102 mOut.destroy(); 103 mOut = null; // make Java object eligible for garbage collection 104 if (mTempIns != null) { 105 for (Allocation tempIn : mTempIns) { 106 tempIn.destroy(); 107 } 108 109 mTempIns = null; // make Java objects eligible for garbage collection 110 } 111 112 mGotResult = true; 113 } 114 115 return mResult; 116 } 117 118 private result_float(Allocation out) { 119 mTempIns = null; 120 mOut = out; 121 mGotResult = false; 122 } 123 124 private Allocation[] mTempIns; 125 private Allocation mOut; 126 private boolean mGotResult; 127 private float mResult; 128 } 129 130 // To obtain the result, invoke get(), which blocks 131 // until the asynchronously-launched operation has completed. 132 public static class result_int { 133 public int get() { 134 if (!mGotResult) { 135 int[] outArray = new int[1]; 136 mOut.copyTo(outArray); 137 mResult = outArray[0]; 138 mOut.destroy(); 139 mOut = null; // make Java object eligible for garbage collection 140 if (mTempIns != null) { 141 for (Allocation tempIn : mTempIns) { 142 tempIn.destroy(); 143 } 144 145 mTempIns = null; // make Java objects eligible for garbage collection 146 } 147 148 mGotResult = true; 149 } 150 151 return mResult; 152 } 153 154 private result_int(Allocation out) { 155 mTempIns = null; 156 mOut = out; 157 mGotResult = false; 158 } 159 160 private Allocation[] mTempIns; 161 private Allocation mOut; 162 private boolean mGotResult; 163 private int mResult; 164 } 165 166 private final static int mExportReduceIdx_addint_init = 0; 167 // in1 = "val" 168 public result_int reduce_addint_init(int[] in1) { 169 // Verify that "in1" is non-null. 170 if (in1 == null) { 171 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 172 } 173 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 174 ain1.setAutoPadding(true); 175 ain1.copyFrom(in1); 176 177 result_int result = reduce_addint_init(ain1, null); 178 result.mTempIns = new Allocation[]{ain1}; 179 return result; 180 } 181 182 // ain1 = "int val" 183 public result_int reduce_addint_init(Allocation ain1) { 184 return reduce_addint_init(ain1, null); 185 } 186 187 // ain1 = "int val" 188 public result_int reduce_addint_init(Allocation ain1, Script.LaunchOptions sc) { 189 // check ain1 190 if (!ain1.getType().getElement().isCompatible(__I32)) { 191 throw new RSRuntimeException("Type mismatch with I32!"); 192 } 193 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 194 aout.setAutoPadding(true); 195 reduce(mExportReduceIdx_addint_init, new Allocation[]{ain1}, aout, sc); 196 return new result_int(aout); 197 } 198 199 private final static int mExportReduceIdx_addint_comb = 1; 200 // in1 = "val" 201 public result_int reduce_addint_comb(int[] in1) { 202 // Verify that "in1" is non-null. 203 if (in1 == null) { 204 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 205 } 206 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 207 ain1.setAutoPadding(true); 208 ain1.copyFrom(in1); 209 210 result_int result = reduce_addint_comb(ain1, null); 211 result.mTempIns = new Allocation[]{ain1}; 212 return result; 213 } 214 215 // ain1 = "int val" 216 public result_int reduce_addint_comb(Allocation ain1) { 217 return reduce_addint_comb(ain1, null); 218 } 219 220 // ain1 = "int val" 221 public result_int reduce_addint_comb(Allocation ain1, Script.LaunchOptions sc) { 222 // check ain1 223 if (!ain1.getType().getElement().isCompatible(__I32)) { 224 throw new RSRuntimeException("Type mismatch with I32!"); 225 } 226 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 227 aout.setAutoPadding(true); 228 reduce(mExportReduceIdx_addint_comb, new Allocation[]{ain1}, aout, sc); 229 return new result_int(aout); 230 } 231 232 private final static int mExportReduceIdx_addint_init_comb = 2; 233 // in1 = "val" 234 public result_int reduce_addint_init_comb(int[] in1) { 235 // Verify that "in1" is non-null. 236 if (in1 == null) { 237 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 238 } 239 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 240 ain1.setAutoPadding(true); 241 ain1.copyFrom(in1); 242 243 result_int result = reduce_addint_init_comb(ain1, null); 244 result.mTempIns = new Allocation[]{ain1}; 245 return result; 246 } 247 248 // ain1 = "int val" 249 public result_int reduce_addint_init_comb(Allocation ain1) { 250 return reduce_addint_init_comb(ain1, null); 251 } 252 253 // ain1 = "int val" 254 public result_int reduce_addint_init_comb(Allocation ain1, Script.LaunchOptions sc) { 255 // check ain1 256 if (!ain1.getType().getElement().isCompatible(__I32)) { 257 throw new RSRuntimeException("Type mismatch with I32!"); 258 } 259 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 260 aout.setAutoPadding(true); 261 reduce(mExportReduceIdx_addint_init_comb, new Allocation[]{ain1}, aout, sc); 262 return new result_int(aout); 263 } 264 265 private final static int mExportReduceIdx_dp_init = 3; 266 // in1 = "in1" 267 // in2 = "in2" 268 public result_float reduce_dp_init(float[] in1, float[] in2) { 269 // Verify that "in1" is non-null. 270 if (in1 == null) { 271 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 272 } 273 Allocation ain1 = Allocation.createSized(mRSLocal, __F32, in1.length); 274 ain1.setAutoPadding(true); 275 ain1.copyFrom(in1); 276 // Verify that "in2" is non-null. 277 if (in2 == null) { 278 throw new RSIllegalArgumentException("Array \"in2\" is null!"); 279 } 280 // Verify that input array lengths are the same. 281 if (in1.length != in2.length) { 282 throw new RSRuntimeException("Array length mismatch between parameters \"in1\" and \"in2\"!"); 283 } 284 Allocation ain2 = Allocation.createSized(mRSLocal, __F32, in2.length); 285 ain2.setAutoPadding(true); 286 ain2.copyFrom(in2); 287 288 result_float result = reduce_dp_init(ain1, ain2, null); 289 result.mTempIns = new Allocation[]{ain1, ain2}; 290 return result; 291 } 292 293 // ain1 = "float in1" 294 // ain2 = "float in2" 295 public result_float reduce_dp_init(Allocation ain1, Allocation ain2) { 296 return reduce_dp_init(ain1, ain2, null); 297 } 298 299 // ain1 = "float in1" 300 // ain2 = "float in2" 301 public result_float reduce_dp_init(Allocation ain1, Allocation ain2, Script.LaunchOptions sc) { 302 Type t0, t1; 303 // check ain1 304 if (!ain1.getType().getElement().isCompatible(__F32)) { 305 throw new RSRuntimeException("Type mismatch with F32!"); 306 } 307 // check ain2 308 if (!ain2.getType().getElement().isCompatible(__F32)) { 309 throw new RSRuntimeException("Type mismatch with F32!"); 310 } 311 // Verify dimensions 312 t0 = ain1.getType(); 313 t1 = ain2.getType(); 314 if ((t0.getCount() != t1.getCount()) || 315 (t0.getX() != t1.getX()) || 316 (t0.getY() != t1.getY()) || 317 (t0.getZ() != t1.getZ()) || 318 (t0.hasFaces() != t1.hasFaces()) || 319 (t0.hasMipmaps() != t1.hasMipmaps())) { 320 throw new RSRuntimeException("Dimension mismatch between parameters ain1 and ain2!"); 321 } 322 323 Allocation aout = Allocation.createSized(mRSLocal, __F32, 1); 324 aout.setAutoPadding(true); 325 reduce(mExportReduceIdx_dp_init, new Allocation[]{ain1, ain2}, aout, sc); 326 return new result_float(aout); 327 } 328 329 private final static int mExportReduceIdx_histogram_init = 4; 330 // in1 = "in" 331 public resultArray256_uint reduce_histogram_init(byte[] in1) { 332 // Verify that "in1" is non-null. 333 if (in1 == null) { 334 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 335 } 336 Allocation ain1 = Allocation.createSized(mRSLocal, __U8, in1.length); 337 ain1.setAutoPadding(true); 338 ain1.copyFrom(in1); 339 340 resultArray256_uint result = reduce_histogram_init(ain1, null); 341 result.mTempIns = new Allocation[]{ain1}; 342 return result; 343 } 344 345 // ain1 = "uchar in" 346 public resultArray256_uint reduce_histogram_init(Allocation ain1) { 347 return reduce_histogram_init(ain1, null); 348 } 349 350 // ain1 = "uchar in" 351 public resultArray256_uint reduce_histogram_init(Allocation ain1, Script.LaunchOptions sc) { 352 // check ain1 353 if (!ain1.getType().getElement().isCompatible(__U8)) { 354 throw new RSRuntimeException("Type mismatch with U8!"); 355 } 356 Allocation aout = Allocation.createSized(mRSLocal, __U32, 256); 357 aout.setAutoPadding(true); 358 reduce(mExportReduceIdx_histogram_init, new Allocation[]{ain1}, aout, sc); 359 return new resultArray256_uint(aout); 360 } 361 362} 363 364