1/* 2 * Copyright (C) 2015 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 17package com.android.rs.test; 18 19import android.content.Context; 20import android.renderscript.Allocation; 21import android.renderscript.Element; 22import android.renderscript.RenderScript; 23import android.renderscript.Type; 24 25public class UT_kernel2d extends UnitTest { 26 private Type T; 27 private Allocation A; 28 private Allocation B; 29 30 protected UT_kernel2d(RSTestCore rstc, Context ctx) { 31 super(rstc, "Kernel 2d (pass-by-value)", ctx); 32 } 33 34 private void initializeGlobals(RenderScript RS, ScriptC_kernel2d s) { 35 Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); 36 int X = 2; 37 s.set_gDimX(X); 38 typeBuilder.setX(X); 39 int Y = 5; 40 s.set_gDimY(Y); 41 typeBuilder.setY(Y); 42 43 T = typeBuilder.create(); 44 A = Allocation.createTyped(RS, T); 45 s.set_A(A); 46 B = Allocation.createTyped(RS, T); 47 s.set_B(B); 48 return; 49 } 50 51 public void run() { 52 RenderScript pRS = RenderScript.create(mCtx); 53 ScriptC_kernel2d s = new ScriptC_kernel2d(pRS); 54 pRS.setMessageHandler(mRsMessage); 55 initializeGlobals(pRS, s); 56 s.forEach_init_vars(A); 57 s.forEach_root(A, B); 58 s.invoke_verify_root(); 59 s.invoke_kernel_test(); 60 pRS.finish(); 61 waitForMessage(); 62 T.destroy(); 63 A.destroy(); 64 B.destroy(); 65 s.destroy(); 66 pRS.destroy(); 67 } 68} 69