1/*
2 * Copyright (C) 2013 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.support.v8.renderscript;
18
19import android.util.Log;
20
21/**
22 *
23 * @hide
24 **/
25class ScriptIntrinsic3DLUTThunker extends ScriptIntrinsic3DLUT {
26    android.renderscript.ScriptIntrinsic3DLUT mN;
27
28    android.renderscript.ScriptIntrinsic3DLUT getNObj() {
29        return mN;
30    }
31
32    private ScriptIntrinsic3DLUTThunker(int id, RenderScript rs, Element e) {
33        super(id, rs, e);
34    }
35
36    public static ScriptIntrinsic3DLUTThunker create(RenderScript rs, Element e) {
37        RenderScriptThunker rst = (RenderScriptThunker) rs;
38        ElementThunker et = (ElementThunker) e;
39
40        ScriptIntrinsic3DLUTThunker lut = new ScriptIntrinsic3DLUTThunker(0, rs, e);
41        try {
42            lut.mN = android.renderscript.ScriptIntrinsic3DLUT.create(rst.mN, et.getNObj());
43        } catch (android.renderscript.RSRuntimeException exc) {
44            throw ExceptionThunker.convertException(exc);
45        }
46        return lut;
47    }
48
49    public void setLUT(Allocation lut) {
50        AllocationThunker lutt = (AllocationThunker) lut;
51        try {
52            mN.setLUT(lutt.getNObj());
53        } catch (android.renderscript.RSRuntimeException e) {
54            throw ExceptionThunker.convertException(e);
55        }
56    }
57
58
59    /**
60     * Invoke the kernel and apply the lookup to each cell of ain
61     * and copy to aout.
62     *
63     * @param ain Input allocation
64     * @param aout Output allocation
65     */
66    public void forEach(Allocation ain, Allocation aout) {
67        AllocationThunker aint = (AllocationThunker)ain;
68        AllocationThunker aoutt = (AllocationThunker)aout;
69        try {
70            mN.forEach(aint.getNObj(), aoutt.getNObj());
71        } catch (android.renderscript.RSRuntimeException e) {
72            throw ExceptionThunker.convertException(e);
73        }
74    }
75
76    /**
77     * Get a KernelID for this intrinsic kernel.
78     *
79     * @return Script.KernelID The KernelID object.
80     */
81    public Script.KernelID getKernelID() {
82        Script.KernelID k = createKernelID(0, 3, null, null);
83        try {
84            k.mN = mN.getKernelID();
85        } catch (android.renderscript.RSRuntimeException e) {
86            throw ExceptionThunker.convertException(e);
87        }
88        return k;
89    }
90}
91
92