1// This file is automatically generated from
2// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py
3/*
4 * Copyright (C) 2017 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package com.android.rs.unittest;
20
21import android.content.Context;
22import android.support.v8.renderscript.Allocation;
23import android.support.v8.renderscript.Element;
24import android.support.v8.renderscript.RenderScript;
25import android.support.v8.renderscript.Type;
26
27public class UT_kernel2d_oldstyle extends UnitTest {
28    private Type T;
29    private Allocation A;
30    private Allocation B;
31
32    public UT_kernel2d_oldstyle(Context ctx) {
33        super("Kernel 2d (old style)", ctx);
34    }
35
36    private void initializeGlobals(RenderScript RS, ScriptC_kernel2d_oldstyle s) {
37        Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
38        int X = 2;
39        s.set_gDimX(X);
40        typeBuilder.setX(X);
41        int Y = 5;
42        s.set_gDimY(Y);
43        typeBuilder.setY(Y);
44
45        T = typeBuilder.create();
46        A = Allocation.createTyped(RS, T);
47        s.set_A(A);
48        B = Allocation.createTyped(RS, T);
49        s.set_B(B);
50        return;
51    }
52
53    public void run() {
54        RenderScript pRS = createRenderScript(true);
55        ScriptC_kernel2d_oldstyle s = new ScriptC_kernel2d_oldstyle(pRS);
56        initializeGlobals(pRS, s);
57        s.forEach_init_vars(A);
58        s.forEach_xform(A, B);
59        s.invoke_verify_xform();
60        s.invoke_kernel_test();
61        pRS.finish();
62        T.destroy();
63        A.destroy();
64        B.destroy();
65        s.destroy();
66        pRS.destroy();
67    }
68}
69