1 /* 2 * Copyright (C) 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 package android.renderscript.cts; 18 19 import android.renderscript.*; 20 import android.util.Log; 21 22 public class IntrinsicLut extends IntrinsicBase { 23 private ScriptIntrinsicLUT mIntrinsic; 24 private ScriptC_intrinsic_lut mScript; 25 26 short mRed[] = new short[256]; 27 short mGreen[] = new short[256]; 28 short mBlue[] = new short[256]; 29 short mAlpha[] = new short[256]; 30 31 32 createTest()33 public void createTest() { 34 java.util.Random r = new java.util.Random(100); 35 36 mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS)); 37 mScript = new ScriptC_intrinsic_lut(mRS); 38 39 for (int ct=0; ct < 256; ct++) { 40 mRed[ct] = (short)r.nextInt(256); 41 mGreen[ct] = (short)r.nextInt(256); 42 mBlue[ct] = (short)r.nextInt(256); 43 mAlpha[ct] = (short)r.nextInt(256); 44 mIntrinsic.setRed(ct, mRed[ct]); 45 mIntrinsic.setGreen(ct, mGreen[ct]); 46 mIntrinsic.setBlue(ct, mBlue[ct]); 47 mIntrinsic.setAlpha(ct, mAlpha[ct]); 48 } 49 mScript.set_red(mRed); 50 mScript.set_green(mGreen); 51 mScript.set_blue(mBlue); 52 mScript.set_alpha(mAlpha); 53 } 54 55 56 test()57 public void test() { 58 createTest(); 59 makeBuffers(97, 97, Element.U8_4(mRS)); 60 61 mIntrinsic.forEach(mAllocSrc, mAllocDst); 62 mScript.forEach_root(mAllocSrc, mAllocRef); 63 64 mVerify.set_gAllowedIntError(0); 65 mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc); 66 mRS.finish(); 67 checkError(); 68 } 69 test1C()70 public void test1C() { 71 createTest(); 72 makeBuffers(97, 97, Element.U8_4(mRS)); 73 74 Script.LaunchOptions lo = makeClipper(11, 11, 87, 87); 75 76 mIntrinsic.forEach(mAllocSrc, mAllocDst, lo); 77 mScript.forEach_root(mAllocSrc, mAllocRef, lo); 78 79 mVerify.set_gAllowedIntError(0); 80 mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc); 81 mRS.finish(); 82 checkError(); 83 } 84 85 test_ID()86 public void test_ID() { 87 ScriptIntrinsicLUT s = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS)); 88 Script.KernelID kid = s.getKernelID(); 89 if (kid == null) { 90 throw new IllegalStateException("kid must be valid"); 91 } 92 } 93 94 } 95