1 /* 2 * Copyright (C) 2013 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 com.android.rs.test; 18 19 import android.content.Context; 20 import android.renderscript.Allocation; 21 import android.renderscript.Element; 22 import android.renderscript.RenderScript; 23 import android.renderscript.Type; 24 25 public class UT_check_dims extends UnitTest { 26 byte mFailedArr[]; 27 int mData[]; 28 Allocation mAFailed; 29 Allocation mA; 30 static final int Pattern = 0xA5A5A5A5; 31 32 protected UT_check_dims(RSTestCore rstc, Context ctx) { 33 super(rstc, "Check Dims", ctx); 34 } 35 36 private void initializeGlobals(RenderScript RS, ScriptC_check_dims s) { 37 Type.Builder typeBuilder = new Type.Builder(RS, Element.U8(RS)); 38 typeBuilder.setX(1); 39 mAFailed = Allocation.createTyped(RS, typeBuilder.create()); 40 s.set_aFailed(mAFailed); 41 42 mFailedArr = new byte[1]; 43 mFailedArr[0] = 0; 44 mAFailed.copyFrom(mFailedArr); 45 46 typeBuilder = new Type.Builder(RS, Element.I32(RS)); 47 int X = 5; 48 int Y = 7; 49 typeBuilder.setX(X).setY(Y); 50 mA = Allocation.createTyped(RS, typeBuilder.create()); 51 s.set_pattern(Pattern); 52 53 mData = new int[X * Y]; 54 for (int i = 0; i < X * Y; i++) { 55 mData[i] = Pattern; 56 } 57 mA.copyFrom(mData); 58 59 return; 60 } 61 62 public void run() { 63 RenderScript pRS = RenderScript.create(mCtx); 64 ScriptC_check_dims s = new ScriptC_check_dims(pRS); 65 pRS.setMessageHandler(mRsMessage); 66 initializeGlobals(pRS, s); 67 s.forEach_root(mA); 68 s.invoke_check_dims_test(); 69 pRS.finish(); 70 waitForMessage(); 71 mAFailed.destroy(); 72 mA.destroy(); 73 s.destroy(); 74 pRS.destroy(); 75 } 76 } 77