1/*
2 * Copyright (C) 2011-2014 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/*
18 * This file is auto-generated. DO NOT MODIFY!
19 * The source Renderscript file: reduce_general_struct.rs
20 */
21
22package struct;
23
24import android.renderscript.*;
25import struct.reduce_general_structBitCode;
26
27/**
28 * @hide
29 */
30public class ScriptC_reduce_general_struct extends ScriptC {
31    private static final String __rs_resource_name = "reduce_general_struct";
32    // Constructor
33    public  ScriptC_reduce_general_struct(RenderScript rs) {
34        super(rs,
35              __rs_resource_name,
36              reduce_general_structBitCode.getBitCode32(),
37              reduce_general_structBitCode.getBitCode64());
38        mRSLocal = rs;
39        __I32 = Element.I32(rs);
40        __ScriptField_MyStruct = ScriptField_MyStruct.createElement(rs);
41    }
42
43    private Element __I32;
44    private Element __ScriptField_MyStruct;
45    private RenderScript mRSLocal;
46    // To obtain the result, invoke get(), which blocks
47    // until the asynchronously-launched operation has completed.
48    public static class result_int {
49        public int get() {
50            if (!mGotResult) {
51                int[] outArray = new int[1];
52                mOut.copyTo(outArray);
53                mResult = outArray[0];
54                mOut.destroy();
55                mOut = null;  // make Java object eligible for garbage collection
56                if (mTempIns != null) {
57                    for (Allocation tempIn : mTempIns) {
58                        tempIn.destroy();
59                    }
60
61                    mTempIns = null;  // make Java objects eligible for garbage collection
62                }
63
64                mGotResult = true;
65            }
66
67            return mResult;
68        }
69
70        private  result_int(Allocation out) {
71            mTempIns = null;
72            mOut = out;
73            mGotResult = false;
74        }
75
76        private Allocation[] mTempIns;
77        private Allocation mOut;
78        private boolean mGotResult;
79        private int mResult;
80    }
81
82    private final static int mExportReduceIdx_inStruct = 0;
83    // ain1 = "/* struct <> */ val"
84    public result_int reduce_inStruct(Allocation ain1) {
85        return reduce_inStruct(ain1, null);
86    }
87
88    // ain1 = "/* struct <> */ val"
89    public result_int reduce_inStruct(Allocation ain1, Script.LaunchOptions sc) {
90        // check ain1
91        if (!ain1.getType().getElement().isCompatible(__ScriptField_MyStruct)) {
92            throw new RSRuntimeException("Type mismatch with ScriptField_MyStruct!");
93        }
94        Allocation aout = Allocation.createSized(mRSLocal, __I32, 1);
95        aout.setAutoPadding(true);
96        reduce(mExportReduceIdx_inStruct, new Allocation[]{ain1}, aout, sc);
97        return new result_int(aout);
98    }
99
100}
101
102