ScriptC_reduce_general_examples_backward.java.expect revision 6a360ef49a83c623784ce97e32f7c07b170ef364
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_backward.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_backwardBitCode; 29 30/** 31 * @hide 32 */ 33public class ScriptC_reduce_general_examples_backward extends ScriptC { 34 private static final String __rs_resource_name = "reduce_general_examples_backward"; 35 // Constructor 36 public ScriptC_reduce_general_examples_backward(RenderScript rs) { 37 super(rs, 38 __rs_resource_name, 39 reduce_general_examples_backwardBitCode.getBitCode32(), 40 reduce_general_examples_backwardBitCode.getBitCode64()); 41 mRSLocal = rs; 42 __I32 = Element.I32(rs); 43 __F32 = Element.F32(rs); 44 __I32_2 = Element.I32_2(rs); 45 __U32 = Element.U32(rs); 46 __U8 = Element.U8(rs); 47 } 48 49 private Element __F32; 50 private Element __I32; 51 private Element __I32_2; 52 private Element __U32; 53 private Element __U8; 54 private RenderScript mRSLocal; 55 // To obtain the result, invoke get(), which blocks 56 // until the asynchronously-launched operation has completed. 57 public static class resultArray256_uint { 58 public long[] get() { 59 if (!mGotResult) { 60 int[] outArray = new int[256]; 61 mOut.copyTo(outArray); 62 long[] result = new long[256]; 63 for (int Idx = 0; Idx < 256; ++Idx) { 64 result[Idx] = ((long) ((outArray[Idx]) & 0xffffffffL)); 65 } 66 67 mResult = result; 68 mOut.destroy(); 69 mOut = null; // make Java object eligible for garbage collection 70 if (mTempIns != null) { 71 for (Allocation tempIn : mTempIns) { 72 tempIn.destroy(); 73 } 74 75 mTempIns = null; // make Java objects eligible for garbage collection 76 } 77 78 mGotResult = true; 79 } 80 81 return mResult; 82 } 83 84 private resultArray256_uint(Allocation out) { 85 mTempIns = null; 86 mOut = out; 87 mGotResult = false; 88 } 89 90 private Allocation[] mTempIns; 91 private Allocation mOut; 92 private boolean mGotResult; 93 private long[] mResult; 94 } 95 96 // To obtain the result, invoke get(), which blocks 97 // until the asynchronously-launched operation has completed. 98 public static class result_float { 99 public float get() { 100 if (!mGotResult) { 101 float[] outArray = new float[1]; 102 mOut.copyTo(outArray); 103 mResult = outArray[0]; 104 mOut.destroy(); 105 mOut = null; // make Java object eligible for garbage collection 106 if (mTempIns != null) { 107 for (Allocation tempIn : mTempIns) { 108 tempIn.destroy(); 109 } 110 111 mTempIns = null; // make Java objects eligible for garbage collection 112 } 113 114 mGotResult = true; 115 } 116 117 return mResult; 118 } 119 120 private result_float(Allocation out) { 121 mTempIns = null; 122 mOut = out; 123 mGotResult = false; 124 } 125 126 private Allocation[] mTempIns; 127 private Allocation mOut; 128 private boolean mGotResult; 129 private float mResult; 130 } 131 132 // To obtain the result, invoke get(), which blocks 133 // until the asynchronously-launched operation has completed. 134 public static class result_int { 135 public int get() { 136 if (!mGotResult) { 137 int[] outArray = new int[1]; 138 mOut.copyTo(outArray); 139 mResult = outArray[0]; 140 mOut.destroy(); 141 mOut = null; // make Java object eligible for garbage collection 142 if (mTempIns != null) { 143 for (Allocation tempIn : mTempIns) { 144 tempIn.destroy(); 145 } 146 147 mTempIns = null; // make Java objects eligible for garbage collection 148 } 149 150 mGotResult = true; 151 } 152 153 return mResult; 154 } 155 156 private result_int(Allocation out) { 157 mTempIns = null; 158 mOut = out; 159 mGotResult = false; 160 } 161 162 private Allocation[] mTempIns; 163 private Allocation mOut; 164 private boolean mGotResult; 165 private int mResult; 166 } 167 168 // To obtain the result, invoke get(), which blocks 169 // until the asynchronously-launched operation has completed. 170 public static class result_int2 { 171 public Int2 get() { 172 if (!mGotResult) { 173 int[] outArray = new int[2]; 174 mOut.copyTo(outArray); 175 mResult = new Int2(outArray[0], outArray[1]); 176 mOut.destroy(); 177 mOut = null; // make Java object eligible for garbage collection 178 if (mTempIns != null) { 179 for (Allocation tempIn : mTempIns) { 180 tempIn.destroy(); 181 } 182 183 mTempIns = null; // make Java objects eligible for garbage collection 184 } 185 186 mGotResult = true; 187 } 188 189 return mResult; 190 } 191 192 private result_int2(Allocation out) { 193 mTempIns = null; 194 mOut = out; 195 mGotResult = false; 196 } 197 198 private Allocation[] mTempIns; 199 private Allocation mOut; 200 private boolean mGotResult; 201 private Int2 mResult; 202 } 203 204 private final static int mExportReduceIdx_addint = 0; 205 // in1 = "val" 206 public result_int reduce_addint(int[] in1) { 207 // Verify that "in1" is non-null. 208 if (in1 == null) { 209 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 210 } 211 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 212 ain1.setAutoPadding(true); 213 ain1.copyFrom(in1); 214 215 result_int result = reduce_addint(ain1, null); 216 result.mTempIns = new Allocation[]{ain1}; 217 return result; 218 } 219 220 // ain1 = "int val" 221 public result_int reduce_addint(Allocation ain1) { 222 return reduce_addint(ain1, null); 223 } 224 225 // ain1 = "int val" 226 public result_int reduce_addint(Allocation ain1, Script.LaunchOptions sc) { 227 // check ain1 228 if (!ain1.getType().getElement().isCompatible(__I32)) { 229 throw new RSRuntimeException("Type mismatch with I32!"); 230 } 231 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 232 aout.setAutoPadding(true); 233 reduce(mExportReduceIdx_addint, new Allocation[]{ain1}, aout, sc); 234 return new result_int(aout); 235 } 236 237 private final static int mExportReduceIdx_mpyint = 1; 238 // in1 = "val" 239 public result_int reduce_mpyint(int[] in1) { 240 // Verify that "in1" is non-null. 241 if (in1 == null) { 242 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 243 } 244 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 245 ain1.setAutoPadding(true); 246 ain1.copyFrom(in1); 247 248 result_int result = reduce_mpyint(ain1, null); 249 result.mTempIns = new Allocation[]{ain1}; 250 return result; 251 } 252 253 // ain1 = "int val" 254 public result_int reduce_mpyint(Allocation ain1) { 255 return reduce_mpyint(ain1, null); 256 } 257 258 // ain1 = "int val" 259 public result_int reduce_mpyint(Allocation ain1, Script.LaunchOptions sc) { 260 // check ain1 261 if (!ain1.getType().getElement().isCompatible(__I32)) { 262 throw new RSRuntimeException("Type mismatch with I32!"); 263 } 264 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 265 aout.setAutoPadding(true); 266 reduce(mExportReduceIdx_mpyint, new Allocation[]{ain1}, aout, sc); 267 return new result_int(aout); 268 } 269 270 private final static int mExportReduceIdx_dp = 2; 271 // in1 = "in1" 272 // in2 = "in2" 273 public result_float reduce_dp(float[] in1, float[] in2) { 274 // Verify that "in1" is non-null. 275 if (in1 == null) { 276 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 277 } 278 Allocation ain1 = Allocation.createSized(mRSLocal, __F32, in1.length); 279 ain1.setAutoPadding(true); 280 ain1.copyFrom(in1); 281 // Verify that "in2" is non-null. 282 if (in2 == null) { 283 throw new RSIllegalArgumentException("Array \"in2\" is null!"); 284 } 285 // Verify that input array lengths are the same. 286 if (in1.length != in2.length) { 287 throw new RSRuntimeException("Array length mismatch between parameters \"in1\" and \"in2\"!"); 288 } 289 Allocation ain2 = Allocation.createSized(mRSLocal, __F32, in2.length); 290 ain2.setAutoPadding(true); 291 ain2.copyFrom(in2); 292 293 result_float result = reduce_dp(ain1, ain2, null); 294 result.mTempIns = new Allocation[]{ain1, ain2}; 295 return result; 296 } 297 298 // ain1 = "float in1" 299 // ain2 = "float in2" 300 public result_float reduce_dp(Allocation ain1, Allocation ain2) { 301 return reduce_dp(ain1, ain2, null); 302 } 303 304 // ain1 = "float in1" 305 // ain2 = "float in2" 306 public result_float reduce_dp(Allocation ain1, Allocation ain2, Script.LaunchOptions sc) { 307 Type t0, t1; 308 // check ain1 309 if (!ain1.getType().getElement().isCompatible(__F32)) { 310 throw new RSRuntimeException("Type mismatch with F32!"); 311 } 312 // check ain2 313 if (!ain2.getType().getElement().isCompatible(__F32)) { 314 throw new RSRuntimeException("Type mismatch with F32!"); 315 } 316 // Verify dimensions 317 t0 = ain1.getType(); 318 t1 = ain2.getType(); 319 if ((t0.getCount() != t1.getCount()) || 320 (t0.getX() != t1.getX()) || 321 (t0.getY() != t1.getY()) || 322 (t0.getZ() != t1.getZ()) || 323 (t0.hasFaces() != t1.hasFaces()) || 324 (t0.hasMipmaps() != t1.hasMipmaps())) { 325 throw new RSRuntimeException("Dimension mismatch between parameters ain1 and ain2!"); 326 } 327 328 Allocation aout = Allocation.createSized(mRSLocal, __F32, 1); 329 aout.setAutoPadding(true); 330 reduce(mExportReduceIdx_dp, new Allocation[]{ain1, ain2}, aout, sc); 331 return new result_float(aout); 332 } 333 334 private final static int mExportReduceIdx_findMinAndMax = 3; 335 // in1 = "in" 336 public result_int2 reduce_findMinAndMax(float[] in1) { 337 // Verify that "in1" is non-null. 338 if (in1 == null) { 339 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 340 } 341 Allocation ain1 = Allocation.createSized(mRSLocal, __F32, in1.length); 342 ain1.setAutoPadding(true); 343 ain1.copyFrom(in1); 344 345 result_int2 result = reduce_findMinAndMax(ain1, null); 346 result.mTempIns = new Allocation[]{ain1}; 347 return result; 348 } 349 350 // ain1 = "float in" 351 public result_int2 reduce_findMinAndMax(Allocation ain1) { 352 return reduce_findMinAndMax(ain1, null); 353 } 354 355 // ain1 = "float in" 356 public result_int2 reduce_findMinAndMax(Allocation ain1, Script.LaunchOptions sc) { 357 // check ain1 358 if (!ain1.getType().getElement().isCompatible(__F32)) { 359 throw new RSRuntimeException("Type mismatch with F32!"); 360 } 361 Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1); 362 aout.setAutoPadding(true); 363 reduce(mExportReduceIdx_findMinAndMax, new Allocation[]{ain1}, aout, sc); 364 return new result_int2(aout); 365 } 366 367 private final static int mExportReduceIdx_fz = 4; 368 // in1 = "inVal" 369 public result_int reduce_fz(int[] in1) { 370 // Verify that "in1" is non-null. 371 if (in1 == null) { 372 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 373 } 374 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 375 ain1.setAutoPadding(true); 376 ain1.copyFrom(in1); 377 378 result_int result = reduce_fz(ain1, null); 379 result.mTempIns = new Allocation[]{ain1}; 380 return result; 381 } 382 383 // ain1 = "int inVal" 384 public result_int reduce_fz(Allocation ain1) { 385 return reduce_fz(ain1, null); 386 } 387 388 // ain1 = "int inVal" 389 public result_int reduce_fz(Allocation ain1, Script.LaunchOptions sc) { 390 // check ain1 391 if (!ain1.getType().getElement().isCompatible(__I32)) { 392 throw new RSRuntimeException("Type mismatch with I32!"); 393 } 394 Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); 395 aout.setAutoPadding(true); 396 reduce(mExportReduceIdx_fz, new Allocation[]{ain1}, aout, sc); 397 return new result_int(aout); 398 } 399 400 private final static int mExportReduceIdx_fz2 = 5; 401 // in1 = "inVal" 402 public result_int2 reduce_fz2(int[] in1) { 403 // Verify that "in1" is non-null. 404 if (in1 == null) { 405 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 406 } 407 Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length); 408 ain1.setAutoPadding(true); 409 ain1.copyFrom(in1); 410 411 result_int2 result = reduce_fz2(ain1, null); 412 result.mTempIns = new Allocation[]{ain1}; 413 return result; 414 } 415 416 // ain1 = "int inVal" 417 public result_int2 reduce_fz2(Allocation ain1) { 418 return reduce_fz2(ain1, null); 419 } 420 421 // ain1 = "int inVal" 422 public result_int2 reduce_fz2(Allocation ain1, Script.LaunchOptions sc) { 423 // check ain1 424 if (!ain1.getType().getElement().isCompatible(__I32)) { 425 throw new RSRuntimeException("Type mismatch with I32!"); 426 } 427 Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1); 428 aout.setAutoPadding(true); 429 reduce(mExportReduceIdx_fz2, new Allocation[]{ain1}, aout, sc); 430 return new result_int2(aout); 431 } 432 433 private final static int mExportReduceIdx_histogram = 6; 434 // in1 = "in" 435 public resultArray256_uint reduce_histogram(byte[] in1) { 436 // Verify that "in1" is non-null. 437 if (in1 == null) { 438 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 439 } 440 Allocation ain1 = Allocation.createSized(mRSLocal, __U8, in1.length); 441 ain1.setAutoPadding(true); 442 ain1.copyFrom(in1); 443 444 resultArray256_uint result = reduce_histogram(ain1, null); 445 result.mTempIns = new Allocation[]{ain1}; 446 return result; 447 } 448 449 // ain1 = "uchar in" 450 public resultArray256_uint reduce_histogram(Allocation ain1) { 451 return reduce_histogram(ain1, null); 452 } 453 454 // ain1 = "uchar in" 455 public resultArray256_uint reduce_histogram(Allocation ain1, Script.LaunchOptions sc) { 456 // check ain1 457 if (!ain1.getType().getElement().isCompatible(__U8)) { 458 throw new RSRuntimeException("Type mismatch with U8!"); 459 } 460 Allocation aout = Allocation.createSized(mRSLocal, __U32, 256); 461 aout.setAutoPadding(true); 462 reduce(mExportReduceIdx_histogram, new Allocation[]{ain1}, aout, sc); 463 return new resultArray256_uint(aout); 464 } 465 466 private final static int mExportReduceIdx_mode = 7; 467 // in1 = "in" 468 public result_int2 reduce_mode(byte[] in1) { 469 // Verify that "in1" is non-null. 470 if (in1 == null) { 471 throw new RSIllegalArgumentException("Array \"in1\" is null!"); 472 } 473 Allocation ain1 = Allocation.createSized(mRSLocal, __U8, in1.length); 474 ain1.setAutoPadding(true); 475 ain1.copyFrom(in1); 476 477 result_int2 result = reduce_mode(ain1, null); 478 result.mTempIns = new Allocation[]{ain1}; 479 return result; 480 } 481 482 // ain1 = "uchar in" 483 public result_int2 reduce_mode(Allocation ain1) { 484 return reduce_mode(ain1, null); 485 } 486 487 // ain1 = "uchar in" 488 public result_int2 reduce_mode(Allocation ain1, Script.LaunchOptions sc) { 489 // check ain1 490 if (!ain1.getType().getElement().isCompatible(__U8)) { 491 throw new RSRuntimeException("Type mismatch with U8!"); 492 } 493 Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1); 494 aout.setAutoPadding(true); 495 reduce(mExportReduceIdx_mode, new Allocation[]{ain1}, aout, sc); 496 return new result_int2(aout); 497 } 498 499} 500 501