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_single_source_script extends UnitTest { 26 private Allocation testAllocation1, testAllocation2; 27 28 protected UT_single_source_script(RSTestCore rstc, Context ctx) { 29 super(rstc, "SingleSourceScript", ctx); 30 } 31 32 private void initializeGlobals(RenderScript RS, ScriptC_single_source_script s) { 33 Type.Builder i32TypeBuilder = new Type.Builder(RS, Element.I32(RS)); 34 int X = 1024; 35 int Y = 768; 36 s.set_dimX(X); 37 s.set_dimY(Y); 38 i32TypeBuilder.setX(X).setY(Y); 39 testAllocation1 = Allocation.createTyped(RS, i32TypeBuilder.create()); 40 testAllocation2 = Allocation.createTyped(RS, i32TypeBuilder.create()); 41 } 42 43 public void run() { 44 RenderScript pRS = RenderScript.create(mCtx); 45 ScriptC_single_source_script s = new ScriptC_single_source_script(pRS); 46 pRS.setMessageHandler(mRsMessage); 47 initializeGlobals(pRS, s); 48 49 s.invoke_entrypoint(testAllocation1, testAllocation2); 50 s.forEach_oldFoo(testAllocation2, testAllocation2); 51 s.forEach_oldGoo(testAllocation2, testAllocation2); 52 s.invoke_validate(testAllocation2); 53 54 pRS.finish(); 55 waitForMessage(); 56 s.destroy(); 57 pRS.destroy(); 58 } 59} 60