Home | History | Annotate | Download | only in test
      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 
     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_kernel2d_oldstyle extends UnitTest {
     26     private Type T;
     27     private Allocation A;
     28     private Allocation B;
     29 
     30     protected UT_kernel2d_oldstyle(RSTestCore rstc, Context ctx) {
     31         super(rstc, "Kernel 2d (old style)", ctx);
     32     }
     33 
     34     private void initializeGlobals(RenderScript RS, ScriptC_kernel2d_oldstyle 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_oldstyle s = new ScriptC_kernel2d_oldstyle(pRS);
     54         pRS.setMessageHandler(mRsMessage);
     55         initializeGlobals(pRS, s);
     56         s.forEach_init_vars(A);
     57         s.forEach_xform(A, B);
     58         s.invoke_verify_xform();
     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