ScriptIntrinsicConvolve5x5.java revision 3a5b8011765906c15b5474b2bc43d80f6746cb45
1/*
2 * Copyright (C) 2012 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 android.renderscript;
18
19import android.util.Log;
20
21/**
22 * @hide
23 **/
24public class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic {
25    private float[] mValues = new float[25];
26    private Allocation mInput;
27
28    ScriptIntrinsicConvolve5x5(int id, RenderScript rs) {
29        super(id, rs);
30    }
31
32    /**
33     * Supported elements types are float, float4, uchar, uchar4
34     *
35     *
36     * @param rs
37     * @param e
38     *
39     * @return ScriptIntrinsicConvolve5x5
40     */
41    public static ScriptIntrinsicConvolve5x5 create(RenderScript rs, Element e) {
42        int id = rs.nScriptIntrinsicCreate(4, e.getID(rs));
43        return new ScriptIntrinsicConvolve5x5(id, rs);
44
45    }
46
47    public void setInput(Allocation ain) {
48        mInput = ain;
49        bindAllocation(ain, 1);
50    }
51
52    public void setCoefficients(float v[]) {
53        FieldPacker fp = new FieldPacker(25*4);
54        for (int ct=0; ct < mValues.length; ct++) {
55            mValues[ct] = v[ct];
56            fp.addF32(mValues[ct]);
57        }
58        setVar(0, fp);
59    }
60
61    public void forEach(Allocation aout) {
62        forEach(0, null, aout, null);
63    }
64
65}
66
67