summaryrefslogtreecommitdiff
path: root/tests/java_api/RSUnitTests/supportlibsrc_gen/com/android/rs/unittest/UT_alloc_supportlib.java
blob: 48abaa1d2c245275038cdd604dcd540c313c398d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This file is automatically generated from
// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.rs.unittest;

import android.content.Context;
import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.Type;

public class UT_alloc_supportlib extends UnitTest {
    private Type T;
    private Type mTFaces;
    private Type mTLOD;
    private Type mTFacesLOD;
    private Allocation mAFaces;
    private Allocation mALOD;
    private Allocation mAFacesLOD;

    public UT_alloc_supportlib(Context ctx) {
        super("Alloc (Support Lib)", ctx);
    }

    private void initializeGlobals(RenderScript RS, ScriptC_alloc_supportlib s) {
        Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
        int X = 5;
        int Y = 7;
        int Z = 0;
        s.set_dimX(X);
        s.set_dimY(Y);
        s.set_dimZ(Z);
        typeBuilder.setX(X).setY(Y);
        T = typeBuilder.create();
        Allocation A = Allocation.createTyped(RS, T);
        s.bind_a(A);
        s.set_aRaw(A);

        typeBuilder = new Type.Builder(RS, Element.I32(RS));
        typeBuilder.setX(X).setY(Y).setFaces(true);
        mTFaces = typeBuilder.create();
        mAFaces = Allocation.createTyped(RS, mTFaces);
        s.set_aFaces(mAFaces);
        typeBuilder.setFaces(false).setMipmaps(true);
        mTLOD = typeBuilder.create();
        mALOD = Allocation.createTyped(RS, mTLOD);
        s.set_aLOD(mALOD);
        typeBuilder.setFaces(true).setMipmaps(true);
        mTFacesLOD = typeBuilder.create();
        mAFacesLOD = Allocation.createTyped(RS, mTFacesLOD);
        s.set_aFacesLOD(mAFacesLOD);

        return;
    }

    public void run() {
        RenderScript pRS = createRenderScript(true);
        ScriptC_alloc_supportlib s = new ScriptC_alloc_supportlib(pRS);
        initializeGlobals(pRS, s);
        s.forEach_root(s.get_aRaw());
        s.invoke_alloc_supportlib_test();
        pRS.finish();
        T.destroy();
        s.get_a().destroy();
        mAFaces.destroy();
        mALOD.destroy();
        mAFacesLOD.destroy();
        mTFaces.destroy();
        mTLOD.destroy();
        mTFacesLOD.destroy();
        s.destroy();
        pRS.destroy();
    }
}