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
21class ScriptIntrinsicColorMatrixThunker extends ScriptIntrinsicColorMatrix {
22    android.renderscript.ScriptIntrinsicColorMatrix mN;
23
24    android.renderscript.ScriptIntrinsicColorMatrix getNObj() {
25        return mN;
26    }
27
28    private ScriptIntrinsicColorMatrixThunker(int id, RenderScript rs) {
29        super(id, rs);
30    }
31
32    public static ScriptIntrinsicColorMatrixThunker create(RenderScript rs, Element e) {
33        RenderScriptThunker rst = (RenderScriptThunker) rs;
34        ElementThunker et = (ElementThunker)e;
35
36        ScriptIntrinsicColorMatrixThunker cm =  new ScriptIntrinsicColorMatrixThunker(0, rs);
37        try {
38            cm.mN = android.renderscript.ScriptIntrinsicColorMatrix.create(rst.mN, et.getNObj());
39        } catch (android.renderscript.RSRuntimeException exc) {
40            throw ExceptionThunker.convertException(exc);
41        }
42        return cm;
43
44    }
45
46    public void setColorMatrix(Matrix4f m) {
47        try {
48            mN.setColorMatrix(new android.renderscript.Matrix4f(m.getArray()));
49        } catch (android.renderscript.RSRuntimeException e) {
50            throw ExceptionThunker.convertException(e);
51        }
52    }
53
54    public void setColorMatrix(Matrix3f m) {
55        try {
56            mN.setColorMatrix(new android.renderscript.Matrix3f(m.getArray()));
57        } catch (android.renderscript.RSRuntimeException e) {
58            throw ExceptionThunker.convertException(e);
59        }
60    }
61
62    public void setGreyscale() {
63        try {
64            mN.setGreyscale();
65        } catch (android.renderscript.RSRuntimeException e) {
66            throw ExceptionThunker.convertException(e);
67        }
68    }
69
70    public void setYUVtoRGB() {
71        try {
72            mN.setYUVtoRGB();
73        } catch (android.renderscript.RSRuntimeException e) {
74            throw ExceptionThunker.convertException(e);
75        }
76    }
77
78    public void setRGBtoYUV() {
79        try {
80            mN.setRGBtoYUV();
81        } catch (android.renderscript.RSRuntimeException e) {
82            throw ExceptionThunker.convertException(e);
83        }
84    }
85
86
87    public void forEach(Allocation ain, Allocation aout) {
88        AllocationThunker aint = (AllocationThunker)ain;
89        AllocationThunker aoutt = (AllocationThunker)aout;
90        try {
91            mN.forEach(aint.getNObj(), aoutt.getNObj());
92        } catch (android.renderscript.RSRuntimeException e) {
93            throw ExceptionThunker.convertException(e);
94        }
95    }
96
97    public Script.KernelID getKernelID() {
98        Script.KernelID k = createKernelID(0, 3, null, null);
99        try {
100            k.mN = mN.getKernelID();
101        } catch (android.renderscript.RSRuntimeException e) {
102            throw ExceptionThunker.convertException(e);
103        }
104        return k;
105    }
106
107}
108
109