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 java.lang.reflect.Method; 20import java.util.ArrayList; 21 22class ScriptGroupThunker extends ScriptGroup { 23 android.renderscript.ScriptGroup mN; 24 25 android.renderscript.ScriptGroup getNObj() { 26 return mN; 27 } 28 29 ScriptGroupThunker(int id, RenderScript rs) { 30 super(id, rs); 31 } 32 33 public void setInput(Script.KernelID s, Allocation a) { 34 AllocationThunker at = (AllocationThunker) a; 35 try { 36 mN.setInput(s.mN, at.getNObj()); 37 } catch (android.renderscript.RSRuntimeException e) { 38 throw ExceptionThunker.convertException(e); 39 } 40 } 41 42 public void setOutput(Script.KernelID s, Allocation a) { 43 AllocationThunker at = (AllocationThunker) a; 44 try { 45 mN.setOutput(s.mN, at.getNObj()); 46 } catch (android.renderscript.RSRuntimeException e) { 47 throw ExceptionThunker.convertException(e); 48 } 49 } 50 51 public void execute() { 52 try { 53 mN.execute(); 54 } catch (android.renderscript.RSRuntimeException e) { 55 throw ExceptionThunker.convertException(e); 56 } 57 } 58 59 60 public static final class Builder { 61 62 android.renderscript.ScriptGroup.Builder bN; 63 RenderScript mRS; 64 65 Builder(RenderScript rs) { 66 RenderScriptThunker rst = (RenderScriptThunker) rs; 67 mRS = rs; 68 try { 69 bN = new android.renderscript.ScriptGroup.Builder(rst.mN); 70 } catch (android.renderscript.RSRuntimeException e) { 71 throw ExceptionThunker.convertException(e); 72 } 73 } 74 75 public Builder addKernel(Script.KernelID k) { 76 try { 77 bN.addKernel(k.mN); 78 } catch (android.renderscript.RSRuntimeException e) { 79 throw ExceptionThunker.convertException(e); 80 } 81 return this; 82 } 83 84 public Builder addConnection(Type t, Script.KernelID from, Script.FieldID to) { 85 TypeThunker tt = (TypeThunker) t; 86 try { 87 bN.addConnection(tt.getNObj(), from.mN, to.mN); 88 } catch (android.renderscript.RSRuntimeException e) { 89 throw ExceptionThunker.convertException(e); 90 } 91 return this; 92 } 93 94 public Builder addConnection(Type t, Script.KernelID from, Script.KernelID to) { 95 TypeThunker tt = (TypeThunker) t; 96 try { 97 bN.addConnection(tt.getNObj(), from.mN, to.mN); 98 } catch (android.renderscript.RSRuntimeException e) { 99 throw ExceptionThunker.convertException(e); 100 } 101 return this; 102 } 103 104 105 106 public ScriptGroupThunker create() { 107 ScriptGroupThunker sg = new ScriptGroupThunker(0, mRS); 108 try { 109 sg.mN = bN.create(); 110 } catch (android.renderscript.RSRuntimeException e) { 111 throw ExceptionThunker.convertException(e); 112 } 113 return sg; 114 } 115 } 116 117 118} 119 120 121